126 const Index m = order + 1;
142 gridpos(gp_trad, old_grid, new_grid, extpolfac);
143 }
else if (n_old == 1) {
150 gp_trad[
i].fd[0] = 0;
151 gp_trad[
i].fd[1] = 1;
158 for (
Index s = 0; s < n_new; ++s) {
166 k =
IMIN(
IMAX(gp_trad[s].idx - (m - 1) / 2, 0), n_old - m);
170 if (gp_trad[s].fd[0] <= 0.5)
173 k = gp_trad[s].idx + 1;
194 gp[s].idx[
i] = k +
i;
200 for (
Index j = 0; j < m; ++j)
201 if (j != i) num *= new_grid[s] - old_grid[k + j];
205 for (
Index j = 0; j < m; ++j)
206 if (j != i) denom *= old_grid[k + i] - old_grid[k + j];
208 gp[s].w[i] = num / denom;
247 gridpos_poly(agp, old_grid, new_grid, order, extpolfac);
286 if (old_grid[0] >= new_grid[new_grid.
nelem() - 1]) {
287 Vector shifted_old_grid = old_grid;
288 shifted_old_grid -= 360;
290 error_msg, shifted_old_grid, new_grid, order, extpolfac);
292 gridpos_poly(gp, shifted_old_grid, new_grid, order, extpolfac);
293 }
else if (old_grid[old_grid.
nelem() - 1] <= new_grid[0]) {
294 Vector shifted_old_grid = old_grid;
295 shifted_old_grid += 360;
297 error_msg, shifted_old_grid, new_grid, order, extpolfac);
298 gridpos_poly(gp, shifted_old_grid, new_grid, order, extpolfac);
338 Vector large_grid(new_n * 3);
340 large_grid[r_left] = old_grid_n1;
341 large_grid[r_left] -= 360.;
343 large_grid[
Range(new_n, new_n)] = old_grid_n1;
345 large_grid[r_right] = old_grid_n1;
346 large_grid[r_right] += 360.;
348 gridpos_poly(gp, large_grid, new_grid, order, extpolfac);
350 for (ArrayOfGridPosPoly::iterator itgp = gp.begin(); itgp != gp.end(); itgp++)
351 for (ArrayOfIndex::iterator iti = itgp->idx.begin(); iti != itgp->idx.end();
389 error_msg, agp, old_grid, new_grid, order, extpolfac);
442 #define LOOPW(x) for (ConstIterator1D x = t##x##begin; x != t##x##end; ++x) 446 const ConstIterator1D t##x##begin = t##x.w.begin(); \ 447 const ConstIterator1D t##x##end = t##x.w.end(); 456 for (ArrayOfIndex::const_iterator x = t##x##begin; x != t##x##end; ++x) 459 #define CACHEIDX(x) \ 460 const ArrayOfIndex::const_iterator t##x##begin = t##x.idx.begin(); \ 461 const ArrayOfIndex::const_iterator t##x##end = t##x.idx.end(); 473 os <<
"idx: " << gp.
idx <<
"\n";
474 os <<
"w: " << gp.
w <<
"\n";
544 itw.
get(iti) = (*r) * (*c);
579 itw.
get(iti) = (*p) * (*r) * (*c);
619 itw.
get(iti) = (*b) * (*p) * (*r) * (*c);
664 itw.
get(iti) = (*s) * (*b) * (*p) * (*r) * (*c);
713 itw.
get(iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
747 tia += a.
get(*c) * itw.
get(iti);
789 tia += a.
get(*
r, *c) * itw.
get(iti);
835 tia += a.
get(*p, *
r, *c) * itw.
get(iti);
886 tia += a.
get(*b, *p, *
r, *c) * itw.
get(iti);
942 tia += a.
get(*s, *b, *p, *
r, *c) * itw.
get(iti);
1002 tia += a.
get(*v, *s, *b, *p, *
r, *c) * itw.
get(iti);
1031 assert(
is_size(itw, n, cgp[0].
w.nelem()));
1070 itw.
get(
i, iti) = *c;
1103 assert(
is_size(itw, n, rgp[0].
w.nelem() * cgp[0].w.
nelem()));
1124 itw.
get(
i, iti) = (*r) * (*c);
1177 itw.
get(
i, iti) = (*p) * (*r) * (*c);
1218 bgp[0].
w.nelem() * pgp[0].w.
nelem() * rgp[0].w.
nelem() *
1238 itw.
get(
i, iti) = (*b) * (*p) * (*r) * (*c);
1282 sgp[0].
w.nelem() * bgp[0].w.
nelem() * pgp[0].w.
nelem() *
1305 itw.
get(
i, iti) = (*s) * (*b) * (*p) * (*r) * (*c);
1352 vgp[0].
w.nelem() * sgp[0].w.
nelem() * bgp[0].w.
nelem() *
1378 itw.
get(
i, iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
1407 assert(
is_size(itw, n, cgp[0].
w.nelem()));
1428 tia += a.
get(*c) * itw.
get(
i, iti);
1464 assert(
is_size(itw, n, rgp[0].
w.nelem() * cgp[0].w.
nelem()));
1488 tia += a.
get(*
r, *c) * itw.
get(
i, iti);
1555 tia += a.
get(*p, *
r, *c) * itw.
get(
i, iti);
1599 bgp[0].
w.nelem() * pgp[0].w.
nelem() * rgp[0].w.
nelem() *
1630 tia += a.
get(*b, *p, *
r, *c) * itw.
get(
i, iti);
1677 sgp[0].
w.nelem() * bgp[0].w.
nelem() * pgp[0].w.
nelem() *
1711 tia += a.
get(*s, *b, *p, *
r, *c) * itw.
get(
i, iti);
1761 vgp[0].
w.nelem() * sgp[0].w.
nelem() * bgp[0].w.
nelem() *
1798 tia += a.
get(*v, *s, *b, *p, *
r, *c) * itw.
get(
i, iti);
1835 assert(
is_size(itw, nr, nc, rgp[0].
w.nelem() * cgp[0].w.
nelem()));
1838 for (
Index ir = 0; ir < nr; ++ir) {
1843 for (
Index ic = 0; ic < nc; ++ic) {
1859 itw.
get(ir, ic, iti) = (*r) * (*c);
1898 itw, np, nr, nc, pgp[0].
w.nelem() * rgp[0].w.
nelem() * cgp[0].w.
nelem()));
1901 for (
Index ip = 0; ip < np; ++ip) {
1904 for (
Index ir = 0; ir < nr; ++ir) {
1907 for (
Index ic = 0; ic < nc; ++ic) {
1916 itw.
get(ip, ir, ic, iti) = (*p) * (*r) * (*c);
1963 bgp[0].
w.nelem() * pgp[0].w.
nelem() * rgp[0].w.
nelem() *
1967 for (
Index ib = 0; ib < nb; ++ib) {
1970 for (
Index ip = 0; ip < np; ++ip) {
1973 for (
Index ir = 0; ir < nr; ++ir) {
1976 for (
Index ic = 0; ic < nc; ++ic) {
1986 itw.
get(ib, ip, ir, ic, iti) = (*b) * (*p) * (*r) * (*c);
2038 sgp[0].
w.nelem() * bgp[0].w.
nelem() * pgp[0].w.
nelem() *
2042 for (
Index is = 0; is <
ns; ++is) {
2045 for (
Index ib = 0; ib < nb; ++ib) {
2048 for (
Index ip = 0; ip < np; ++ip) {
2051 for (
Index ir = 0; ir < nr; ++ir) {
2054 for (
Index ic = 0; ic < nc; ++ic) {
2065 itw.
get(is, ib, ip, ir, ic, iti) =
2066 (*s) * (*b) * (*p) * (*r) * (*c);
2123 vgp[0].
w.nelem() * sgp[0].w.
nelem() * bgp[0].w.
nelem() *
2127 for (
Index iv = 0; iv < nv; ++iv) {
2130 for (
Index is = 0; is <
ns; ++is) {
2133 for (
Index ib = 0; ib < nb; ++ib) {
2136 for (
Index ip = 0; ip < np; ++ip) {
2139 for (
Index ir = 0; ir < nr; ++ir) {
2142 for (
Index ic = 0; ic < nc; ++ic) {
2154 itw.
get(iv, is, ib, ip, ir, ic, iti) =
2155 (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
2196 assert(
is_size(itw, nr, nc, rgp[0].
w.nelem() * cgp[0].w.
nelem()));
2202 itw(0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2205 for (
Index ir = 0; ir < nr; ++ir) {
2210 for (
Index ic = 0; ic < nc; ++ic) {
2223 tia += a.
get(*
r, *c) * itw.
get(ir, ic, iti);
2262 assert(
is_size(ia, np, nr, nc));
2264 itw, np, nr, nc, pgp[0].
w.nelem() * rgp[0].w.
nelem() * cgp[0].w.
nelem()));
2270 itw(0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2273 for (
Index ip = 0; ip < np; ++ip) {
2276 for (
Index ir = 0; ir < nr; ++ir) {
2279 for (
Index ic = 0; ic < nc; ++ic) {
2286 Numeric& tia = ia(ip, ir, ic);
2293 tia += a.
get(*p, *
r, *c) * itw.
get(ip, ir, ic, iti);
2336 assert(
is_size(ia, nb, np, nr, nc));
2342 bgp[0].
w.nelem() * pgp[0].w.
nelem() * rgp[0].w.
nelem() *
2349 itw(0, 0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2352 for (
Index ib = 0; ib < nb; ++ib) {
2355 for (
Index ip = 0; ip < np; ++ip) {
2358 for (
Index ir = 0; ir < nr; ++ir) {
2361 for (
Index ic = 0; ic < nc; ++ic) {
2368 Numeric& tia = ia(ib, ip, ir, ic);
2376 tia += a.
get(*b, *p, *
r, *c) * itw.
get(ib, ip, ir, ic, iti);
2423 assert(
is_size(ia, ns, nb, np, nr, nc));
2430 sgp[0].
w.nelem() * bgp[0].w.
nelem() * pgp[0].w.
nelem() *
2437 itw(0, 0, 0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2440 for (
Index is = 0; is <
ns; ++is) {
2443 for (
Index ib = 0; ib < nb; ++ib) {
2446 for (
Index ip = 0; ip < np; ++ip) {
2449 for (
Index ir = 0; ir < nr; ++ir) {
2452 for (
Index ic = 0; ic < nc; ++ic) {
2459 Numeric& tia = ia(is, ib, ip, ir, ic);
2469 a.
get(*s, *b, *p, *
r, *c) * itw.
get(is, ib, ip, ir, ic, iti);
2520 assert(
is_size(ia, nv, ns, nb, np, nr, nc));
2528 vgp[0].
w.nelem() * sgp[0].w.
nelem() * bgp[0].w.
nelem() *
2535 itw(0, 0, 0, 0, 0, 0,
Range(
joker)).sum(), 1, sum_check_epsilon));
2538 for (
Index iv = 0; iv < nv; ++iv) {
2541 for (
Index is = 0; is <
ns; ++is) {
2544 for (
Index ib = 0; ib < nb; ++ib) {
2547 for (
Index ip = 0; ip < np; ++ip) {
2550 for (
Index ir = 0; ir < nr; ++ir) {
2553 for (
Index ic = 0; ic < nc; ++ic) {
2560 Numeric& tia = ia(iv, is, ib, ip, ir, ic);
2570 tia += a.
get(*v, *s, *b, *p, *
r, *c) *
2571 itw.
get(iv, is, ib, ip, ir, ic, iti);
INDEX Index
The type to use for all integer numbers and indices.
bool is_lon_cyclic(ConstVectorView grid, const Numeric &epsilon)
Check if the given longitude grid is cyclic.
Index nelem() const
Number of elements.
A constant view of a Tensor7.
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.
A constant view of a Tensor6.
Index IMIN(Index a, Index b)
Return the minimum of two integer numbers.
Numeric get(Index r, Index c) const
Get element implementation without assertions.
ostream & operator<<(ostream &os, const GridPosPoly &gp)
Output operator for GridPosPoly.
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.
#define CACHEIDX(x)
Macro for caching begin and end iterators for interpolation index loops.
Index nelem() const
Returns the number of elements.
A constant view of a Tensor4.
void interpweights(VectorView itw, const GridPosPoly &tc)
Red 1D interpolation weights.
void gridpos_poly_longitudinal(const String &error_msg, ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
Set up grid positions for higher order interpolation on longitudes.
bool is_same_within_epsilon(const Numeric &a, const Numeric &b, const Numeric &epsilon)
Check, if two numbers agree within a given epsilon.
#define CACHEW(x)
Macro for caching begin and end iterators for interpolation weight loops.
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 LOOPW(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.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPosPoly &tc)
Red 1D Interpolate.
A constant view of a Tensor5.
NUMERIC Numeric
The type to use for all floating point numbers.
void gridpos_poly(ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
The maximum difference from 1 that we allow for a sum check.
Numeric & get(Index p, Index r, Index c)
Get element implementation without assertions.
void gridpos_poly_cyclic_longitudinal(ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
Set up grid positions for higher order interpolation.
Header file for logic.cc.
#define LOOPIDX(x)
Macro for interpolation index loops.
Header file for interpolation_poly.cc.
Numeric & get(Index b, Index p, Index r, Index c)
Get element implementation without assertions.
Index IMAX(Index a, Index b)
Return the maximum of two integer numbers.
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.
Structure to store a grid position for higher order interpolation.
Numeric get(Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
Header file for helper functions for OpenMP.
Numeric get(Index p, Index r, Index c) const
Get element implementation without assertions.
Numeric get(Index b, Index p, Index r, Index c) const
Get element implementation without assertions.