Branch Coverage

inverse_interpolate.c
Criterion Covered Total %
branch 135 206 65.5


line true false branch
52 2920 181 if (hi != 0) {
55 44 2876 rmid = MPU_CALLBACK(mid);
56 0 2920 if(_dbgprint)printf(" 01 lo %lu mid %lu hi %lu\n", lo, mid, hi);
57 2373 547 if (rmid >= n) {
59 41 2332 rlo = MPU_CALLBACK(lo);
60 0 2373 if (rlo == n) RETURNI(lo); /* Possible bad limit */
63 3 544 rhi = MPU_CALLBACK(hi);
67 181 0 rlo = MPU_CALLBACK(lo);
68 0 181 if (rlo == n) RETURNI(lo); /* Possible bad limit */
70 244 181 while (hi == 0) {
72 12 232 if (estf <= 1.004) estf = 1.004;
73 162 70 else if (estf > 8.0) estf = 8.0;
75 0 244 : (UV) (estf * (double)lo + 1);
76 0 244 if(_dbgprint)printf(" 0s lo %lu mid %lu hi %lu\n", lo, mid, hi);
77 244 0 rmid = MPU_CALLBACK(mid);
78 181 63 if (rmid >= n) { hi = mid; rhi = rmid; }
80 0 244 if (lo == UV_MAX) break; /* Overflow */
84 3101 0 MPUassert(rlo <= n && rhi >= n, "interpolation: bad initial limits");
0 3101 MPUassert(rlo <= n && rhi >= n, "interpolation: bad initial limits");
85 1 3100 if ((hi-lo) <= 1) RETURNI( (rlo == n || (rlo < n && rhi > n)) ? lo : hi );
1 0 if ((hi-lo) <= 1) RETURNI( (rlo == n || (rlo < n && rhi > n)) ? lo : hi );
1 0 if ((hi-lo) <= 1) RETURNI( (rlo == n || (rlo < n && rhi > n)) ? lo : hi );
0 1 if ((hi-lo) <= 1) RETURNI( (rlo == n || (rlo < n && rhi > n)) ? lo : hi );
88 0 3100 if(_dbgprint)printf(" 1 lo %lu hi %lu\n", lo, hi);
90 112 2988 mid = (n == rhi) ? hi-1 : LINEAR_INTERP(n,lo,hi,rlo,rhi);
91 11 3089 if (mid == lo) mid++; else if (mid == hi) mid--;
15 3074 if (mid == lo) mid++; else if (mid == hi) mid--;
93 3996 123 for (iloopc = 1; (hi-lo) > 1 && rhi > n; iloopc++) {
3884 112 for (iloopc = 1; (hi-lo) > 1 && rhi > n; iloopc++) {
94 3884 0 MPUassert(lo < mid && mid < hi, "interpolation: assume 3 unique points");
0 3884 MPUassert(lo < mid && mid < hi, "interpolation: assume 3 unique points");
95 637 3247 rmid = MPU_CALLBACK(mid);
96 3279 605 if (rmid >= n) { hi = mid; rhi = rmid; }
98 2865 1019 if (rhi == n) break;
106 12 1007 if ((iloopc % 6) == 0) {
108 0 12 if (lo+close > mid) mid = lo+close;
109 0 12 else if (hi-close < mid) mid = hi-close;
115 99 920 if (mid <= lo) mid=lo+1; else if (mid >= hi) mid=hi-1;
103 817 if (mid <= lo) mid=lo+1; else if (mid >= hi) mid=hi-1;
116 1019 0 MPUassert(lo <= mid && mid <= hi, "interpolation: range error");
0 1019 MPUassert(lo <= mid && mid <= hi, "interpolation: range error");
117 0 1019 if(_dbgprint)printf(" 1s lo %lu mid %lu hi %lu (%lu)\n", lo, mid, hi, rhi-n);
120 0 3100 if (rlo == n) RETURNI(lo);
121 152 2948 if ((hi-lo) <= 1) RETURNI((rlo == n || (rlo < n && rhi > n)) ? lo : hi);
152 0 if ((hi-lo) <= 1) RETURNI((rlo == n || (rlo < n && rhi > n)) ? lo : hi);
152 0 if ((hi-lo) <= 1) RETURNI((rlo == n || (rlo < n && rhi > n)) ? lo : hi);
123 29 if ((hi-lo) <= 1) RETURNI((rlo == n || (rlo < n && rhi > n)) ? lo : hi);
123 2948 0 MPUassert(rlo < n && rhi == n, "interpolation: bad step 1 interpolation");
0 2948 MPUassert(rlo < n && rhi == n, "interpolation: bad step 1 interpolation");
127 2948 0 MPUassert(rlo < n && rhi >= n, "interpolation: Ridder initial assumption");
0 2948 MPUassert(rlo < n && rhi >= n, "interpolation: Ridder initial assumption");
128 0 2948 if(_dbgprint)printf(" 2 lo %lu mid %lu hi %lu\n", lo, mid, hi);
130 2915 2821 while ((hi-lo) > 8 && ((hi-lo) > threshold || rhi > n)) {
2788 127 while ((hi-lo) > 8 && ((hi-lo) > threshold || rhi > n)) {
0 127 while ((hi-lo) > 8 && ((hi-lo) > threshold || rhi > n)) {
132 130 2658 UV rx1 = MPU_CALLBACK(x1);
139 0 2788 if(_dbgprint)printf(" 2s lo %lu mid %lu hi %lu (%lu)\n", lo, x1, hi, (rx1>n) ? rx1-n : n-rx1);
0 0 if(_dbgprint)printf(" 2s lo %lu mid %lu hi %lu (%lu)\n", lo, x1, hi, (rx1>n) ? rx1-n : n-rx1);
141 2788 0 if (x3 >= hi || x3 <= lo || x3 == x1) {
2788 0 if (x3 >= hi || x3 <= lo || x3 == x1) {
133 2655 if (x3 >= hi || x3 <= lo || x3 == x1) {
143 133 0 if (rx1 >= n) { hi = x1; rhi = rx1; }
146 78 2577 UV rx3 = MPU_CALLBACK(x3);
147 0 2655 if(_dbgprint)printf(" 2S lo %lu mid %lu hi %lu (%lu)\n", lo, x3, hi, (rx3>n) ? rx3-n : n-rx3);
0 0 if(_dbgprint)printf(" 2S lo %lu mid %lu hi %lu (%lu)\n", lo, x3, hi, (rx3>n) ? rx3-n : n-rx3);
149 0 2655 if (rx1 > rx3) { UV t=x1; x1=x3; x3=t; t=rx1; fx1=rx3; rx3=t; }
150 0 2655 if (rx1 >= n) { hi = x1; rhi = rx1; }
151 191 2464 else if (rx3 >= n) { lo = x1; rlo = rx1; hi = x3; rhi = rx3; }
154 2788 0 MPUassert(rlo < n && rhi >= n, "interpolation: Ridder step error");
0 2788 MPUassert(rlo < n && rhi >= n, "interpolation: Ridder step error");
160 6553 2764 while ((hi-lo) > 1 && ((hi-lo) > threshold || rhi > n)) {
6369 184 while ((hi-lo) > 1 && ((hi-lo) > threshold || rhi > n)) {
0 184 while ((hi-lo) > 1 && ((hi-lo) > threshold || rhi > n)) {
162 62 6307 if (MPU_CALLBACK(mid) < n) lo = mid; /* Keeps invariant f(lo) < n */
4097 2272 if (MPU_CALLBACK(mid) < n) lo = mid; /* Keeps invariant f(lo) < n */
165 0 2948 if(_dbgprint)printf("final %lu - %lu threshold %lu\n", lo, hi, threshold);
192 125 0 for (gn = 2; gn < 20; gn++) {
194 0 125 MPUverbose(2, " interp %"UVuf"-th is around %"UVuf" ... ", n, guess);
196 0 125 MPUverbose(2, "(%"IVdf")\n", (IV)(n-count));
198 47 78 if (n==count || (n>count && n-count < tol) || (n
33 14 if (n==count || (n>count && n-count < tol) || (n
0 33 if (n==count || (n>count && n-count < tol) || (n
14 0 if (n==count || (n>count && n-count < tol) || (n
0 14 if (n==count || (n>count && n-count < tol) || (n
202 0 0 if (count <= n && guess > ming) ming = guess; /* Previous guesses */
0 0 if (count <= n && guess > ming) ming = guess; /* Previous guesses */
203 0 0 if (count >= n && guess < maxg) maxg = guess;
0 0 if (count >= n && guess < maxg) maxg = guess;
205 0 0 if (guess <= ming || guess >= maxg) MPUverbose(2, " fix min/max for %"UVuf"\n",n);
0 0 if (guess <= ming || guess >= maxg) MPUverbose(2, " fix min/max for %"UVuf"\n",n);
0 0 if (guess <= ming || guess >= maxg) MPUverbose(2, " fix min/max for %"UVuf"\n",n);
206 0 0 if (guess <= ming) guess = ming + tol - 1;
207 0 0 if (guess >= maxg) guess = maxg - tol + 1;
210 0 125 if (gn == 20) count = fcnt(guess);
212 64 61 if (fis) {
213 6 58 if (count < n) {
216 527 6 for ( ; count < n; count++)
217 9329 527 while (!fis(++guess))
220 58 0 } else if (count >= n) {
223 7 58 while (!fis(guess)) guess--;
225 151 58 for ( ; count > n; count--)
226 2514 151 while (!fis(--guess))
232 61 64 if (gcount) *gcount = count;