85 #define LOOPIT(x) for (const Numeric* x = &t##x.fd[1]; x >= &t##x.fd[0]; --x)
97 os << gp.
idx <<
" " << gp.
fd[0] <<
" " << gp.
fd[1] <<
"\n";
179 bool ascending = (old_grid[0] <= old_grid[1]);
193 old_grid[0] - extpolfac * (old_grid[1] - old_grid[0]);
195 old_grid[n_old - 1] +
196 extpolfac * (old_grid[n_old - 1] - old_grid[n_old - 2]);
209 Numeric frac = (new_grid[0] - og_min) / (og_max - og_min);
223 assert(0 <= current_position);
224 assert(current_position <= n_old - 2);
228 Numeric lower = old_grid[current_position];
229 Numeric upper = old_grid[current_position + 1];
232 for (
Index i_new = 0; i_new < n_new; ++i_new) {
236 const Numeric tng = new_grid[i_new];
240 assert(og_min <= tng);
241 assert(tng <= og_max);
251 if (tng < lower && current_position > 0) {
254 lower = old_grid[current_position];
255 }
while (tng < lower && current_position > 0);
257 upper = old_grid[current_position + 1];
259 tgp.
idx = current_position;
260 tgp.
fd[0] = (tng - lower) / (upper - lower);
261 tgp.
fd[1] = 1.0 - tgp.
fd[0];
266 if (tng >= upper && current_position < n_old - 2) {
269 upper = old_grid[current_position + 1];
270 }
while (tng >= upper && current_position < n_old - 2);
272 lower = old_grid[current_position];
274 tgp.
idx = current_position;
275 tgp.
fd[0] = (tng - lower) / (upper - lower);
276 tgp.
fd[1] = 1.0 - tgp.
fd[0];
286 tgp.
idx = current_position;
287 tgp.
fd[0] = (tng - lower) / (upper - lower);
288 tgp.
fd[1] = 1.0 - tgp.
fd[0];
295 assert(old_grid[tgp.
idx] <= tng || tgp.
idx == 0);
311 old_grid[0] - extpolfac * (old_grid[1] - old_grid[0]);
313 old_grid[n_old - 1] +
314 extpolfac * (old_grid[n_old - 1] - old_grid[n_old - 2]);
318 Numeric frac = 1 - (new_grid[0] - og_min) / (og_max - og_min);
331 assert(0 <= current_position);
332 assert(current_position <= n_old - 2);
336 Numeric lower = old_grid[current_position];
337 Numeric upper = old_grid[current_position + 1];
339 for (
Index i_new = 0; i_new < n_new; ++i_new) {
341 const Numeric tng = new_grid[i_new];
345 assert(og_min <= tng);
346 assert(tng <= og_max);
355 if (tng > lower && current_position > 0) {
358 lower = old_grid[current_position];
359 }
while (tng > lower && current_position > 0);
361 upper = old_grid[current_position + 1];
363 tgp.
idx = current_position;
364 tgp.
fd[0] = (tng - lower) / (upper - lower);
365 tgp.
fd[1] = 1.0 - tgp.
fd[0];
369 if (tng <= upper && current_position < n_old - 2) {
372 upper = old_grid[current_position + 1];
373 }
while (tng <= upper && current_position < n_old - 2);
375 lower = old_grid[current_position];
377 tgp.
idx = current_position;
378 tgp.
fd[0] = (tng - lower) / (upper - lower);
379 tgp.
fd[1] = 1.0 - tgp.
fd[0];
390 tgp.
idx = current_position;
391 tgp.
fd[0] = (tng - lower) / (upper - lower);
392 tgp.
fd[1] = 1.0 - tgp.
fd[0];
397 assert(old_grid[tgp.
idx] >= tng || tgp.
idx == 0);
430 gridpos(agp, old_grid, v, extpolfac);
453 for (
Index i = 0; i < n - 1; i++) {
458 gp[n - 1].idx = n - 2;
475 gp_new.
fd[0] = gp_old.
fd[0];
476 gp_new.
fd[1] = gp_old.
fd[1];
516 if (gp.
fd[0] < 0.0) {
519 }
else if (gp.
fd[0] > 1.0) {
524 if (gp.
fd[1] < 0.0) {
527 }
else if (gp.
fd[1] > 1.0) {
559 if (gp.
fd[0] > 0.5) {
568 if (gp.
idx == n - 1) {
591 assert(gp.
fd[0] < 0.005);
614 if (gp[i].idx == ie) {
615 assert(gp[i].fd[0] < 0.005);
659 const bool& strict) {
663 if (gp.
idx == i && gp.
fd[0] == 0) {
665 }
else if (gp.
idx == i - 1 && gp.
fd[1] == 0) {
698 assert(gp.
fd[0] >= 0);
699 assert(gp.
fd[1] >= 0);
702 if (gp.
fd[0] > 0 && gp.
fd[1] > 0) {
707 else if (gp.
fd[0] == 0) {
803 itw.
get(iti) = (*r) * (*c);
835 itw.
get(iti) = (*p) * (*r) * (*c);
870 itw.
get(iti) = (*b) * (*p) * (*r) * (*c);
908 itw.
get(iti) = (*s) * (*b) * (*p) * (*r) * (*c);
949 itw.
get(iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
982 for (
Index c = 0; c < 2; ++c) {
1022 for (
Index r = 0; r < 2; ++r)
1023 for (
Index c = 0; c < 2; ++c) {
1065 for (
Index p = 0; p < 2; ++p)
1066 for (
Index r = 0; r < 2; ++r)
1067 for (
Index c = 0; c < 2; ++c) {
1111 for (
Index b = 0; b < 2; ++b)
1112 for (
Index p = 0; p < 2; ++p)
1113 for (
Index r = 0; r < 2; ++r)
1114 for (
Index c = 0; c < 2; ++c) {
1161 for (
Index s = 0; s < 2; ++s)
1162 for (
Index b = 0; b < 2; ++b)
1163 for (
Index p = 0; p < 2; ++p)
1164 for (
Index r = 0; r < 2; ++r)
1165 for (
Index c = 0; c < 2; ++c) {
1218 for (
Index v = 0; v < 2; ++v)
1219 for (
Index s = 0; s < 2; ++s)
1220 for (
Index b = 0; b < 2; ++b)
1221 for (
Index p = 0; p < 2; ++p)
1222 for (
Index r = 0; r < 2; ++r)
1223 for (
Index c = 0; c < 2; ++c) {
1263 for (
Index i = 0; i < n; ++i) {
1298 itw.
get(i, iti) = *c;
1335 for (
Index i = 0; i < n; ++i) {
1351 itw.
get(i, iti) = (*r) * (*c);
1391 for (
Index i = 0; i < n; ++i) {
1401 itw.
get(i, iti) = (*p) * (*r) * (*c);
1444 for (
Index i = 0; i < n; ++i) {
1456 itw.
get(i, iti) = (*b) * (*p) * (*r) * (*c);
1502 for (
Index i = 0; i < n; ++i) {
1516 itw.
get(i, iti) = (*s) * (*b) * (*p) * (*r) * (*c);
1565 for (
Index i = 0; i < n; ++i) {
1581 itw.
get(i, iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
1620 for (
Index i = 0; i < n; ++i) {
1630 for (
Index c = 0; c < 2; ++c) {
1632 tia += a.
get(tc.
idx + c) * itw.
get(i, iti);
1678 for (
Index i = 0; i < n; ++i) {
1689 for (
Index r = 0; r < 2; ++r)
1690 for (
Index c = 0; c < 2; ++c) {
1691 tia += a.
get(tr.
idx + r, tc.
idx + c) * itw.
get(i, iti);
1740 for (
Index i = 0; i < n; ++i) {
1752 for (
Index p = 0; p < 2; ++p)
1753 for (
Index r = 0; r < 2; ++r)
1754 for (
Index c = 0; c < 2; ++c) {
1807 for (
Index i = 0; i < n; ++i) {
1820 for (
Index b = 0; b < 2; ++b)
1821 for (
Index p = 0; p < 2; ++p)
1822 for (
Index r = 0; r < 2; ++r)
1823 for (
Index c = 0; c < 2; ++c) {
1880 for (
Index i = 0; i < n; ++i) {
1894 for (
Index s = 0; s < 2; ++s)
1895 for (
Index b = 0; b < 2; ++b)
1896 for (
Index p = 0; p < 2; ++p)
1897 for (
Index r = 0; r < 2; ++r)
1898 for (
Index c = 0; c < 2; ++c) {
1962 for (
Index i = 0; i < n; ++i) {
1977 for (
Index v = 0; v < 2; ++v)
1978 for (
Index s = 0; s < 2; ++s)
1979 for (
Index b = 0; b < 2; ++b)
1980 for (
Index p = 0; p < 2; ++p)
1981 for (
Index r = 0; r < 2; ++r)
1982 for (
Index c = 0; c < 2; ++c) {
2026 assert(
is_size(itw, nr, nc, 4));
2030 for (
Index ir = 0; ir < nr; ++ir) {
2034 for (
Index ic = 0; ic < nc; ++ic) {
2049 itw.
get(ir, ic, iti) = (*r) * (*c);
2087 assert(
is_size(itw, np, nr, nc, 8));
2090 for (
Index ip = 0; ip < np; ++ip) {
2092 for (
Index ir = 0; ir < nr; ++ir) {
2094 for (
Index ic = 0; ic < nc; ++ic) {
2102 itw.
get(ip, ir, ic, iti) = (*p) * (*r) * (*c);
2144 assert(
is_size(itw, nb, np, nr, nc, 16));
2147 for (
Index ib = 0; ib < nb; ++ib) {
2149 for (
Index ip = 0; ip < np; ++ip) {
2151 for (
Index ir = 0; ir < nr; ++ir) {
2153 for (
Index ic = 0; ic < nc; ++ic) {
2162 itw.
get(ib, ip, ir, ic, iti) = (*b) * (*p) * (*r) * (*c);
2208 assert(
is_size(itw,
ns, nb, np, nr, nc, 32));
2211 for (
Index is = 0; is <
ns; ++is) {
2213 for (
Index ib = 0; ib < nb; ++ib) {
2215 for (
Index ip = 0; ip < np; ++ip) {
2217 for (
Index ir = 0; ir < nr; ++ir) {
2219 for (
Index ic = 0; ic < nc; ++ic) {
2229 itw.
get(is, ib, ip, ir, ic, iti) =
2230 (*s) * (*b) * (*p) * (*r) * (*c);
2280 assert(
is_size(itw, nv,
ns, nb, np, nr, nc, 64));
2283 for (
Index iv = 0; iv < nv; ++iv) {
2285 for (
Index is = 0; is <
ns; ++is) {
2287 for (
Index ib = 0; ib < nb; ++ib) {
2289 for (
Index ip = 0; ip < np; ++ip) {
2291 for (
Index ir = 0; ir < nr; ++ir) {
2293 for (
Index ic = 0; ic < nc; ++ic) {
2304 itw.
get(iv, is, ib, ip, ir, ic, iti) =
2305 (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
2346 assert(
is_size(itw, nr, nc, 4));
2353 itw(0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2356 for (
Index ir = 0; ir < nr; ++ir) {
2360 for (
Index ic = 0; ic < nc; ++ic) {
2370 for (
Index r = 0; r < 2; ++r)
2371 for (
Index c = 0; c < 2; ++c) {
2374 tia += a.
get(tr.
idx + r, tc.
idx + c) * itw.
get(ir, ic, iti);
2413 assert(
is_size(ia, np, nr, nc));
2414 assert(
is_size(itw, np, nr, nc, 8));
2420 itw(0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2423 for (
Index ip = 0; ip < np; ++ip) {
2425 for (
Index ir = 0; ir < nr; ++ir) {
2427 for (
Index ic = 0; ic < nc; ++ic) {
2433 Numeric& tia = ia(ip, ir, ic);
2437 for (
Index p = 0; p < 2; ++p)
2438 for (
Index r = 0; r < 2; ++r)
2439 for (
Index c = 0; c < 2; ++c) {
2444 itw.
get(ip, ir, ic, iti);
2487 assert(
is_size(ia, nb, np, nr, nc));
2488 assert(
is_size(itw, nb, np, nr, nc, 16));
2494 itw(0, 0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2497 for (
Index ib = 0; ib < nb; ++ib) {
2499 for (
Index ip = 0; ip < np; ++ip) {
2501 for (
Index ir = 0; ir < nr; ++ir) {
2503 for (
Index ic = 0; ic < nc; ++ic) {
2509 Numeric& tia = ia(ib, ip, ir, ic);
2513 for (
Index b = 0; b < 2; ++b)
2514 for (
Index p = 0; p < 2; ++p)
2515 for (
Index r = 0; r < 2; ++r)
2516 for (
Index c = 0; c < 2; ++c) {
2518 itw.
get(ib, ip, ir, ic, iti);
2565 assert(
is_size(ia,
ns, nb, np, nr, nc));
2566 assert(
is_size(itw,
ns, nb, np, nr, nc, 32));
2572 itw(0, 0, 0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2575 for (
Index is = 0; is <
ns; ++is) {
2577 for (
Index ib = 0; ib < nb; ++ib) {
2579 for (
Index ip = 0; ip < np; ++ip) {
2581 for (
Index ir = 0; ir < nr; ++ir) {
2583 for (
Index ic = 0; ic < nc; ++ic) {
2589 Numeric& tia = ia(is, ib, ip, ir, ic);
2593 for (
Index s = 0; s < 2; ++s)
2594 for (
Index b = 0; b < 2; ++b)
2595 for (
Index p = 0; p < 2; ++p)
2596 for (
Index r = 0; r < 2; ++r)
2597 for (
Index c = 0; c < 2; ++c) {
2603 itw.
get(is, ib, ip, ir, ic, iti);
2654 assert(
is_size(ia, nv,
ns, nb, np, nr, nc));
2655 assert(
is_size(itw, nv,
ns, nb, np, nr, nc, 64));
2661 itw(0, 0, 0, 0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2664 for (
Index iv = 0; iv < nv; ++iv) {
2666 for (
Index is = 0; is <
ns; ++is) {
2668 for (
Index ib = 0; ib < nb; ++ib) {
2670 for (
Index ip = 0; ip < np; ++ip) {
2672 for (
Index ir = 0; ir < nr; ++ir) {
2674 for (
Index ic = 0; ic < nc; ++ic) {
2680 Numeric& tia = ia(iv, is, ib, ip, ir, ic);
2684 for (
Index v = 0; v < 2; ++v)
2685 for (
Index s = 0; s < 2; ++s)
2686 for (
Index b = 0; b < 2; ++b)
2687 for (
Index p = 0; p < 2; ++p)
2688 for (
Index r = 0; r < 2; ++r)
2689 for (
Index c = 0; c < 2; ++c) {
2696 itw.
get(iv, is, ib, ip, ir, ic, iti);
2729 assert(N_x ==
y.nelem());
2741 Index interp_method = 1;
2743 if (interp_method == 1) {
2745 if ((gp.
fd[0] <= 0.5 && gp.
idx > 0) || gp.
idx == N_x - 2) {
2750 ya[0] =
y[gp.
idx - 1];
2752 ya[2] =
y[gp.
idx + 1];
2755 else if ((gp.
fd[0] > 0.5 && gp.
idx < N_x - 2) || gp.
idx == 0) {
2761 ya[1] =
y[gp.
idx + 1];
2762 ya[2] =
y[gp.
idx + 2];
2765 else if (gp.
idx == N_x - 1) {
2778 polint(y_int, dy_int,
xa, ya, 3, x_i);
2782 else if (interp_method == 2) {
2789 ya[1] =
y[gp.
idx + 1];
2790 ya[2] =
y[gp.
idx + 2];
2791 }
else if (gp.
idx == N_x - 1) {
2796 ya[0] =
y[gp.
idx - 2];
2797 ya[1] =
y[gp.
idx - 1];
2804 ya[0] =
y[gp.
idx - 1];
2806 ya[2] =
y[gp.
idx + 1];
2810 polint(y_int, dy_int,
xa, ya, 3, x_i);
2813 else if (interp_method == 3) {
2821 ya[0] =
y[gp.
idx + 1];
2822 ya[1] =
y[gp.
idx + 0];
2823 ya[2] =
y[gp.
idx + 1];
2824 ya[3] =
y[gp.
idx + 2];
2825 }
else if (gp.
idx == N_x - 1) {
2831 ya[0] =
y[gp.
idx - 1];
2832 ya[1] =
y[gp.
idx - 0];
2833 ya[2] =
y[gp.
idx - 1];
2834 ya[3] =
y[gp.
idx - 2];
2835 }
else if (gp.
idx == N_x - 2) {
2841 ya[0] =
y[gp.
idx - 2];
2842 ya[1] =
y[gp.
idx - 1];
2844 ya[3] =
y[gp.
idx + 1];
2851 ya[0] =
y[gp.
idx - 1];
2853 ya[2] =
y[gp.
idx + 1];
2854 ya[3] =
y[gp.
idx + 2];
2857 polint(y_int, dy_int,
xa, ya, 4, x_i);
2898 for (
Index i = 0; i < n; i++) {
2899 if ((dift =
abs(
x -
xa[i])) < dif) {
2910 for (
Index m = 1; m < n; m++) {
2911 for (
Index i = 0; i < n - m; i++) {
2914 w = c[i + 1] - d[i];
2922 y_int += (dy_int = (2 * (
ns + 1) < (n - m) ? c[
ns + 1] : d[
ns--]));