Branch Coverage

levmar-2.6/lmbc_core.c
Criterion Covered Total %
branch 333 680 48.9


line true false branch
72 0 138319 if(!lb){ /* no lower bounds */
0 52493 if(!lb){ /* no lower bounds */
73 0 0 if(!ub) /* no upper bounds */
0 0 if(!ub) /* no upper bounds */
76 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
77 0 0 if(p[i]>ub[i]) p[i]=ub[i];
0 0 if(p[i]>ub[i]) p[i]=ub[i];
81 0 138319 if(!ub){ /* lower bounds only */
0 52493 if(!ub){ /* lower bounds only */
82 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
83 0 0 if(p[i]
0 0 if(p[i]
86 553262 138319 for(i=m; i-->0; )
209972 52493 for(i=m; i-->0; )
87 8 553254 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
8 0 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
0 0 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
427877 125377 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
0 125377 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
0 209972 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
0 0 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
0 0 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
157910 52062 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
0 52062 p[i]=__MEDIAN3(lb[i], p[i], ub[i]);
98 0 0 if(!lb){ /* no lower bounds */
0 0 if(!lb){ /* no lower bounds */
99 0 0 if(!ub) /* no upper bounds */
0 0 if(!ub) /* no upper bounds */
102 0 0 if(div){
0 0 if(div){
103 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
104 0 0 if(ub[i]!=LM_REAL_MAX)
0 0 if(ub[i]!=LM_REAL_MAX)
107 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
108 0 0 if(ub[i]!=LM_REAL_MAX)
0 0 if(ub[i]!=LM_REAL_MAX)
114 0 0 if(!ub){ /* lower bounds only */
0 0 if(!ub){ /* lower bounds only */
115 0 0 if(div){
0 0 if(div){
116 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
117 0 0 if(lb[i]!=LM_REAL_MIN)
0 0 if(lb[i]!=LM_REAL_MIN)
120 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
121 0 0 if(lb[i]!=LM_REAL_MIN)
0 0 if(lb[i]!=LM_REAL_MIN)
126 0 0 if(div){
0 0 if(div){
127 0 0 for(i=m; i-->0; ){
0 0 for(i=m; i-->0; ){
128 0 0 if(ub[i]!=LM_REAL_MAX)
0 0 if(ub[i]!=LM_REAL_MAX)
130 0 0 if(lb[i]!=LM_REAL_MIN)
0 0 if(lb[i]!=LM_REAL_MIN)
134 0 0 for(i=m; i-->0; ){
0 0 for(i=m; i-->0; ){
135 0 0 if(ub[i]!=LM_REAL_MAX)
0 0 if(ub[i]!=LM_REAL_MAX)
137 0 0 if(lb[i]!=LM_REAL_MIN)
0 0 if(lb[i]!=LM_REAL_MIN)
159 0 0 for(i=n, max=0.0; i-->0; )
0 0 for(i=n, max=0.0; i-->0; )
160 0 0 if(x[i]>max) max=x[i];
0 0 if(x[i]>max) max=x[i];
161 0 0 else if(x[i]<-max) max=-x[i];
0 0 else if(x[i]<-max) max=-x[i];
163 0 0 for(i=n, sum=0.0; i-->0; ){
0 0 for(i=n, sum=0.0; i-->0; ){
231 10136 2534 for (i = m; i-- > 0; )
892 223 for (i = m; i-- > 0; )
234 0 2534 if (sln > stepmx) {
0 223 if (sln > stepmx) {
237 0 0 for (i = m; i-- > 0; ) /* p * scl */
0 0 for (i = m; i-- > 0; ) /* p * scl */
241 10136 2534 for (i = m, slp = rln = 0.; i-- > 0; ){
892 223 for (i = m, slp = rln = 0.; i-- > 0; ){
244 10136 0 tmp1 = (FABS(x[i])>=LM_CNST(1.))? FABS(x[i]) : LM_CNST(1.);
0 10136 tmp1 = (FABS(x[i])>=LM_CNST(1.))? FABS(x[i]) : LM_CNST(1.);
0 0 tmp1 = (FABS(x[i])>=LM_CNST(1.))? FABS(x[i]) : LM_CNST(1.);
892 0 tmp1 = (FABS(x[i])>=LM_CNST(1.))? FABS(x[i]) : LM_CNST(1.);
0 892 tmp1 = (FABS(x[i])>=LM_CNST(1.))? FABS(x[i]) : LM_CNST(1.);
0 0 tmp1 = (FABS(x[i])>=LM_CNST(1.))? FABS(x[i]) : LM_CNST(1.);
245 10050 86 tmp2 = FABS(p[i])/tmp1;
877 15 tmp2 = FABS(p[i])/tmp1;
246 2543 7593 if(rln < tmp2) rln = tmp2;
228 664 if(rln < tmp2) rln = tmp2;
253 12915 0 for(j = _LSITMAX_; j-- > 0; ) {
421 0 for(j = _LSITMAX_; j-- > 0; ) {
254 51660 12915 for (i = m; i-- > 0; )
1684 421 for (i = m; i-- > 0; )
259 12915 0 if(!sx){
421 0 if(!sx){
263 0 0 for (i = m; i-- > 0; ) xpls[i] *= sx[i];
0 0 for (i = m; i-- > 0; ) xpls[i] *= sx[i];
265 0 0 for (i = m; i-- > 0; ) xpls[i] /= sx[i];
0 0 for (i = m; i-- > 0; ) xpls[i] /= sx[i];
278 2109 10806 if (fpls <= f + slp * alpha * lambda) { /* solution found */
30 391 if (fpls <= f + slp * alpha * lambda) { /* solution found */
280 0 2109 if (lambda == LM_CNST(1.) && sln > stepmx * LM_CNST(.99)) *mxtake = 1;
0 0 if (lambda == LM_CNST(1.) && sln > stepmx * LM_CNST(.99)) *mxtake = 1;
0 30 if (lambda == LM_CNST(1.) && sln > stepmx * LM_CNST(.99)) *mxtake = 1;
0 0 if (lambda == LM_CNST(1.) && sln > stepmx * LM_CNST(.99)) *mxtake = 1;
288 425 10381 if (lambda < rmnlmb) {
193 198 if (lambda < rmnlmb) {
297 0 10381 if (!LM_FINITE(fpls)) {
0 198 if (!LM_FINITE(fpls)) {
302 2534 7847 if (firstback) { /* first backtrack: quadratic fit */
198 0 if (firstback) { /* first backtrack: quadratic fit */
315 8 7839 if (disc > b * b)
0 0 if (disc > b * b)
317 0 8 tlmbda = (-b + ((a3 < 0)? -(LM_REAL)sqrt(disc): (LM_REAL)sqrt(disc))) /a3;
0 0 tlmbda = (-b + ((a3 < 0)? -(LM_REAL)sqrt(disc): (LM_REAL)sqrt(disc))) /a3;
320 7839 0 tlmbda = (-b + ((a3 < 0)? (LM_REAL)sqrt(disc): -(LM_REAL)sqrt(disc))) /a3;
0 0 tlmbda = (-b + ((a3 < 0)? (LM_REAL)sqrt(disc): -(LM_REAL)sqrt(disc))) /a3;
322 0 7847 if (tlmbda > lambda * LM_CNST(.5))
0 0 if (tlmbda > lambda * LM_CNST(.5))
327 8828 1553 if (tlmbda < lambda * LM_CNST(.1))
183 15 if (tlmbda < lambda * LM_CNST(.1))
440 0 12 if(n
0 5 if(n
445 0 12 if(!jacf){
0 5 if(!jacf){
451 0 12 if(!LEVMAR_BOX_CHECK(lb, ub, m)){
0 5 if(!LEVMAR_BOX_CHECK(lb, ub, m)){
456 0 12 if(dscl){ /* check that scaling consts are valid */
0 5 if(dscl){ /* check that scaling consts are valid */
457 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
458 0 0 if(dscl[i]<=0.0){
0 0 if(dscl[i]<=0.0){
464 0 0 if(!sp_pDp){
0 0 if(!sp_pDp){
470 12 0 if(opts){
5 0 if(opts){
485 0 12 if(!work){
0 5 if(!work){
488 0 0 if(!work){
0 0 if(!work){
514 45 12 for(i=0; i
20 5 for(i=0; i
517 45 12 for(i=0; i
20 5 for(i=0; i
518 0 45 if(pDp[i]!=p[i])
0 20 if(pDp[i]!=p[i])
534 0 12 if(!LM_FINITE(p_eL2)) stop=7;
0 5 if(!LM_FINITE(p_eL2)) stop=7;
536 0 12 if(dscl){
0 5 if(dscl){
538 0 0 for(i=m; i-->0; ) p[i]/=dscl[i];
0 0 for(i=m; i-->0; ) p[i]/=dscl[i];
542 9 45014 for(k=0; k
45013 1 for(k=0; k
3 15474 for(k=0; k
15472 2 for(k=0; k
545 2 45011 if(p_eL2<=eps3){ /* error is small */
0 15472 if(p_eL2<=eps3){ /* error is small */
555 45011 0 if(!dscl){
15472 0 if(!dscl){
559 0 0 for(i=m; i-->0; ) sp_pDp[i]=p[i]*dscl[i];
0 0 for(i=m; i-->0; ) sp_pDp[i]=p[i]*dscl[i];
563 0 0 for(i=n; i-->0; ){
0 0 for(i=n; i-->0; ){
567 0 0 for(j=m; j-->0; )
0 0 for(j=m; j-->0; )
573 45000 11 if(nm<__BLOCKSZ__SQ){ // this is a small problem
15472 0 if(nm<__BLOCKSZ__SQ){ // this is a small problem
595 720000 45000 for(i=m*m; i-->0; )
247552 15472 for(i=m*m; i-->0; )
597 180000 45000 for(i=m; i-->0; )
61888 15472 for(i=m; i-->0; )
600 180000 45000 for(l=n; l-->0; ){
61888 15472 for(l=n; l-->0; ){
602 720000 180000 for(i=m; i-->0; ){
247552 61888 for(i=m; i-->0; ){
605 1800000 720000 for(j=i+1; j-->0; ) /* j<=i computes lower triangular part only */
618880 247552 for(j=i+1; j-->0; ) /* j<=i computes lower triangular part only */
613 180000 45000 for(i=m; i-->0; ) /* copy to upper part */
61888 15472 for(i=m; i-->0; ) /* copy to upper part */
614 270000 180000 for(j=i+1; j
92832 61888 for(j=i+1; j
623 33 11 for(i=0; i
0 0 for(i=0; i
626 11000 11 for(i=0; i
0 0 for(i=0; i
629 33000 11000 for(l=0, jacrow=jac+i*m, tmp=e[i]; l
0 0 for(l=0, jacrow=jac+i*m, tmp=e[i]; l
639 180033 45011 for(i=j=numactive=0, p_L2=jacTe_inf=0.0; i
61888 15472 for(i=j=numactive=0, p_L2=jacTe_inf=0.0; i
640 180033 0 if(ub && p[i]==ub[i]){ ++numactive; if(jacTe[i]>0.0) ++j; }
44991 135042 if(ub && p[i]==ub[i]){ ++numactive; if(jacTe[i]>0.0) ++j; }
44986 5 if(ub && p[i]==ub[i]){ ++numactive; if(jacTe[i]>0.0) ++j; }
61888 0 if(ub && p[i]==ub[i]){ ++numactive; if(jacTe[i]>0.0) ++j; }
15462 46426 if(ub && p[i]==ub[i]){ ++numactive; if(jacTe[i]>0.0) ++j; }
15462 0 if(ub && p[i]==ub[i]){ ++numactive; if(jacTe[i]>0.0) ++j; }
641 135042 0 else if(lb && p[i]==lb[i]){ ++numactive; if(jacTe[i]<0.0) ++j; }
0 135042 else if(lb && p[i]==lb[i]){ ++numactive; if(jacTe[i]<0.0) ++j; }
0 0 else if(lb && p[i]==lb[i]){ ++numactive; if(jacTe[i]<0.0) ++j; }
46426 0 else if(lb && p[i]==lb[i]){ ++numactive; if(jacTe[i]<0.0) ++j; }
0 46426 else if(lb && p[i]==lb[i]){ ++numactive; if(jacTe[i]<0.0) ++j; }
0 0 else if(lb && p[i]==lb[i]){ ++numactive; if(jacTe[i]<0.0) ++j; }
642 65098 69944 else if(jacTe_inf < (tmp=FABS(jacTe[i]))) jacTe_inf=tmp;
46898 88144 else if(jacTe_inf < (tmp=FABS(jacTe[i]))) jacTe_inf=tmp;
7938 38488 else if(jacTe_inf < (tmp=FABS(jacTe[i]))) jacTe_inf=tmp;
15755 30671 else if(jacTe_inf < (tmp=FABS(jacTe[i]))) jacTe_inf=tmp;
659 45006 5 if(j==numactive && (jacTe_inf <= eps1)){
0 45006 if(j==numactive && (jacTe_inf <= eps1)){
15472 0 if(j==numactive && (jacTe_inf <= eps1)){
0 15472 if(j==numactive && (jacTe_inf <= eps1)){
666 12 44999 if(k==0){
5 15467 if(k==0){
667 0 12 if(!lb && !ub){ /* no bounds */
0 0 if(!lb && !ub){ /* no bounds */
0 5 if(!lb && !ub){ /* no bounds */
0 0 if(!lb && !ub){ /* no bounds */
668 0 0 for(i=0, tmp=LM_REAL_MIN; i
0 0 for(i=0, tmp=LM_REAL_MIN; i
669 0 0 if(diag_jacTjac[i]>tmp) tmp=diag_jacTjac[i]; /* find max diagonal element */
0 0 if(diag_jacTjac[i]>tmp) tmp=diag_jacTjac[i]; /* find max diagonal element */
679 180033 45011 for(i=0; i
61888 15472 for(i=0; i
706 45011 0 if(issolved){
15472 0 if(issolved){
707 180033 45011 for(i=0; i
61888 15472 for(i=0; i
712 180033 45011 for(i=0, Dp_L2=0.0; i
61888 15472 for(i=0, Dp_L2=0.0; i
718 1 45010 if(Dp_L2<=eps2_sq*p_L2){ /* relative change in p is small, stop */
0 15472 if(Dp_L2<=eps2_sq*p_L2){ /* relative change in p is small, stop */
723 0 45010 if(Dp_L2>=(p_L2+eps2)/(LM_CNST(EPSILON)*LM_CNST(EPSILON))){ /* almost singular */
0 15472 if(Dp_L2>=(p_L2+eps2)/(LM_CNST(EPSILON)*LM_CNST(EPSILON))){ /* almost singular */
728 45010 0 if(!dscl){
15472 0 if(!dscl){
732 0 0 for(i=m; i-->0; ) sp_pDp[i]=pDp[i]*dscl[i];
0 0 for(i=m; i-->0; ) sp_pDp[i]=pDp[i]*dscl[i];
748 0 45010 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
0 0 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
0 15472 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
0 0 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
753 28 44982 if(pDp_eL2<=gamma*p_eL2){
10 15462 if(pDp_eL2<=gamma*p_eL2){
754 102 28 for(i=0, dL=0.0; i
40 10 for(i=0, dL=0.0; i
758 28 0 if(dL>0.0){
10 0 if(dL>0.0){
762 16 12 mu=mu*( (tmp>=LM_CNST(ONE_THIRD))? tmp : LM_CNST(ONE_THIRD) );
10 0 mu=mu*( (tmp>=LM_CNST(ONE_THIRD))? tmp : LM_CNST(ONE_THIRD) );
766 0 0 mu=(mu>=tmp)? tmp : mu;
0 0 mu=(mu>=tmp)? tmp : mu;
776 102 28 for(i=0 ; i
40 10 for(i=0 ; i
779 10072 28 for(i=0; i
40 10 for(i=0; i
794 0 0 if(nu2<=nu){ /* nu has wrapped around (overflown). Thanks to Frank Jordan for spotting this case */
0 0 if(nu2<=nu){ /* nu has wrapped around (overflown). Thanks to Frank Jordan for spotting this case */
800 0 0 for(i=0; i
0 0 for(i=0; i
811 179928 44982 for(i=0, jacTeDp=0.0; i
61848 15462 for(i=0, jacTeDp=0.0; i
816 42448 2534 if(jacTeDp<=-rho*pow(Dp_L2, LM_CNST(_POW_)/LM_CNST(2.0))){
15239 223 if(jacTeDp<=-rho*pow(Dp_L2, LM_CNST(_POW_)/LM_CNST(2.0))){
824 2534 0 tmp=(LM_REAL)sqrt(p_L2); stepmx=LM_CNST(1e3)*( (tmp>=LM_CNST(1.0))? tmp : LM_CNST(1.0) );
223 0 tmp=(LM_REAL)sqrt(p_L2); stepmx=LM_CNST(1e3)*( (tmp>=LM_CNST(1.0))? tmp : LM_CNST(1.0) );
828 2109 425 if(iretcd!=0 || !LM_FINITE(pDp_eL2)) goto gradproj; /* rather inelegant but effective way to handle LNSRCH() failures... */
0 2109 if(iretcd!=0 || !LM_FINITE(pDp_eL2)) goto gradproj; /* rather inelegant but effective way to handle LNSRCH() failures... */
30 193 if(iretcd!=0 || !LM_FINITE(pDp_eL2)) goto gradproj; /* rather inelegant but effective way to handle LNSRCH() failures... */
0 30 if(iretcd!=0 || !LM_FINITE(pDp_eL2)) goto gradproj; /* rather inelegant but effective way to handle LNSRCH() failures... */
878 171492 42873 for(i=0, tmp=0.0; i
61728 15432 for(i=0, tmp=0.0; i
882 0 42873 t0=(tmp<=tini)? tmp : tini; /* guard against poor scaling & large steps; see (3.50) in C.T. Kelley's book */
0 15432 t0=(tmp<=tini)? tmp : tini; /* guard against poor scaling & large steps; see (3.50) in C.T. Kelley's book */
885 40839 2034 for(t=(gprevtaken)? t : t0; t>tming; t*=beta){
80381 0 for(t=(gprevtaken)? t : t0; t>tming; t*=beta){
15407 25 for(t=(gprevtaken)? t : t0; t>tming; t*=beta){
36595 0 for(t=(gprevtaken)? t : t0; t>tming; t*=beta){
886 321524 80381 for(i=0; i
146380 36595 for(i=0; i
889 321524 80381 for(i=0, Dp_L2=0.0; i
146380 36595 for(i=0, Dp_L2=0.0; i
894 80381 0 if(!dscl){
36595 0 if(!dscl){
898 0 0 for(i=m; i-->0; ) sp_pDp[i]=pDp[i]*dscl[i];
0 0 for(i=m; i-->0; ) sp_pDp[i]=pDp[i]*dscl[i];
915 0 80381 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
0 0 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
0 36595 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
0 0 if(!LM_FINITE(pDp_eL2) && !LM_FINITE(VECNORM(hx, n))){
923 321524 80381 for(i=0, jacTeDp=0.0; i
146380 36595 for(i=0, jacTeDp=0.0; i
926 40865 39516 if(gprevtaken && pDp_eL2<=p_eL2 + LM_CNST(2.0)*LM_CNST(0.99999)*jacTeDp){ /* starting t too small */
37465 3400 if(gprevtaken && pDp_eL2<=p_eL2 + LM_CNST(2.0)*LM_CNST(0.99999)*jacTeDp){ /* starting t too small */
15474 21121 if(gprevtaken && pDp_eL2<=p_eL2 + LM_CNST(2.0)*LM_CNST(0.99999)*jacTeDp){ /* starting t too small */
14904 570 if(gprevtaken && pDp_eL2<=p_eL2 + LM_CNST(2.0)*LM_CNST(0.99999)*jacTeDp){ /* starting t too small */
932 42873 43 if(pDp_eL2<=p_eL2 + LM_CNST(2.0)*alpha*jacTeDp) goto terminatePGLS;
15432 6259 if(pDp_eL2<=p_eL2 + LM_CNST(2.0)*alpha*jacTeDp) goto terminatePGLS;
950 179928 44982 for(i=0, Dp_L2=0.0; i
61848 15462 for(i=0, Dp_L2=0.0; i
956 0 44982 if(Dp_L2<=eps2_sq*p_L2){ /* relative change in p is small, stop */
2 15460 if(Dp_L2<=eps2_sq*p_L2){ /* relative change in p is small, stop */
961 179928 44982 for(i=0 ; i
61840 15460 for(i=0 ; i
964 179928 44982 for(i=0; i
61840 15460 for(i=0; i
973 9 3 if(k>=itmax) stop=3;
3 2 if(k>=itmax) stop=3;
975 45 12 for(i=0; i
20 5 for(i=0; i
978 12 0 if(info){
5 0 if(info){
983 45 12 for(i=0, tmp=LM_REAL_MIN; i
20 5 for(i=0, tmp=LM_REAL_MIN; i
984 15 30 if(tmp
5 15 if(tmp
994 12 0 if(covar){
5 0 if(covar){
997 0 12 if(dscl){ /* correct for the scaling */
0 5 if(dscl){ /* correct for the scaling */
998 0 0 for(i=m; i-->0; )
0 0 for(i=m; i-->0; )
999 0 0 for(j=m; j-->0; )
0 0 for(j=m; j-->0; )
1004 0 12 if(freework) free(work);
0 5 if(freework) free(work);
1007 12 0 if(linsolver) (*linsolver)(NULL, NULL, NULL, 0);
5 0 if(linsolver) (*linsolver)(NULL, NULL, NULL, 0);
1014 0 12 if(dscl){
0 5 if(dscl){
1016 0 0 for(i=0; i
0 0 for(i=0; i
1021 12 0 return (stop!=4 && stop!=7)? k : LM_ERROR;
12 0 return (stop!=4 && stop!=7)? k : LM_ERROR;
5 0 return (stop!=4 && stop!=7)? k : LM_ERROR;
5 0 return (stop!=4 && stop!=7)? k : LM_ERROR;
1047 10004 0 if(dta->ffdif){
5250 0 if(dta->ffdif){