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);
466 gridpos( agp, old_grid, v, extpolfac );
485 gp_new.
fd[0] = gp_old.
fd[0];
486 gp_new.
fd[1] = gp_old.
fd[1];
533 { gp.
fd[0] = 0.0; gp.
fd[1] = 1.0; }
534 else if( gp.
fd[0] > 1.0 )
535 { gp.
fd[0] = 1.0; gp.
fd[1] = 0.0; }
538 { gp.
fd[1] = 0.0; gp.
fd[0] = 1.0; }
539 else if( gp.
fd[1] > 1.0 )
540 { gp.
fd[1] = 1.0; gp.
fd[0] = 0.0; }
571 assert( gp.
idx >= 0 );
581 assert( gp.
idx < n );
614 assert( gp.
fd[0] < 0.005 );
642 if( gp[i].idx == ie )
644 assert( gp[i].fd[0] < 0.005 );
672 if( gp.
idx == i && gp.
fd[0] == 0 )
674 else if( gp.
idx == i-1 && gp.
fd[1] == 0 )
703 const bool& upwards )
705 assert( gp.
fd[0] >= 0 );
706 assert( gp.
fd[1] >= 0 );
709 if( gp.
fd[0] > 0 && gp.
fd[1] > 0 )
715 else if( gp.
fd[0] == 0 )
825 itw[iti] = (*r) * (*c);
859 itw[iti] = (*p) * (*r) * (*c);
896 itw[iti] = (*b) * (*p) * (*r) * (*c);
936 itw[iti] = (*s) * (*b) * (*p) * (*r) * (*c);
979 itw[iti] = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
1017 for (
Index c=0; c<2; ++c )
1019 tia += a[tc.
idx+c] * itw[iti];
1061 for (
Index r=0; r<2; ++r )
1062 for (
Index c=0; c<2; ++c )
1065 tc.
idx+c) * itw[iti];
1109 for (
Index p=0; p<2; ++p )
1110 for (
Index r=0; r<2; ++r )
1111 for (
Index c=0; c<2; ++c )
1115 tc.
idx+c) * itw[iti];
1161 for (
Index b=0; b<2; ++b )
1162 for (
Index p=0; p<2; ++p )
1163 for (
Index r=0; r<2; ++r )
1164 for (
Index c=0; c<2; ++c )
1169 tc.
idx+c) * itw[iti];
1217 for (
Index s=0; s<2; ++s )
1218 for (
Index b=0; b<2; ++b )
1219 for (
Index p=0; p<2; ++p )
1220 for (
Index r=0; r<2; ++r )
1221 for (
Index c=0; c<2; ++c )
1227 tc.
idx+c) * itw[iti];
1277 for (
Index v=0; v<2; ++v )
1278 for (
Index s=0; s<2; ++s )
1279 for (
Index b=0; b<2; ++b )
1280 for (
Index p=0; p<2; ++p )
1281 for (
Index r=0; r<2; ++r )
1282 for (
Index c=0; c<2; ++c )
1289 tc.
idx+c) * itw[iti];
1325 for (
Index i=0; i<n; ++i )
1400 for (
Index i=0; i<n; ++i )
1418 itw(i,iti) = (*r) * (*c);
1459 for (
Index i=0; i<n; ++i )
1471 itw(i,iti) = (*p) * (*r) * (*c);
1515 for (
Index i=0; i<n; ++i )
1529 itw(i,iti) = (*b) * (*p) * (*r) * (*c);
1576 for (
Index i=0; i<n; ++i )
1592 itw(i,iti) = (*s) * (*b) * (*p) * (*r) * (*c);
1642 for (
Index i=0; i<n; ++i )
1660 itw(i,iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
1701 for (
Index i=0; i<n; ++i )
1712 for (
Index c=0; c<2; ++c )
1714 tia += a[tc.
idx+c] * itw(i,iti);
1762 for (
Index i=0; i<n; ++i )
1774 for (
Index r=0; r<2; ++r )
1775 for (
Index c=0; c<2; ++c )
1778 tc.
idx+c) * itw(i,iti);
1829 for (
Index i=0; i<n; ++i )
1842 for (
Index p=0; p<2; ++p )
1843 for (
Index r=0; r<2; ++r )
1844 for (
Index c=0; c<2; ++c )
1848 tc.
idx+c) * itw(i,iti);
1902 for (
Index i=0; i<n; ++i )
1916 for (
Index b=0; b<2; ++b )
1917 for (
Index p=0; p<2; ++p )
1918 for (
Index r=0; r<2; ++r )
1919 for (
Index c=0; c<2; ++c )
1924 tc.
idx+c) * itw(i,iti);
1981 for (
Index i=0; i<n; ++i )
1996 for (
Index s=0; s<2; ++s )
1997 for (
Index b=0; b<2; ++b )
1998 for (
Index p=0; p<2; ++p )
1999 for (
Index r=0; r<2; ++r )
2000 for (
Index c=0; c<2; ++c )
2006 tc.
idx+c) * itw(i,iti);
2066 for (
Index i=0; i<n; ++i )
2082 for (
Index v=0; v<2; ++v )
2083 for (
Index s=0; s<2; ++s )
2084 for (
Index b=0; b<2; ++b )
2085 for (
Index p=0; p<2; ++p )
2086 for (
Index r=0; r<2; ++r )
2087 for (
Index c=0; c<2; ++c )
2094 tc.
idx+c) * itw(i,iti);
2136 for (
Index ir=0; ir<nr; ++ir )
2141 for (
Index ic=0; ic<nc; ++ic )
2158 itw(ir,ic,iti) = (*r) * (*c);
2197 assert(
is_size(itw,np,nr,nc,8));
2200 for (
Index ip=0; ip<np; ++ip )
2203 for (
Index ir=0; ir<nr; ++ir )
2206 for (
Index ic=0; ic<nc; ++ic )
2260 assert(
is_size(itw,nb,np,nr,nc,16));
2263 for (
Index ib=0; ib<nb; ++ib )
2266 for (
Index ip=0; ip<np; ++ip )
2269 for (
Index ir=0; ir<nr; ++ir )
2272 for (
Index ic=0; ic<nc; ++ic )
2283 itw(ib,ip,ir,ic,iti) =
2284 (*b) * (*p) * (*r) * (*c);
2334 for (
Index is=0; is<
ns; ++is )
2337 for (
Index ib=0; ib<nb; ++ib )
2340 for (
Index ip=0; ip<np; ++ip )
2343 for (
Index ir=0; ir<nr; ++ir )
2346 for (
Index ic=0; ic<nc; ++ic )
2358 itw(is,ib,ip,ir,ic,iti) =
2359 (*s) * (*b) * (*p) * (*r) * (*c);
2410 assert(
is_size(itw,nv,
ns,nb,np,nr,nc,64));
2413 for (
Index iv=0; iv<nv; ++iv )
2416 for (
Index is=0; is<
ns; ++is )
2419 for (
Index ib=0; ib<nb; ++ib )
2422 for (
Index ip=0; ip<np; ++ip )
2425 for (
Index ir=0; ir<nr; ++ir )
2428 for (
Index ic=0; ic<nc; ++ic )
2441 itw(iv,is,ib,ip,ir,ic,iti) =
2442 (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
2495 for (
Index ir=0; ir<nr; ++ir )
2500 for (
Index ic=0; ic<nc; ++ic )
2511 for (
Index r=0; r<2; ++r )
2512 for (
Index c=0; c<2; ++c )
2515 tc.
idx+c) * itw(ir,ic,iti);
2569 for (
Index ip=0; ip<np; ++ip )
2572 for (
Index ir=0; ir<nr; ++ir )
2575 for (
Index ic=0; ic<nc; ++ic )
2586 for (
Index p=0; p<2; ++p )
2587 for (
Index r=0; r<2; ++r )
2588 for (
Index c=0; c<2; ++c )
2592 tc.
idx+c) * itw(ip,ir,ic,
2651 for (
Index ib=0; ib<nb; ++ib )
2654 for (
Index ip=0; ip<np; ++ip )
2657 for (
Index ir=0; ir<nr; ++ir )
2660 for (
Index ic=0; ic<nc; ++ic )
2667 Numeric& tia = ia(ib,ip,ir,ic);
2671 for (
Index b=0; b<2; ++b )
2672 for (
Index p=0; p<2; ++p )
2673 for (
Index r=0; r<2; ++r )
2674 for (
Index c=0; c<2; ++c )
2679 tc.
idx+c) * itw(ib,ip,ir,ic,
2742 for (
Index is=0; is<
ns; ++is )
2745 for (
Index ib=0; ib<nb; ++ib )
2748 for (
Index ip=0; ip<np; ++ip )
2751 for (
Index ir=0; ir<nr; ++ir )
2754 for (
Index ic=0; ic<nc; ++ic )
2761 Numeric& tia = ia(is,ib,ip,ir,ic);
2765 for (
Index s=0; s<2; ++s )
2766 for (
Index b=0; b<2; ++b )
2767 for (
Index p=0; p<2; ++p )
2768 for (
Index r=0; r<2; ++r )
2769 for (
Index c=0; c<2; ++c )
2775 tc.
idx+c) * itw(is,ib,ip,ir,ic,
2829 nv,
ns,nb,np,nr,nc));
2842 for (
Index iv=0; iv<nv; ++iv )
2845 for (
Index is=0; is<
ns; ++is )
2848 for (
Index ib=0; ib<nb; ++ib )
2851 for (
Index ip=0; ip<np; ++ip )
2854 for (
Index ir=0; ir<nr; ++ir )
2857 for (
Index ic=0; ic<nc; ++ic )
2864 Numeric& tia = ia(iv,is,ib,ip,ir,ic);
2868 for (
Index v=0; v<2; ++v )
2869 for (
Index s=0; s<2; ++s )
2870 for (
Index b=0; b<2; ++b )
2871 for (
Index p=0; p<2; ++p )
2872 for (
Index r=0; r<2; ++r )
2873 for (
Index c=0; c<2; ++c )
2880 tc.
idx+c) * itw(iv,is,ib,ip,ir,ic,
2916 assert(N_x == y.
nelem());
2928 Index interp_method = 1;
2930 if (interp_method == 1)
2934 if((gp.
fd[0] <= 0.5 && gp.
idx > 0) || gp.
idx == N_x-2 )
2936 xa[0] = x[gp.
idx - 1];
2938 xa[2] = x[gp.
idx + 1];
2940 ya[0] = y[gp.
idx - 1];
2942 ya[2] = y[gp.
idx + 1];
2945 else if((gp.
fd[0] > 0.5 && gp.
idx < N_x-2) || gp.
idx == 0 )
2948 xa[1] = x[gp.
idx + 1];
2949 xa[2] = x[gp.
idx + 2];
2952 ya[1] = y[gp.
idx + 1];
2953 ya[2] = y[gp.
idx + 2];
2956 else if(gp.
idx == N_x-1)
2972 polint(y_int, dy_int, xa, ya, 3, x_i);
2976 else if (interp_method == 2)
2981 xa[1] = x[gp.
idx + 1];
2982 xa[2] = x[gp.
idx + 2];
2985 ya[1] = y[gp.
idx + 1];
2986 ya[2] = y[gp.
idx + 2];
2988 else if(gp.
idx == N_x-1)
2990 xa[0] = x[gp.
idx - 2];
2991 xa[1] = x[gp.
idx - 1];
2994 ya[0] = y[gp.
idx - 2];
2995 ya[1] = y[gp.
idx - 1];
3000 xa[0] = x[gp.
idx - 1];
3002 xa[2] = x[gp.
idx + 1];
3004 ya[0] = y[gp.
idx - 1];
3006 ya[2] = y[gp.
idx + 1];
3010 polint(y_int, dy_int, xa, ya, 3, x_i);
3013 else if (interp_method == 3)
3018 xa[0] = - x[gp.
idx + 1];
3019 xa[1] = x[gp.
idx + 0];
3020 xa[2] = x[gp.
idx + 1];
3021 xa[3] = x[gp.
idx + 2];
3023 ya[0] = y[gp.
idx + 1];
3024 ya[1] = y[gp.
idx + 0];
3025 ya[2] = y[gp.
idx + 1];
3026 ya[3] = y[gp.
idx + 2];
3028 else if(gp.
idx == N_x-1)
3030 xa[0] = x[gp.
idx - 1];
3031 xa[1] = x[gp.
idx - 0];
3032 xa[2] = 2*x[gp.
idx] - x[gp.
idx-1];
3033 xa[3] = 2*x[gp.
idx] - x[gp.
idx-2];
3035 ya[0] = y[gp.
idx - 1];
3036 ya[1] = y[gp.
idx - 0];
3037 ya[2] = y[gp.
idx - 1];
3038 ya[3] = y[gp.
idx - 2];
3040 else if(gp.
idx == N_x-2)
3042 xa[0] = x[gp.
idx - 2];
3043 xa[1] = x[gp.
idx - 1];
3045 xa[3] = x[gp.
idx + 1];
3047 ya[0] = y[gp.
idx - 2];
3048 ya[1] = y[gp.
idx - 1];
3050 ya[3] = y[gp.
idx + 1];
3054 xa[0] = x[gp.
idx - 1];
3056 xa[2] = x[gp.
idx + 1];
3057 xa[3] = x[gp.
idx + 2];
3059 ya[0] = y[gp.
idx - 1];
3061 ya[2] = y[gp.
idx + 1];
3062 ya[3] = y[gp.
idx + 2];
3065 polint(y_int, dy_int, xa, ya, 4, x_i);
3103 Numeric den, dif, dift, ho, hp, w;
3111 for(
Index i=0; i<n; i++)
3113 if( (dift =
abs(x-xa[i])) < dif)
3125 for(
Index m=1; m<n; m++)
3127 for(
Index i=0; i < n-m; i++)
3139 y_int += (dy_int = (2*(
ns+1) < (n-m) ? c[
ns+1] : d[
ns--] ));