MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / lrlines

Function lrlines

src/linreg.cpp:668–773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

666
667
668void lrlines(const ap::real_2d_array& xy,
669 const ap::real_1d_array& s,
670 int n,
671 int& info,
672 double& a,
673 double& b,
674 double& vara,
675 double& varb,
676 double& covab,
677 double& corrab,
678 double& p)
679{
680 int i;
681 double ss;
682 double sx;
683 double sxx;
684 double sy;
685 double stt;
686 double e1;
687 double e2;
688 double t;
689 double chi2;
690
691 if( n<2 )
692 {
693 info = -1;
694 return;
695 }
696 for(i = 0; i <= n-1; i++)
697 {
698 if( ap::fp_less_eq(s(i),0) )
699 {
700 info = -2;
701 return;
702 }
703 }
704 info = 1;
705
706 //
707 // Calculate S, SX, SY, SXX
708 //
709 ss = 0;
710 sx = 0;
711 sy = 0;
712 sxx = 0;
713 for(i = 0; i <= n-1; i++)
714 {
715 t = ap::sqr(s(i));
716 ss = ss+1/t;
717 sx = sx+xy(i,0)/t;
718 sy = sy+xy(i,1)/t;
719 sxx = sxx+ap::sqr(xy(i,0))/t;
720 }
721
722 //
723 // Test for condition number
724 //
725 t = sqrt(4*ap::sqr(sx)+ap::sqr(ss-sxx));

Callers 1

lrlineFunction · 0.85

Calls 1

incompletegammacFunction · 0.85

Tested by

no test coverage detected