91 #define LOOPIT(x) for ( const Numeric* x=&t##x.fd[1]; x>=&t##x.fd[0]; --x ) 107 os << gp.
idx <<
" " << gp.
fd[0] <<
" " << gp.
fd[1] <<
"\n";
191 bool ascending = ( old_grid[0] <= old_grid[1] );
205 const Numeric og_min = old_grid[0] -
206 extpolfac * ( old_grid[1] - old_grid[0] );
207 const Numeric og_max = old_grid[n_old-1] +
208 extpolfac * ( old_grid[n_old-1] - old_grid[n_old-2] );
221 Numeric frac = (new_grid[0]-og_min)/(og_max-og_min);
235 assert( 0<= current_position );
236 assert( current_position <= n_old-2 );
240 Numeric lower = old_grid[current_position];
241 Numeric upper = old_grid[current_position+1];
244 for (
Index i_new=0; i_new<n_new; ++i_new )
249 const Numeric tng = new_grid[i_new];
253 assert( og_min <= tng );
254 assert( tng <= og_max );
264 if ( tng < lower && current_position > 0 )
269 lower = old_grid[current_position];
271 while ( tng < lower && current_position > 0 );
273 upper = old_grid[current_position+1];
275 tgp.
idx = current_position;
276 tgp.
fd[0] = (tng-lower)/(upper-lower);
277 tgp.
fd[1] = 1.0 - tgp.
fd[0];
284 if ( tng >= upper && current_position < n_old-2 )
289 upper = old_grid[current_position+1];
291 while ( tng >= upper && current_position < n_old-2 );
293 lower = old_grid[current_position];
295 tgp.
idx = current_position;
296 tgp.
fd[0] = (tng-lower)/(upper-lower);
297 tgp.
fd[1] = 1.0 - tgp.
fd[0];
309 tgp.
idx = current_position;
310 tgp.
fd[0] = (tng-lower)/(upper-lower);
311 tgp.
fd[1] = 1.0 - tgp.
fd[0];
318 assert(old_grid[tgp.
idx]<=tng || tgp.
idx==0);
334 const Numeric og_max = old_grid[0] -
335 extpolfac * ( old_grid[1] - old_grid[0] );
336 const Numeric og_min = old_grid[n_old-1] +
337 extpolfac * ( old_grid[n_old-1] - old_grid[n_old-2] );
341 Numeric frac = 1 - (new_grid[0]-og_min)/(og_max-og_min);
354 assert( 0<= current_position );
355 assert( current_position <= n_old-2 );
359 Numeric lower = old_grid[current_position];
360 Numeric upper = old_grid[current_position+1];
362 for (
Index i_new=0; i_new<n_new; ++i_new )
365 const Numeric tng = new_grid[i_new];
369 assert( og_min <= tng );
370 assert( tng <= og_max );
379 if ( tng > lower && current_position > 0 )
384 lower = old_grid[current_position];
386 while ( tng > lower && current_position > 0 );
388 upper = old_grid[current_position+1];
390 tgp.
idx = current_position;
391 tgp.
fd[0] = (tng-lower)/(upper-lower);
392 tgp.
fd[1] = 1.0 - tgp.
fd[0];
398 if ( tng <= upper && current_position < n_old-2 )
403 upper = old_grid[current_position+1];
405 while ( tng <= upper && current_position < n_old-2 );
407 lower = old_grid[current_position];
409 tgp.
idx = current_position;
410 tgp.
fd[0] = (tng-lower)/(upper-lower);
411 tgp.
fd[1] = 1.0 - tgp.
fd[0];
424 tgp.
idx = current_position;
425 tgp.
fd[0] = (tng-lower)/(upper-lower);
426 tgp.
fd[1] = 1.0 - tgp.
fd[0];
431 assert(old_grid[tgp.
idx]>=tng || tgp.
idx==0);
467 gridpos( agp, old_grid, v, extpolfac );
495 for(
Index i=0; i<n-1; i++ )
520 gp_new.
fd[0] = gp_old.
fd[0];
521 gp_new.
fd[1] = gp_old.
fd[1];
568 { gp.
fd[0] = 0.0; gp.
fd[1] = 1.0; }
569 else if( gp.
fd[0] > 1.0 )
570 { gp.
fd[0] = 1.0; gp.
fd[1] = 0.0; }
573 { gp.
fd[1] = 0.0; gp.
fd[0] = 1.0; }
574 else if( gp.
fd[1] > 1.0 )
575 { gp.
fd[1] = 1.0; gp.
fd[0] = 0.0; }
606 assert( gp.
idx >= 0 );
616 assert( gp.
idx < n );
649 assert( gp.
fd[0] < 0.005 );
677 if( gp[i].idx == ie )
679 assert( gp[i].fd[0] < 0.005 );
711 if( gp.
idx == i && gp.
fd[0] == 0 )
713 else if( gp.
idx == i-1 && gp.
fd[1] == 0 )
749 const bool& upwards )
751 assert( gp.
fd[0] >= 0 );
752 assert( gp.
fd[1] >= 0 );
755 if( gp.
fd[0] > 0 && gp.
fd[1] > 0 )
761 else if( gp.
fd[0] == 0 )
871 itw.
get(iti) = (*r) * (*c);
905 itw.
get(iti) = (*p) * (*r) * (*c);
942 itw.
get(iti) = (*b) * (*p) * (*r) * (*c);
982 itw.
get(iti) = (*s) * (*b) * (*p) * (*r) * (*c);
1025 itw.
get(iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
1063 for (
Index c=0; c<2; ++c )
1107 for (
Index r=0; r<2; ++r )
1108 for (
Index c=0; c<2; ++c )
1111 tc.
idx+c) * itw.
get(iti);
1155 for (
Index p=0; p<2; ++p )
1156 for (
Index r=0; r<2; ++r )
1157 for (
Index c=0; c<2; ++c )
1161 tc.
idx+c) * itw.
get(iti);
1207 for (
Index b=0; b<2; ++b )
1208 for (
Index p=0; p<2; ++p )
1209 for (
Index r=0; r<2; ++r )
1210 for (
Index c=0; c<2; ++c )
1215 tc.
idx+c) * itw.
get(iti);
1263 for (
Index s=0; s<2; ++s )
1264 for (
Index b=0; b<2; ++b )
1265 for (
Index p=0; p<2; ++p )
1266 for (
Index r=0; r<2; ++r )
1267 for (
Index c=0; c<2; ++c )
1273 tc.
idx+c) * itw.
get(iti);
1323 for (
Index v=0; v<2; ++v )
1324 for (
Index s=0; s<2; ++s )
1325 for (
Index b=0; b<2; ++b )
1326 for (
Index p=0; p<2; ++p )
1327 for (
Index r=0; r<2; ++r )
1328 for (
Index c=0; c<2; ++c )
1335 tc.
idx+c) * itw.
get(iti);
1371 for (
Index i=0; i<n; ++i )
1408 itw.
get(i,iti) = *c;
1446 for (
Index i=0; i<n; ++i )
1464 itw.
get(i,iti) = (*r) * (*c);
1505 for (
Index i=0; i<n; ++i )
1517 itw.
get(i,iti) = (*p) * (*r) * (*c);
1561 for (
Index i=0; i<n; ++i )
1575 itw.
get(i,iti) = (*b) * (*p) * (*r) * (*c);
1622 for (
Index i=0; i<n; ++i )
1638 itw.
get(i,iti) = (*s) * (*b) * (*p) * (*r) * (*c);
1688 for (
Index i=0; i<n; ++i )
1706 itw.
get(i,iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
1747 for (
Index i=0; i<n; ++i )
1758 for (
Index c=0; c<2; ++c )
1760 tia += a.
get(tc.
idx+c) * itw.
get(i,iti);
1808 for (
Index i=0; i<n; ++i )
1820 for (
Index r=0; r<2; ++r )
1821 for (
Index c=0; c<2; ++c )
1824 tc.
idx+c) * itw.
get(i,iti);
1875 for (
Index i=0; i<n; ++i )
1888 for (
Index p=0; p<2; ++p )
1889 for (
Index r=0; r<2; ++r )
1890 for (
Index c=0; c<2; ++c )
1894 tc.
idx+c) * itw.
get(i,iti);
1948 for (
Index i=0; i<n; ++i )
1962 for (
Index b=0; b<2; ++b )
1963 for (
Index p=0; p<2; ++p )
1964 for (
Index r=0; r<2; ++r )
1965 for (
Index c=0; c<2; ++c )
1970 tc.
idx+c) * itw.
get(i,iti);
2027 for (
Index i=0; i<n; ++i )
2042 for (
Index s=0; s<2; ++s )
2043 for (
Index b=0; b<2; ++b )
2044 for (
Index p=0; p<2; ++p )
2045 for (
Index r=0; r<2; ++r )
2046 for (
Index c=0; c<2; ++c )
2052 tc.
idx+c) * itw.
get(i,iti);
2112 for (
Index i=0; i<n; ++i )
2128 for (
Index v=0; v<2; ++v )
2129 for (
Index s=0; s<2; ++s )
2130 for (
Index b=0; b<2; ++b )
2131 for (
Index p=0; p<2; ++p )
2132 for (
Index r=0; r<2; ++r )
2133 for (
Index c=0; c<2; ++c )
2140 tc.
idx+c) * itw.
get(i,iti);
2182 for (
Index ir=0; ir<nr; ++ir )
2187 for (
Index ic=0; ic<nc; ++ic )
2204 itw.
get(ir,ic,iti) = (*r) * (*c);
2243 assert(
is_size(itw,np,nr,nc,8));
2246 for (
Index ip=0; ip<np; ++ip )
2249 for (
Index ir=0; ir<nr; ++ir )
2252 for (
Index ic=0; ic<nc; ++ic )
2262 itw.
get(ip,ir,ic,iti) =
2306 assert(
is_size(itw,nb,np,nr,nc,16));
2309 for (
Index ib=0; ib<nb; ++ib )
2312 for (
Index ip=0; ip<np; ++ip )
2315 for (
Index ir=0; ir<nr; ++ir )
2318 for (
Index ic=0; ic<nc; ++ic )
2329 itw.
get(ib,ip,ir,ic,iti) =
2330 (*b) * (*p) * (*r) * (*c);
2377 assert(
is_size(itw,ns,nb,np,nr,nc,32));
2380 for (
Index is=0; is<
ns; ++is )
2383 for (
Index ib=0; ib<nb; ++ib )
2386 for (
Index ip=0; ip<np; ++ip )
2389 for (
Index ir=0; ir<nr; ++ir )
2392 for (
Index ic=0; ic<nc; ++ic )
2404 itw.
get(is,ib,ip,ir,ic,iti) =
2405 (*s) * (*b) * (*p) * (*r) * (*c);
2456 assert(
is_size(itw,nv,ns,nb,np,nr,nc,64));
2459 for (
Index iv=0; iv<nv; ++iv )
2462 for (
Index is=0; is<
ns; ++is )
2465 for (
Index ib=0; ib<nb; ++ib )
2468 for (
Index ip=0; ip<np; ++ip )
2471 for (
Index ir=0; ir<nr; ++ir )
2474 for (
Index ic=0; ic<nc; ++ic )
2487 itw.
get(iv,is,ib,ip,ir,ic,iti) =
2488 (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
2541 for (
Index ir=0; ir<nr; ++ir )
2546 for (
Index ic=0; ic<nc; ++ic )
2557 for (
Index r=0; r<2; ++r )
2558 for (
Index c=0; c<2; ++c )
2561 tc.
idx+c) * itw.
get(ir,ic,iti);
2615 for (
Index ip=0; ip<np; ++ip )
2618 for (
Index ir=0; ir<nr; ++ir )
2621 for (
Index ic=0; ic<nc; ++ic )
2632 for (
Index p=0; p<2; ++p )
2633 for (
Index r=0; r<2; ++r )
2634 for (
Index c=0; c<2; ++c )
2638 tc.
idx+c) * itw.
get(ip,ir,ic,
2697 for (
Index ib=0; ib<nb; ++ib )
2700 for (
Index ip=0; ip<np; ++ip )
2703 for (
Index ir=0; ir<nr; ++ir )
2706 for (
Index ic=0; ic<nc; ++ic )
2713 Numeric& tia = ia(ib,ip,ir,ic);
2717 for (
Index b=0; b<2; ++b )
2718 for (
Index p=0; p<2; ++p )
2719 for (
Index r=0; r<2; ++r )
2720 for (
Index c=0; c<2; ++c )
2725 tc.
idx+c) * itw.
get(ib,ip,ir,ic,
2788 for (
Index is=0; is<
ns; ++is )
2791 for (
Index ib=0; ib<nb; ++ib )
2794 for (
Index ip=0; ip<np; ++ip )
2797 for (
Index ir=0; ir<nr; ++ir )
2800 for (
Index ic=0; ic<nc; ++ic )
2807 Numeric& tia = ia(is,ib,ip,ir,ic);
2811 for (
Index s=0; s<2; ++s )
2812 for (
Index b=0; b<2; ++b )
2813 for (
Index p=0; p<2; ++p )
2814 for (
Index r=0; r<2; ++r )
2815 for (
Index c=0; c<2; ++c )
2821 tc.
idx+c) * itw.
get(is,ib,ip,ir,ic,
2875 nv,ns,nb,np,nr,nc));
2888 for (
Index iv=0; iv<nv; ++iv )
2891 for (
Index is=0; is<
ns; ++is )
2894 for (
Index ib=0; ib<nb; ++ib )
2897 for (
Index ip=0; ip<np; ++ip )
2900 for (
Index ir=0; ir<nr; ++ir )
2903 for (
Index ic=0; ic<nc; ++ic )
2910 Numeric& tia = ia(iv,is,ib,ip,ir,ic);
2914 for (
Index v=0; v<2; ++v )
2915 for (
Index s=0; s<2; ++s )
2916 for (
Index b=0; b<2; ++b )
2917 for (
Index p=0; p<2; ++p )
2918 for (
Index r=0; r<2; ++r )
2919 for (
Index c=0; c<2; ++c )
2926 tc.
idx+c) * itw.
get(iv,is,ib,ip,ir,ic,
2962 assert(N_x == y.
nelem());
2974 Index interp_method = 1;
2976 if (interp_method == 1)
2980 if((gp.
fd[0] <= 0.5 && gp.
idx > 0) || gp.
idx == N_x-2 )
2982 xa[0] = x[gp.
idx - 1];
2984 xa[2] = x[gp.
idx + 1];
2986 ya[0] = y[gp.
idx - 1];
2988 ya[2] = y[gp.
idx + 1];
2991 else if((gp.
fd[0] > 0.5 && gp.
idx < N_x-2) || gp.
idx == 0 )
2994 xa[1] = x[gp.
idx + 1];
2995 xa[2] = x[gp.
idx + 2];
2998 ya[1] = y[gp.
idx + 1];
2999 ya[2] = y[gp.
idx + 2];
3002 else if(gp.
idx == N_x-1)
3018 polint(y_int, dy_int, xa, ya, 3, x_i);
3022 else if (interp_method == 2)
3027 xa[1] = x[gp.
idx + 1];
3028 xa[2] = x[gp.
idx + 2];
3031 ya[1] = y[gp.
idx + 1];
3032 ya[2] = y[gp.
idx + 2];
3034 else if(gp.
idx == N_x-1)
3036 xa[0] = x[gp.
idx - 2];
3037 xa[1] = x[gp.
idx - 1];
3040 ya[0] = y[gp.
idx - 2];
3041 ya[1] = y[gp.
idx - 1];
3046 xa[0] = x[gp.
idx - 1];
3048 xa[2] = x[gp.
idx + 1];
3050 ya[0] = y[gp.
idx - 1];
3052 ya[2] = y[gp.
idx + 1];
3056 polint(y_int, dy_int, xa, ya, 3, x_i);
3059 else if (interp_method == 3)
3064 xa[0] = - x[gp.
idx + 1];
3065 xa[1] = x[gp.
idx + 0];
3066 xa[2] = x[gp.
idx + 1];
3067 xa[3] = x[gp.
idx + 2];
3069 ya[0] = y[gp.
idx + 1];
3070 ya[1] = y[gp.
idx + 0];
3071 ya[2] = y[gp.
idx + 1];
3072 ya[3] = y[gp.
idx + 2];
3074 else if(gp.
idx == N_x-1)
3076 xa[0] = x[gp.
idx - 1];
3077 xa[1] = x[gp.
idx - 0];
3078 xa[2] = 2*x[gp.
idx] - x[gp.
idx-1];
3079 xa[3] = 2*x[gp.
idx] - x[gp.
idx-2];
3081 ya[0] = y[gp.
idx - 1];
3082 ya[1] = y[gp.
idx - 0];
3083 ya[2] = y[gp.
idx - 1];
3084 ya[3] = y[gp.
idx - 2];
3086 else if(gp.
idx == N_x-2)
3088 xa[0] = x[gp.
idx - 2];
3089 xa[1] = x[gp.
idx - 1];
3091 xa[3] = x[gp.
idx + 1];
3093 ya[0] = y[gp.
idx - 2];
3094 ya[1] = y[gp.
idx - 1];
3096 ya[3] = y[gp.
idx + 1];
3100 xa[0] = x[gp.
idx - 1];
3102 xa[2] = x[gp.
idx + 1];
3103 xa[3] = x[gp.
idx + 2];
3105 ya[0] = y[gp.
idx - 1];
3107 ya[2] = y[gp.
idx + 1];
3108 ya[3] = y[gp.
idx + 2];
3111 polint(y_int, dy_int, xa, ya, 4, x_i);
3157 for(
Index i=0; i<n; i++)
3159 if( (dift =
abs(x-xa[i])) < dif)
3171 for(
Index m=1; m<n; m++)
3173 for(
Index i=0; i < n-m; i++)
3185 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 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
cmplx FADDEEVA() w(cmplx z, double relerr)
Numeric get(Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
Numeric get(Index r, Index c) const
Get element implementation without assertions.
Header file for interpolation.cc.
Index gridpos2gridrange(const GridPos &gp, const bool &upwards)
gridpos2gridrange
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.
Numeric get(Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
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
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.
Numeric sum() const
The sum of all elements of a Vector.
Numeric get(Index n) const
Get element implementation without assertions.
Numeric get(Index p, Index r, Index c) const
Get element implementation without assertions.
const Numeric sum_check_epsilon
The maximum difference from 1 that we allow for a sum check.
#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 l, Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
void gridpos_copy(GridPos &gp_new, const GridPos &gp_old)
gridpos_copy
Numeric get(Index n) const
Get element implementation without assertions.
Header file for logic.cc.
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.
A constant view of a Matrix.
Numeric get(Index b, Index p, Index r, Index c) const
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
Allowed tolerance for fractional distance values.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
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.