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);
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) {
1023 for (
Index c = 0; c < 2; ++c) {
1065 for (
Index p = 0; p < 2; ++p)
1067 for (
Index c = 0; c < 2; ++c) {
1111 for (
Index b = 0; b < 2; ++b)
1112 for (
Index p = 0; p < 2; ++p)
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)
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)
1223 for (
Index c = 0; c < 2; ++c) {
1298 itw.
get(
i, iti) = *c;
1351 itw.
get(
i, iti) = (*r) * (*c);
1401 itw.
get(
i, iti) = (*p) * (*r) * (*c);
1456 itw.
get(
i, iti) = (*b) * (*p) * (*r) * (*c);
1516 itw.
get(
i, iti) = (*s) * (*b) * (*p) * (*r) * (*c);
1581 itw.
get(
i, iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
1630 for (
Index c = 0; c < 2; ++c) {
1690 for (
Index c = 0; c < 2; ++c) {
1752 for (
Index p = 0; p < 2; ++p)
1754 for (
Index c = 0; c < 2; ++c) {
1820 for (
Index b = 0; b < 2; ++b)
1821 for (
Index p = 0; p < 2; ++p)
1823 for (
Index c = 0; c < 2; ++c) {
1894 for (
Index s = 0; s < 2; ++s)
1895 for (
Index b = 0; b < 2; ++b)
1896 for (
Index p = 0; p < 2; ++p)
1898 for (
Index c = 0; c < 2; ++c) {
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)
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) {
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)
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)
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)
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)
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) {
2746 xa[0] = x[gp.
idx - 1];
2748 xa[2] = x[gp.
idx + 1];
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) {
2757 xa[1] = x[gp.
idx + 1];
2758 xa[2] = x[gp.
idx + 2];
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) {
2785 xa[1] = x[gp.
idx + 1];
2786 xa[2] = x[gp.
idx + 2];
2789 ya[1] = y[gp.
idx + 1];
2790 ya[2] = y[gp.
idx + 2];
2791 }
else if (gp.
idx == N_x - 1) {
2792 xa[0] = x[gp.
idx - 2];
2793 xa[1] = x[gp.
idx - 1];
2796 ya[0] = y[gp.
idx - 2];
2797 ya[1] = y[gp.
idx - 1];
2800 xa[0] = x[gp.
idx - 1];
2802 xa[2] = x[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) {
2816 xa[0] = -x[gp.
idx + 1];
2817 xa[1] = x[gp.
idx + 0];
2818 xa[2] = x[gp.
idx + 1];
2819 xa[3] = x[gp.
idx + 2];
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) {
2826 xa[0] = x[gp.
idx - 1];
2827 xa[1] = x[gp.
idx - 0];
2828 xa[2] = 2 * x[gp.
idx] - x[gp.
idx - 1];
2829 xa[3] = 2 * x[gp.
idx] - x[gp.
idx - 2];
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) {
2836 xa[0] = x[gp.
idx - 2];
2837 xa[1] = x[gp.
idx - 1];
2839 xa[3] = x[gp.
idx + 1];
2841 ya[0] = y[gp.
idx - 2];
2842 ya[1] = y[gp.
idx - 1];
2844 ya[3] = y[gp.
idx + 1];
2846 xa[0] = x[gp.
idx - 1];
2848 xa[2] = x[gp.
idx + 1];
2849 xa[3] = x[gp.
idx + 2];
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);
2892 dif =
abs(x - xa[0]);
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--]));
INDEX Index
The type to use for all integer numbers and indices.
Numeric interp_poly(ConstVectorView x, ConstVectorView y, const Numeric &x_i, const GridPos &gp)
Polynomial interpolation.
Index nelem() const
Number of elements.
void arts_exit(int status)
This is the exit function of ARTS.
A constant view of a Tensor7.
void gridpos_upperend_check(GridPos &gp, const Index &ie)
gridpos_upperend_check
Numeric & get(Index n)
Get element implementation without assertions.
Numeric get(Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
A constant view of a Tensor6.
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
Numeric get(Index r, Index c) const
Get element implementation without assertions.
Numeric fractional_gp(const GridPos &gp)
fractional_gp
Numeric & get(Index v, Index s, Index b, Index p, Index r, Index c)
Get element implementation without assertions.
cmplx FADDEEVA() w(cmplx z, double relerr)
Header file for interpolation.cc.
Index gridpos2gridrange(const GridPos &gp, const bool &upwards)
gridpos2gridrange
Index nrows() const
Returns the number of rows.
bool is_gridpos_at_index_i(const GridPos &gp, const Index &i, const bool &strict)
is_gridpos_at_index_i
Index nelem() const
Returns the number of elements.
Structure to store a grid position.
A constant view of a Tensor4.
void polint(Numeric &y_int, Numeric &dy_int, ConstVectorView xa, ConstVectorView ya, const Index &n, const Numeric &x)
Polynomial interpolation.
This file contains the definition of Array.
void gridpos_check_fd(GridPos &gp)
gridpos_check_fd
Index ncols() const
Returns the number of columns.
ostream & operator<<(ostream &os, const GridPos &gp)
Output operator for GridPos.
bool is_same_within_epsilon(const Numeric &a, const Numeric &b, const Numeric &epsilon)
Check, if two numbers agree within a given epsilon.
Index ncols() const
Returns the number of columns.
Numeric sum() const
The sum of all elements of a Vector.
Numeric get(Index n) const
Get element implementation without assertions.
Numeric & get(Index r, Index c)
Get element implementation without assertions.
#define LOOPIT(x)
Macro for interpolation weight loops.
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
A constant view of a Tensor5.
NUMERIC Numeric
The type to use for all floating point numbers.
Numeric & get(Index p, Index r, Index c)
Get element implementation without assertions.
void gridpos_copy(GridPos &gp_new, const GridPos &gp_old)
gridpos_copy
Header file for logic.cc.
Index npages() const
Returns the number of pages.
This can be used to make arrays out of anything.
Numeric & get(Index b, Index p, Index r, Index c)
Get element implementation without assertions.
Numeric get(Index l, Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
A constant view of a Tensor3.
A constant view of a Vector.
Numeric & get(Index s, Index b, Index p, Index r, Index c)
Get element implementation without assertions.
A constant view of a Matrix.
Numeric & get(Index l, Index v, Index s, Index b, Index p, Index r, Index c)
Get element implementation without assertions.
Numeric get(Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
bool is_decreasing(ConstVectorView x)
Checks if a vector is sorted in reversed order and is strictly decreasing.
void gridpos_1to1(ArrayOfGridPos &gp, ConstVectorView grid)
gridpos_1to1
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
const Numeric FD_TOL
The maximum difference from 1 that we allow for a sum check.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
Index nrows() const
Returns the number of rows.
Numeric get(Index p, Index r, Index c) const
Get element implementation without assertions.
void gridpos_force_end_fd(GridPos &gp, const Index &n)
gridpos_force_end_fd
Numeric get(Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
void gp4length1grid(ArrayOfGridPos &gp)
Grid position matching a grid of length 1.