00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00039 #include <iostream>
00040 #include "interpolation_poly.h"
00041 #include "interpolation.h"
00042 #include "logic.h"
00043
00044
00045
00046 static Index imaxarg1, imaxarg2;
00047 #define IMAX(a,b) (imaxarg1=(a), imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
00048 (imaxarg1) : (imaxarg2))
00049
00050 static Index iminarg1, iminarg2;
00051 #define IMIN(a,b) (iminarg1=(a), iminarg2=(b),(iminarg1) < (iminarg2) ?\
00052 (iminarg1) : (iminarg2))
00053
00054
00055
00057
00068 const Numeric sum_check_epsilon = 1e-6;
00069
00071
00089 void gridpos_poly(ArrayOfGridPosPoly& gp,
00090 ConstVectorView old_grid,
00091 ConstVectorView new_grid,
00092 const Index order,
00093 const Numeric& extpolfac)
00094 {
00095
00096 Index m=order+1;
00097
00098 const Index n_old = old_grid.nelem();
00099 const Index n_new = new_grid.nelem();
00100
00101
00102
00103 assert(n_old>=m);
00104
00105
00106
00107 assert( is_size(gp,n_new) );
00108
00109
00110 ArrayOfGridPos gp_trad(n_new);
00111 gridpos( gp_trad, old_grid, new_grid, extpolfac );
00112
00113
00114
00115
00116
00117
00118 #pragma omp parallel
00119 #pragma omp for
00120 for (Index s=0; s<n_new; ++s)
00121 {
00122
00123
00124
00125
00126
00127
00128 Index k = IMIN(IMAX(gp_trad[s].idx-(m-1)/2, 0),
00129 n_old-m);
00130
00131
00132
00133
00134
00135 gp[s].idx.resize(m);
00136 gp[s].w.resize(m);
00137
00138
00139
00140
00141
00142
00143 for (Index i=0; i<m; ++i)
00144 {
00145 gp[s].idx[i] = k+i;
00146
00147
00148
00149
00150 Numeric num = 1;
00151 for (Index j=0; j<m; ++j)
00152 if (j!=i)
00153 num *= new_grid[s] - old_grid[k+j];
00154
00155
00156 Numeric denom = 1;
00157 for (Index j=0; j<m; ++j)
00158 if (j!=i)
00159 denom *= old_grid[k+i] - old_grid[k+j];
00160
00161 gp[s].w[i] = num / denom;
00162 }
00163
00164
00165
00166
00167
00168
00169 }
00170 }
00171
00172
00174
00196 void gridpos_poly( GridPosPoly& gp,
00197 ConstVectorView old_grid,
00198 const Numeric& new_grid,
00199 const Index order,
00200 const Numeric& extpolfac )
00201 {
00202 ArrayOfGridPosPoly agp(1);
00203 Vector v( 1, new_grid );
00204 gridpos_poly( agp, old_grid, v, order, extpolfac );
00205 gp = agp[0];
00206 }
00207
00208
00209
00210
00211
00212
00213
00214
00216
00230
00231
00232 #define LOOPW(x) for ( ConstIterator1D x=t##x.w.begin(); x!=t##x.w.end(); ++x )
00233
00235
00240 #define LOOPIDX(x) for (ArrayOfIndex::const_iterator x=t##x.idx.begin(); x!=t##x.idx.end(); ++x)
00241
00242
00244
00252 ostream& operator<<(ostream& os, const GridPosPoly& gp)
00253 {
00254 os << "idx: " << gp.idx << "\n";
00255 os << "w: " << gp.w << "\n";
00256
00257
00258
00259
00260
00261
00262 return os;
00263 }
00264
00265
00266
00267
00268
00269
00271
00273
00275
00288 void interpweights( VectorView itw,
00289 const GridPosPoly& tc )
00290 {
00291 assert(is_size(itw,tc.w.nelem()));
00292
00293
00294
00295
00296
00297
00298 Index iti = 0;
00299
00300 LOOPW(c)
00301 {
00302 itw[iti] = *c;
00303 ++iti;
00304 }
00305 }
00306
00308
00322 void interpweights( VectorView itw,
00323 const GridPosPoly& tr,
00324 const GridPosPoly& tc )
00325 {
00326 assert(is_size(itw,
00327 tr.w.nelem()*
00328 tc.w.nelem()));
00329 Index iti = 0;
00330
00331 LOOPW(r)
00332 LOOPW(c)
00333 {
00334 itw[iti] = (*r) * (*c);
00335 ++iti;
00336 }
00337 }
00338
00340
00355 void interpweights( VectorView itw,
00356 const GridPosPoly& tp,
00357 const GridPosPoly& tr,
00358 const GridPosPoly& tc )
00359 {
00360 assert(is_size(itw,
00361 tp.w.nelem()*
00362 tr.w.nelem()*
00363 tc.w.nelem()));
00364
00365 Index iti = 0;
00366
00367 LOOPW(p)
00368 LOOPW(r)
00369 LOOPW(c)
00370 {
00371 itw[iti] = (*p) * (*r) * (*c);
00372 ++iti;
00373 }
00374 }
00375
00377
00393 void interpweights( VectorView itw,
00394 const GridPosPoly& tb,
00395 const GridPosPoly& tp,
00396 const GridPosPoly& tr,
00397 const GridPosPoly& tc )
00398 {
00399 assert(is_size(itw,
00400 tb.w.nelem()*
00401 tp.w.nelem()*
00402 tr.w.nelem()*
00403 tc.w.nelem()));
00404
00405 Index iti = 0;
00406
00407 LOOPW(b)
00408 LOOPW(p)
00409 LOOPW(r)
00410 LOOPW(c)
00411 {
00412 itw[iti] = (*b) * (*p) * (*r) * (*c);
00413 ++iti;
00414 }
00415 }
00416
00418
00435 void interpweights( VectorView itw,
00436 const GridPosPoly& ts,
00437 const GridPosPoly& tb,
00438 const GridPosPoly& tp,
00439 const GridPosPoly& tr,
00440 const GridPosPoly& tc )
00441 {
00442 assert(is_size(itw,
00443 ts.w.nelem()*
00444 tb.w.nelem()*
00445 tp.w.nelem()*
00446 tr.w.nelem()*
00447 tc.w.nelem()));
00448
00449 Index iti = 0;
00450
00451 LOOPW(s)
00452 LOOPW(b)
00453 LOOPW(p)
00454 LOOPW(r)
00455 LOOPW(c)
00456 {
00457 itw[iti] = (*s) * (*b) * (*p) * (*r) * (*c);
00458 ++iti;
00459 }
00460 }
00461
00463
00481 void interpweights( VectorView itw,
00482 const GridPosPoly& tv,
00483 const GridPosPoly& ts,
00484 const GridPosPoly& tb,
00485 const GridPosPoly& tp,
00486 const GridPosPoly& tr,
00487 const GridPosPoly& tc )
00488 {
00489 assert(is_size(itw,
00490 tv.w.nelem()*
00491 ts.w.nelem()*
00492 tb.w.nelem()*
00493 tp.w.nelem()*
00494 tr.w.nelem()*
00495 tc.w.nelem()));
00496
00497 Index iti = 0;
00498
00499 LOOPW(v)
00500 LOOPW(s)
00501 LOOPW(b)
00502 LOOPW(p)
00503 LOOPW(r)
00504 LOOPW(c)
00505 {
00506 itw[iti] = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
00507 ++iti;
00508 }
00509 }
00510
00512
00527 Numeric interp( ConstVectorView itw,
00528 ConstVectorView a,
00529 const GridPosPoly& tc )
00530 {
00531 assert(is_size(itw,tc.w.nelem()));
00532
00533
00534
00535 assert( is_same_within_epsilon( itw.sum(),
00536 1,
00537 sum_check_epsilon ) );
00538
00539
00540 Numeric tia = 0;
00541
00542 Index iti = 0;
00543 LOOPIDX(c)
00544 {
00545 tia += a[*c] * itw[iti];
00546 ++iti;
00547 }
00548
00549 return tia;
00550 }
00551
00553
00569 Numeric interp( ConstVectorView itw,
00570 ConstMatrixView a,
00571 const GridPosPoly& tr,
00572 const GridPosPoly& tc )
00573 {
00574 assert(is_size(itw,
00575 tr.w.nelem()*
00576 tc.w.nelem()));
00577
00578
00579
00580 assert( is_same_within_epsilon( itw.sum(),
00581 1,
00582 sum_check_epsilon ) );
00583
00584
00585 Numeric tia = 0;
00586
00587 Index iti = 0;
00588 LOOPIDX(r)
00589 LOOPIDX(c)
00590 {
00591 tia += a(*r,
00592 *c) * itw[iti];
00593 ++iti;
00594 }
00595
00596 return tia;
00597 }
00598
00600
00617 Numeric interp( ConstVectorView itw,
00618 ConstTensor3View a,
00619 const GridPosPoly& tp,
00620 const GridPosPoly& tr,
00621 const GridPosPoly& tc )
00622 {
00623 assert(is_size(itw,
00624 tp.w.nelem()*
00625 tr.w.nelem()*
00626 tc.w.nelem()));
00627
00628
00629
00630 assert( is_same_within_epsilon( itw.sum(),
00631 1,
00632 sum_check_epsilon ) );
00633
00634
00635 Numeric tia = 0;
00636
00637 Index iti = 0;
00638 LOOPIDX(p)
00639 LOOPIDX(r)
00640 LOOPIDX(c)
00641 {
00642 tia += a(*p,
00643 *r,
00644 *c) * itw[iti];
00645 ++iti;
00646 }
00647
00648 return tia;
00649 }
00650
00652
00670 Numeric interp( ConstVectorView itw,
00671 ConstTensor4View a,
00672 const GridPosPoly& tb,
00673 const GridPosPoly& tp,
00674 const GridPosPoly& tr,
00675 const GridPosPoly& tc )
00676 {
00677 assert(is_size(itw,
00678 tb.w.nelem()*
00679 tp.w.nelem()*
00680 tr.w.nelem()*
00681 tc.w.nelem()));
00682
00683
00684
00685 assert( is_same_within_epsilon( itw.sum(),
00686 1,
00687 sum_check_epsilon ) );
00688
00689
00690 Numeric tia = 0;
00691
00692 Index iti = 0;
00693 LOOPIDX(b)
00694 LOOPIDX(p)
00695 LOOPIDX(r)
00696 LOOPIDX(c)
00697 {
00698 tia += a(*b,
00699 *p,
00700 *r,
00701 *c) * itw[iti];
00702 ++iti;
00703 }
00704
00705 return tia;
00706 }
00707
00709
00728 Numeric interp( ConstVectorView itw,
00729 ConstTensor5View a,
00730 const GridPosPoly& ts,
00731 const GridPosPoly& tb,
00732 const GridPosPoly& tp,
00733 const GridPosPoly& tr,
00734 const GridPosPoly& tc )
00735 {
00736 assert(is_size(itw,
00737 ts.w.nelem()*
00738 tb.w.nelem()*
00739 tp.w.nelem()*
00740 tr.w.nelem()*
00741 tc.w.nelem()));
00742
00743
00744
00745 assert( is_same_within_epsilon( itw.sum(),
00746 1,
00747 sum_check_epsilon ) );
00748
00749
00750 Numeric tia = 0;
00751
00752 Index iti = 0;
00753 LOOPIDX(s)
00754 LOOPIDX(b)
00755 LOOPIDX(p)
00756 LOOPIDX(r)
00757 LOOPIDX(c)
00758 {
00759 tia += a(*s,
00760 *b,
00761 *p,
00762 *r,
00763 *c) * itw[iti];
00764 ++iti;
00765 }
00766
00767 return tia;
00768 }
00769
00771
00791 Numeric interp( ConstVectorView itw,
00792 ConstTensor6View a,
00793 const GridPosPoly& tv,
00794 const GridPosPoly& ts,
00795 const GridPosPoly& tb,
00796 const GridPosPoly& tp,
00797 const GridPosPoly& tr,
00798 const GridPosPoly& tc )
00799 {
00800 assert(is_size(itw,
00801 tv.w.nelem()*
00802 ts.w.nelem()*
00803 tb.w.nelem()*
00804 tp.w.nelem()*
00805 tr.w.nelem()*
00806 tc.w.nelem()));
00807
00808
00809
00810 assert( is_same_within_epsilon( itw.sum(),
00811 1,
00812 sum_check_epsilon ) );
00813
00814
00815 Numeric tia = 0;
00816
00817 Index iti = 0;
00818 LOOPIDX(v)
00819 LOOPIDX(s)
00820 LOOPIDX(b)
00821 LOOPIDX(p)
00822 LOOPIDX(r)
00823 LOOPIDX(c)
00824 {
00825 tia += a(*v,
00826 *s,
00827 *b,
00828 *p,
00829 *r,
00830 *c) * itw[iti];
00831 ++iti;
00832 }
00833
00834 return tia;
00835 }
00836
00837
00838
00840
00842
00844
00859 void interpweights( MatrixView itw,
00860 const ArrayOfGridPosPoly& cgp )
00861 {
00862 Index n = cgp.nelem();
00863 assert(is_size(itw,n,
00864 cgp[0].w.nelem()));
00865
00866
00867
00868 for ( Index i=0; i<n; ++i )
00869 {
00870
00871 const GridPosPoly& tc = cgp[i];
00872
00873
00874
00875
00876
00877
00878 Index iti = 0;
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903 LOOPW(c)
00904 {
00905 itw(i,iti) = *c;
00906 ++iti;
00907 }
00908 }
00909 }
00910
00912
00933 void interpweights( MatrixView itw,
00934 const ArrayOfGridPosPoly& rgp,
00935 const ArrayOfGridPosPoly& cgp )
00936 {
00937 Index n = cgp.nelem();
00938 assert(is_size(rgp,n));
00939 assert(is_size(itw,n,
00940 rgp[0].w.nelem()*
00941 cgp[0].w.nelem()));
00942
00943
00944
00945 for ( Index i=0; i<n; ++i )
00946 {
00947
00948 const GridPosPoly& tr = rgp[i];
00949 const GridPosPoly& tc = cgp[i];
00950
00951
00952
00953
00954
00955
00956
00957
00958 Index iti = 0;
00959
00960 LOOPW(r)
00961 LOOPW(c)
00962 {
00963 itw(i,iti) = (*r) * (*c);
00964 ++iti;
00965 }
00966 }
00967 }
00968
00970
00992 void interpweights( MatrixView itw,
00993 const ArrayOfGridPosPoly& pgp,
00994 const ArrayOfGridPosPoly& rgp,
00995 const ArrayOfGridPosPoly& cgp )
00996 {
00997 Index n = cgp.nelem();
00998 assert(is_size(pgp,n));
00999 assert(is_size(rgp,n));
01000 assert(is_size(itw,n,
01001 pgp[0].w.nelem()*
01002 rgp[0].w.nelem()*
01003 cgp[0].w.nelem()));
01004
01005
01006
01007 for ( Index i=0; i<n; ++i )
01008 {
01009
01010 const GridPosPoly& tp = pgp[i];
01011 const GridPosPoly& tr = rgp[i];
01012 const GridPosPoly& tc = cgp[i];
01013
01014 Index iti = 0;
01015 LOOPW(p)
01016 LOOPW(r)
01017 LOOPW(c)
01018 {
01019 itw(i,iti) = (*p) * (*r) * (*c);
01020 ++iti;
01021 }
01022 }
01023 }
01024
01026
01049 void interpweights( MatrixView itw,
01050 const ArrayOfGridPosPoly& bgp,
01051 const ArrayOfGridPosPoly& pgp,
01052 const ArrayOfGridPosPoly& rgp,
01053 const ArrayOfGridPosPoly& cgp )
01054 {
01055 Index n = cgp.nelem();
01056 assert(is_size(bgp,n));
01057 assert(is_size(pgp,n));
01058 assert(is_size(rgp,n));
01059 assert(is_size(itw,n,
01060 bgp[0].w.nelem()*
01061 pgp[0].w.nelem()*
01062 rgp[0].w.nelem()*
01063 cgp[0].w.nelem()));
01064
01065
01066
01067 for ( Index i=0; i<n; ++i )
01068 {
01069
01070 const GridPosPoly& tb = bgp[i];
01071 const GridPosPoly& tp = pgp[i];
01072 const GridPosPoly& tr = rgp[i];
01073 const GridPosPoly& tc = cgp[i];
01074
01075 Index iti = 0;
01076 LOOPW(b)
01077 LOOPW(p)
01078 LOOPW(r)
01079 LOOPW(c)
01080 {
01081 itw(i,iti) = (*b) * (*p) * (*r) * (*c);
01082 ++iti;
01083 }
01084 }
01085 }
01086
01088
01112 void interpweights( MatrixView itw,
01113 const ArrayOfGridPosPoly& sgp,
01114 const ArrayOfGridPosPoly& bgp,
01115 const ArrayOfGridPosPoly& pgp,
01116 const ArrayOfGridPosPoly& rgp,
01117 const ArrayOfGridPosPoly& cgp )
01118 {
01119 Index n = cgp.nelem();
01120 assert(is_size(sgp,n));
01121 assert(is_size(bgp,n));
01122 assert(is_size(pgp,n));
01123 assert(is_size(rgp,n));
01124 assert(is_size(itw,n,
01125 sgp[0].w.nelem()*
01126 bgp[0].w.nelem()*
01127 pgp[0].w.nelem()*
01128 rgp[0].w.nelem()*
01129 cgp[0].w.nelem()));
01130
01131
01132
01133 for ( Index i=0; i<n; ++i )
01134 {
01135
01136 const GridPosPoly& ts = sgp[i];
01137 const GridPosPoly& tb = bgp[i];
01138 const GridPosPoly& tp = pgp[i];
01139 const GridPosPoly& tr = rgp[i];
01140 const GridPosPoly& tc = cgp[i];
01141
01142 Index iti = 0;
01143 LOOPW(s)
01144 LOOPW(b)
01145 LOOPW(p)
01146 LOOPW(r)
01147 LOOPW(c)
01148 {
01149 itw(i,iti) = (*s) * (*b) * (*p) * (*r) * (*c);
01150 ++iti;
01151 }
01152 }
01153 }
01154
01156
01181 void interpweights( MatrixView itw,
01182 const ArrayOfGridPosPoly& vgp,
01183 const ArrayOfGridPosPoly& sgp,
01184 const ArrayOfGridPosPoly& bgp,
01185 const ArrayOfGridPosPoly& pgp,
01186 const ArrayOfGridPosPoly& rgp,
01187 const ArrayOfGridPosPoly& cgp )
01188 {
01189 Index n = cgp.nelem();
01190 assert(is_size(vgp,n));
01191 assert(is_size(sgp,n));
01192 assert(is_size(bgp,n));
01193 assert(is_size(pgp,n));
01194 assert(is_size(rgp,n));
01195 assert(is_size(itw,n,
01196 vgp[0].w.nelem()*
01197 sgp[0].w.nelem()*
01198 bgp[0].w.nelem()*
01199 pgp[0].w.nelem()*
01200 rgp[0].w.nelem()*
01201 cgp[0].w.nelem()));
01202
01203
01204
01205 for ( Index i=0; i<n; ++i )
01206 {
01207
01208 const GridPosPoly& tv = vgp[i];
01209 const GridPosPoly& ts = sgp[i];
01210 const GridPosPoly& tb = bgp[i];
01211 const GridPosPoly& tp = pgp[i];
01212 const GridPosPoly& tr = rgp[i];
01213 const GridPosPoly& tc = cgp[i];
01214
01215 Index iti = 0;
01216 LOOPW(v)
01217 LOOPW(s)
01218 LOOPW(b)
01219 LOOPW(p)
01220 LOOPW(r)
01221 LOOPW(c)
01222 {
01223 itw(i,iti) = (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
01224 ++iti;
01225 }
01226 }
01227 }
01228
01230
01246 void interp( VectorView ia,
01247 ConstMatrixView itw,
01248 ConstVectorView a,
01249 const ArrayOfGridPosPoly& cgp)
01250 {
01251 Index n = cgp.nelem();
01252 assert(is_size(ia,n));
01253 assert(is_size(itw,n,
01254 cgp[0].w.nelem()));
01255
01256
01257
01258
01259 assert( is_same_within_epsilon( itw(0,Range(joker)).sum(),
01260 1,
01261 sum_check_epsilon ) );
01262
01263
01264 for ( Index i=0; i<n; ++i )
01265 {
01266
01267 const GridPosPoly& tc = cgp[i];
01268
01269
01270
01271 Numeric& tia = ia[i];
01272 tia = 0;
01273
01274 Index iti = 0;
01275 LOOPIDX(c)
01276 {
01277 tia += a[*c] * itw(i,iti);
01278 ++iti;
01279 }
01280 }
01281 }
01282
01284
01305 void interp( VectorView ia,
01306 ConstMatrixView itw,
01307 ConstMatrixView a,
01308 const ArrayOfGridPosPoly& rgp,
01309 const ArrayOfGridPosPoly& cgp)
01310 {
01311 Index n = cgp.nelem();
01312 assert(is_size(ia,n));
01313 assert(is_size(rgp,n));
01314 assert(is_size(itw,n,
01315 rgp[0].w.nelem()*
01316 cgp[0].w.nelem()));
01317
01318
01319
01320
01321 assert( is_same_within_epsilon( itw(0,Range(joker)).sum(),
01322 1,
01323 sum_check_epsilon ) );
01324
01325
01326 for ( Index i=0; i<n; ++i )
01327 {
01328
01329 const GridPosPoly& tr = rgp[i];
01330 const GridPosPoly& tc = cgp[i];
01331
01332
01333
01334 Numeric& tia = ia[i];
01335 tia = 0;
01336
01337 Index iti = 0;
01338 LOOPIDX(r)
01339 LOOPIDX(c)
01340 {
01341 tia += a(*r,
01342 *c) * itw(i,iti);
01343 ++iti;
01344 }
01345 }
01346 }
01347
01349
01371 void interp( VectorView ia,
01372 ConstMatrixView itw,
01373 ConstTensor3View a,
01374 const ArrayOfGridPosPoly& pgp,
01375 const ArrayOfGridPosPoly& rgp,
01376 const ArrayOfGridPosPoly& cgp)
01377 {
01378 Index n = cgp.nelem();
01379 assert(is_size(ia,n));
01380 assert(is_size(pgp,n));
01381 assert(is_size(rgp,n));
01382 assert(is_size(itw,n,
01383 pgp[0].w.nelem()*
01384 rgp[0].w.nelem()*
01385 cgp[0].w.nelem()));
01386
01387
01388
01389
01390 assert( is_same_within_epsilon( itw(0,Range(joker)).sum(),
01391 1,
01392 sum_check_epsilon ) );
01393
01394
01395 for ( Index i=0; i<n; ++i )
01396 {
01397
01398 const GridPosPoly& tp = pgp[i];
01399 const GridPosPoly& tr = rgp[i];
01400 const GridPosPoly& tc = cgp[i];
01401
01402
01403
01404 Numeric& tia = ia[i];
01405 tia = 0;
01406
01407 Index iti = 0;
01408 LOOPIDX(p)
01409 LOOPIDX(r)
01410 LOOPIDX(c)
01411 {
01412 tia += a(*p,
01413 *r,
01414 *c) * itw(i,iti);
01415 ++iti;
01416 }
01417 }
01418 }
01419
01421
01444 void interp( VectorView ia,
01445 ConstMatrixView itw,
01446 ConstTensor4View a,
01447 const ArrayOfGridPosPoly& bgp,
01448 const ArrayOfGridPosPoly& pgp,
01449 const ArrayOfGridPosPoly& rgp,
01450 const ArrayOfGridPosPoly& cgp)
01451 {
01452 Index n = cgp.nelem();
01453 assert(is_size(ia,n));
01454 assert(is_size(bgp,n));
01455 assert(is_size(pgp,n));
01456 assert(is_size(rgp,n));
01457 assert(is_size(itw,n,
01458 bgp[0].w.nelem()*
01459 pgp[0].w.nelem()*
01460 rgp[0].w.nelem()*
01461 cgp[0].w.nelem()));
01462
01463
01464
01465
01466 assert( is_same_within_epsilon( itw(0,Range(joker)).sum(),
01467 1,
01468 sum_check_epsilon ) );
01469
01470
01471 for ( Index i=0; i<n; ++i )
01472 {
01473
01474 const GridPosPoly& tb = bgp[i];
01475 const GridPosPoly& tp = pgp[i];
01476 const GridPosPoly& tr = rgp[i];
01477 const GridPosPoly& tc = cgp[i];
01478
01479
01480
01481 Numeric& tia = ia[i];
01482 tia = 0;
01483
01484 Index iti = 0;
01485 LOOPIDX(b)
01486 LOOPIDX(p)
01487 LOOPIDX(r)
01488 LOOPIDX(c)
01489 {
01490 tia += a(*b,
01491 *p,
01492 *r,
01493 *c) * itw(i,iti);
01494 ++iti;
01495 }
01496 }
01497 }
01498
01500
01524 void interp( VectorView ia,
01525 ConstMatrixView itw,
01526 ConstTensor5View a,
01527 const ArrayOfGridPosPoly& sgp,
01528 const ArrayOfGridPosPoly& bgp,
01529 const ArrayOfGridPosPoly& pgp,
01530 const ArrayOfGridPosPoly& rgp,
01531 const ArrayOfGridPosPoly& cgp)
01532 {
01533 Index n = cgp.nelem();
01534 assert(is_size(ia,n));
01535 assert(is_size(sgp,n));
01536 assert(is_size(bgp,n));
01537 assert(is_size(pgp,n));
01538 assert(is_size(rgp,n));
01539 assert(is_size(itw,n,
01540 sgp[0].w.nelem()*
01541 bgp[0].w.nelem()*
01542 pgp[0].w.nelem()*
01543 rgp[0].w.nelem()*
01544 cgp[0].w.nelem()));
01545
01546
01547
01548
01549 assert( is_same_within_epsilon( itw(0,Range(joker)).sum(),
01550 1,
01551 sum_check_epsilon ) );
01552
01553
01554 for ( Index i=0; i<n; ++i )
01555 {
01556
01557 const GridPosPoly& ts = sgp[i];
01558 const GridPosPoly& tb = bgp[i];
01559 const GridPosPoly& tp = pgp[i];
01560 const GridPosPoly& tr = rgp[i];
01561 const GridPosPoly& tc = cgp[i];
01562
01563
01564
01565 Numeric& tia = ia[i];
01566 tia = 0;
01567
01568 Index iti = 0;
01569 LOOPIDX(s)
01570 LOOPIDX(b)
01571 LOOPIDX(p)
01572 LOOPIDX(r)
01573 LOOPIDX(c)
01574 {
01575 tia += a(*s,
01576 *b,
01577 *p,
01578 *r,
01579 *c) * itw(i,iti);
01580 ++iti;
01581 }
01582 }
01583 }
01584
01586
01611 void interp( VectorView ia,
01612 ConstMatrixView itw,
01613 ConstTensor6View a,
01614 const ArrayOfGridPosPoly& vgp,
01615 const ArrayOfGridPosPoly& sgp,
01616 const ArrayOfGridPosPoly& bgp,
01617 const ArrayOfGridPosPoly& pgp,
01618 const ArrayOfGridPosPoly& rgp,
01619 const ArrayOfGridPosPoly& cgp)
01620 {
01621 Index n = cgp.nelem();
01622 assert(is_size(ia,n));
01623 assert(is_size(vgp,n));
01624 assert(is_size(sgp,n));
01625 assert(is_size(bgp,n));
01626 assert(is_size(pgp,n));
01627 assert(is_size(rgp,n));
01628 assert(is_size(itw,n,
01629 vgp[0].w.nelem()*
01630 sgp[0].w.nelem()*
01631 bgp[0].w.nelem()*
01632 pgp[0].w.nelem()*
01633 rgp[0].w.nelem()*
01634 cgp[0].w.nelem()));
01635
01636
01637
01638
01639 assert( is_same_within_epsilon( itw(0,Range(joker)).sum(),
01640 1,
01641 sum_check_epsilon ) );
01642
01643
01644 for ( Index i=0; i<n; ++i )
01645 {
01646
01647 const GridPosPoly& tv = vgp[i];
01648 const GridPosPoly& ts = sgp[i];
01649 const GridPosPoly& tb = bgp[i];
01650 const GridPosPoly& tp = pgp[i];
01651 const GridPosPoly& tr = rgp[i];
01652 const GridPosPoly& tc = cgp[i];
01653
01654
01655
01656 Numeric& tia = ia[i];
01657 tia = 0;
01658
01659 Index iti = 0;
01660 LOOPIDX(v)
01661 LOOPIDX(s)
01662 LOOPIDX(b)
01663 LOOPIDX(p)
01664 LOOPIDX(r)
01665 LOOPIDX(c)
01666 {
01667 tia += a(*v,
01668 *s,
01669 *b,
01670 *p,
01671 *r,
01672 *c) * itw(i,iti);
01673 ++iti;
01674 }
01675 }
01676 }
01677
01679
01681
01683
01704 void interpweights( Tensor3View itw,
01705 const ArrayOfGridPosPoly& rgp,
01706 const ArrayOfGridPosPoly& cgp )
01707 {
01708 Index nr = rgp.nelem();
01709 Index nc = cgp.nelem();
01710 assert(is_size(itw,nr,nc,
01711 rgp[0].w.nelem()*
01712 cgp[0].w.nelem()));
01713
01714
01715
01716 for ( Index ir=0; ir<nr; ++ir )
01717 {
01718
01719 const GridPosPoly& tr = rgp[ir];
01720
01721 for ( Index ic=0; ic<nc; ++ic )
01722 {
01723
01724 const GridPosPoly& tc = cgp[ic];
01725
01726
01727
01728
01729
01730
01731
01732
01733 Index iti = 0;
01734
01735 LOOPW(r)
01736 LOOPW(c)
01737 {
01738 itw(ir,ic,iti) = (*r) * (*c);
01739 ++iti;
01740 }
01741 }
01742 }
01743 }
01744
01746
01768 void interpweights( Tensor4View itw,
01769 const ArrayOfGridPosPoly& pgp,
01770 const ArrayOfGridPosPoly& rgp,
01771 const ArrayOfGridPosPoly& cgp )
01772 {
01773 Index np = pgp.nelem();
01774 Index nr = rgp.nelem();
01775 Index nc = cgp.nelem();
01776
01777 assert(is_size(itw,np,nr,nc,
01778 pgp[0].w.nelem()*
01779 rgp[0].w.nelem()*
01780 cgp[0].w.nelem()));
01781
01782
01783 for ( Index ip=0; ip<np; ++ip )
01784 {
01785 const GridPosPoly& tp = pgp[ip];
01786 for ( Index ir=0; ir<nr; ++ir )
01787 {
01788 const GridPosPoly& tr = rgp[ir];
01789 for ( Index ic=0; ic<nc; ++ic )
01790 {
01791 const GridPosPoly& tc = cgp[ic];
01792
01793 Index iti = 0;
01794
01795 LOOPW(p)
01796 LOOPW(r)
01797 LOOPW(c)
01798 {
01799 itw(ip,ir,ic,iti) =
01800 (*p) * (*r) * (*c);
01801 ++iti;
01802 }
01803 }
01804 }
01805 }
01806 }
01807
01809
01832 void interpweights( Tensor5View itw,
01833 const ArrayOfGridPosPoly& bgp,
01834 const ArrayOfGridPosPoly& pgp,
01835 const ArrayOfGridPosPoly& rgp,
01836 const ArrayOfGridPosPoly& cgp )
01837 {
01838 Index nb = bgp.nelem();
01839 Index np = pgp.nelem();
01840 Index nr = rgp.nelem();
01841 Index nc = cgp.nelem();
01842
01843 assert(is_size(itw,nb,np,nr,nc,
01844 bgp[0].w.nelem()*
01845 pgp[0].w.nelem()*
01846 rgp[0].w.nelem()*
01847 cgp[0].w.nelem()));
01848
01849
01850 for ( Index ib=0; ib<nb; ++ib )
01851 {
01852 const GridPosPoly& tb = bgp[ib];
01853 for ( Index ip=0; ip<np; ++ip )
01854 {
01855 const GridPosPoly& tp = pgp[ip];
01856 for ( Index ir=0; ir<nr; ++ir )
01857 {
01858 const GridPosPoly& tr = rgp[ir];
01859 for ( Index ic=0; ic<nc; ++ic )
01860 {
01861 const GridPosPoly& tc = cgp[ic];
01862
01863 Index iti = 0;
01864
01865 LOOPW(b)
01866 LOOPW(p)
01867 LOOPW(r)
01868 LOOPW(c)
01869 {
01870 itw(ib,ip,ir,ic,iti) =
01871 (*b) * (*p) * (*r) * (*c);
01872 ++iti;
01873 }
01874 }
01875 }
01876 }
01877 }
01878 }
01879
01881
01905 void interpweights( Tensor6View itw,
01906 const ArrayOfGridPosPoly& sgp,
01907 const ArrayOfGridPosPoly& bgp,
01908 const ArrayOfGridPosPoly& pgp,
01909 const ArrayOfGridPosPoly& rgp,
01910 const ArrayOfGridPosPoly& cgp )
01911 {
01912 Index ns = sgp.nelem();
01913 Index nb = bgp.nelem();
01914 Index np = pgp.nelem();
01915 Index nr = rgp.nelem();
01916 Index nc = cgp.nelem();
01917
01918 assert(is_size(itw,ns,nb,np,nr,nc,
01919 sgp[0].w.nelem()*
01920 bgp[0].w.nelem()*
01921 pgp[0].w.nelem()*
01922 rgp[0].w.nelem()*
01923 cgp[0].w.nelem()));
01924
01925
01926 for ( Index is=0; is<ns; ++is )
01927 {
01928 const GridPosPoly& ts = sgp[is];
01929 for ( Index ib=0; ib<nb; ++ib )
01930 {
01931 const GridPosPoly& tb = bgp[ib];
01932 for ( Index ip=0; ip<np; ++ip )
01933 {
01934 const GridPosPoly& tp = pgp[ip];
01935 for ( Index ir=0; ir<nr; ++ir )
01936 {
01937 const GridPosPoly& tr = rgp[ir];
01938 for ( Index ic=0; ic<nc; ++ic )
01939 {
01940 const GridPosPoly& tc = cgp[ic];
01941
01942 Index iti = 0;
01943
01944 LOOPW(s)
01945 LOOPW(b)
01946 LOOPW(p)
01947 LOOPW(r)
01948 LOOPW(c)
01949 {
01950 itw(is,ib,ip,ir,ic,iti) =
01951 (*s) * (*b) * (*p) * (*r) * (*c);
01952 ++iti;
01953 }
01954 }
01955 }
01956 }
01957 }
01958 }
01959 }
01960
01962
01987 void interpweights( Tensor7View itw,
01988 const ArrayOfGridPosPoly& vgp,
01989 const ArrayOfGridPosPoly& sgp,
01990 const ArrayOfGridPosPoly& bgp,
01991 const ArrayOfGridPosPoly& pgp,
01992 const ArrayOfGridPosPoly& rgp,
01993 const ArrayOfGridPosPoly& cgp )
01994 {
01995 Index nv = vgp.nelem();
01996 Index ns = sgp.nelem();
01997 Index nb = bgp.nelem();
01998 Index np = pgp.nelem();
01999 Index nr = rgp.nelem();
02000 Index nc = cgp.nelem();
02001
02002 assert(is_size(itw,nv,ns,nb,np,nr,nc,
02003 vgp[0].w.nelem()*
02004 sgp[0].w.nelem()*
02005 bgp[0].w.nelem()*
02006 pgp[0].w.nelem()*
02007 rgp[0].w.nelem()*
02008 cgp[0].w.nelem()));
02009
02010
02011 for ( Index iv=0; iv<nv; ++iv )
02012 {
02013 const GridPosPoly& tv = vgp[iv];
02014 for ( Index is=0; is<ns; ++is )
02015 {
02016 const GridPosPoly& ts = sgp[is];
02017 for ( Index ib=0; ib<nb; ++ib )
02018 {
02019 const GridPosPoly& tb = bgp[ib];
02020 for ( Index ip=0; ip<np; ++ip )
02021 {
02022 const GridPosPoly& tp = pgp[ip];
02023 for ( Index ir=0; ir<nr; ++ir )
02024 {
02025 const GridPosPoly& tr = rgp[ir];
02026 for ( Index ic=0; ic<nc; ++ic )
02027 {
02028 const GridPosPoly& tc = cgp[ic];
02029
02030 Index iti = 0;
02031
02032 LOOPW(v)
02033 LOOPW(s)
02034 LOOPW(b)
02035 LOOPW(p)
02036 LOOPW(r)
02037 LOOPW(c)
02038 {
02039 itw(iv,is,ib,ip,ir,ic,iti) =
02040 (*v) * (*s) * (*b) * (*p) * (*r) * (*c);
02041 ++iti;
02042 }
02043 }
02044 }
02045 }
02046 }
02047 }
02048 }
02049 }
02050
02052
02073 void interp( MatrixView ia,
02074 ConstTensor3View itw,
02075 ConstMatrixView a,
02076 const ArrayOfGridPosPoly& rgp,
02077 const ArrayOfGridPosPoly& cgp)
02078 {
02079 Index nr = rgp.nelem();
02080 Index nc = cgp.nelem();
02081 assert(is_size(ia,nr,nc));
02082 assert(is_size(itw,nr,nc,
02083 rgp[0].w.nelem()*
02084 cgp[0].w.nelem()));
02085
02086
02087
02088
02089 assert( is_same_within_epsilon( itw(0,0,Range(joker)).sum(),
02090 1,
02091 sum_check_epsilon ) );
02092
02093
02094 for ( Index ir=0; ir<nr; ++ir )
02095 {
02096
02097 const GridPosPoly& tr = rgp[ir];
02098
02099 for ( Index ic=0; ic<nc; ++ic )
02100 {
02101
02102 const GridPosPoly& tc = cgp[ic];
02103
02104
02105
02106 Numeric& tia = ia(ir,ic);
02107 tia = 0;
02108
02109 Index iti = 0;
02110 LOOPIDX(r)
02111 LOOPIDX(c)
02112 {
02113 tia += a(*r,
02114 *c) * itw(ir,ic,iti);
02115 ++iti;
02116 }
02117 }
02118 }
02119 }
02120
02122
02144 void interp( Tensor3View ia,
02145 ConstTensor4View itw,
02146 ConstTensor3View a,
02147 const ArrayOfGridPosPoly& pgp,
02148 const ArrayOfGridPosPoly& rgp,
02149 const ArrayOfGridPosPoly& cgp)
02150 {
02151 Index np = pgp.nelem();
02152 Index nr = rgp.nelem();
02153 Index nc = cgp.nelem();
02154 assert(is_size(ia,
02155 np,nr,nc));
02156 assert(is_size(itw,
02157 np,nr,nc,
02158 pgp[0].w.nelem()*
02159 rgp[0].w.nelem()*
02160 cgp[0].w.nelem()));
02161
02162
02163
02164
02165 assert( is_same_within_epsilon( itw(0,0,0,Range(joker)).sum(),
02166 1,
02167 sum_check_epsilon ) );
02168
02169
02170 for ( Index ip=0; ip<np; ++ip )
02171 {
02172 const GridPosPoly& tp = pgp[ip];
02173 for ( Index ir=0; ir<nr; ++ir )
02174 {
02175 const GridPosPoly& tr = rgp[ir];
02176 for ( Index ic=0; ic<nc; ++ic )
02177 {
02178
02179 const GridPosPoly& tc = cgp[ic];
02180
02181
02182
02183 Numeric& tia = ia(ip,ir,ic);
02184 tia = 0;
02185
02186 Index iti = 0;
02187 LOOPIDX(p)
02188 LOOPIDX(r)
02189 LOOPIDX(c)
02190 {
02191 tia += a(*p,
02192 *r,
02193 *c) * itw(ip,ir,ic,
02194 iti);
02195 ++iti;
02196 }
02197 }
02198 }
02199 }
02200 }
02201
02203
02226 void interp( Tensor4View ia,
02227 ConstTensor5View itw,
02228 ConstTensor4View a,
02229 const ArrayOfGridPosPoly& bgp,
02230 const ArrayOfGridPosPoly& pgp,
02231 const ArrayOfGridPosPoly& rgp,
02232 const ArrayOfGridPosPoly& cgp)
02233 {
02234 Index nb = bgp.nelem();
02235 Index np = pgp.nelem();
02236 Index nr = rgp.nelem();
02237 Index nc = cgp.nelem();
02238 assert(is_size(ia,
02239 nb,np,nr,nc));
02240 assert(is_size(itw,
02241 nb,np,nr,nc,
02242 bgp[0].w.nelem()*
02243 pgp[0].w.nelem()*
02244 rgp[0].w.nelem()*
02245 cgp[0].w.nelem()));
02246
02247
02248
02249
02250 assert( is_same_within_epsilon( itw(0,0,0,0,Range(joker)).sum(),
02251 1,
02252 sum_check_epsilon ) );
02253
02254
02255 for ( Index ib=0; ib<nb; ++ib )
02256 {
02257 const GridPosPoly& tb = bgp[ib];
02258 for ( Index ip=0; ip<np; ++ip )
02259 {
02260 const GridPosPoly& tp = pgp[ip];
02261 for ( Index ir=0; ir<nr; ++ir )
02262 {
02263 const GridPosPoly& tr = rgp[ir];
02264 for ( Index ic=0; ic<nc; ++ic )
02265 {
02266
02267 const GridPosPoly& tc = cgp[ic];
02268
02269
02270
02271 Numeric& tia = ia(ib,ip,ir,ic);
02272 tia = 0;
02273
02274 Index iti = 0;
02275 LOOPIDX(b)
02276 LOOPIDX(p)
02277 LOOPIDX(r)
02278 LOOPIDX(c)
02279 {
02280 tia += a(*b,
02281 *p,
02282 *r,
02283 *c) * itw(ib,ip,ir,ic,
02284 iti);
02285 ++iti;
02286 }
02287 }
02288 }
02289 }
02290 }
02291 }
02292
02294
02318 void interp( Tensor5View ia,
02319 ConstTensor6View itw,
02320 ConstTensor5View a,
02321 const ArrayOfGridPosPoly& sgp,
02322 const ArrayOfGridPosPoly& bgp,
02323 const ArrayOfGridPosPoly& pgp,
02324 const ArrayOfGridPosPoly& rgp,
02325 const ArrayOfGridPosPoly& cgp)
02326 {
02327 Index ns = sgp.nelem();
02328 Index nb = bgp.nelem();
02329 Index np = pgp.nelem();
02330 Index nr = rgp.nelem();
02331 Index nc = cgp.nelem();
02332 assert(is_size(ia,
02333 ns,nb,np,nr,nc));
02334 assert(is_size(itw,
02335 ns,nb,np,nr,nc,
02336 sgp[0].w.nelem()*
02337 bgp[0].w.nelem()*
02338 pgp[0].w.nelem()*
02339 rgp[0].w.nelem()*
02340 cgp[0].w.nelem()));
02341
02342
02343
02344
02345 assert( is_same_within_epsilon( itw(0,0,0,0,0,Range(joker)).sum(),
02346 1,
02347 sum_check_epsilon ) );
02348
02349
02350 for ( Index is=0; is<ns; ++is )
02351 {
02352 const GridPosPoly& ts = sgp[is];
02353 for ( Index ib=0; ib<nb; ++ib )
02354 {
02355 const GridPosPoly& tb = bgp[ib];
02356 for ( Index ip=0; ip<np; ++ip )
02357 {
02358 const GridPosPoly& tp = pgp[ip];
02359 for ( Index ir=0; ir<nr; ++ir )
02360 {
02361 const GridPosPoly& tr = rgp[ir];
02362 for ( Index ic=0; ic<nc; ++ic )
02363 {
02364
02365 const GridPosPoly& tc = cgp[ic];
02366
02367
02368
02369 Numeric& tia = ia(is,ib,ip,ir,ic);
02370 tia = 0;
02371
02372 Index iti = 0;
02373 LOOPIDX(s)
02374 LOOPIDX(b)
02375 LOOPIDX(p)
02376 LOOPIDX(r)
02377 LOOPIDX(c)
02378 {
02379 tia += a(*s,
02380 *b,
02381 *p,
02382 *r,
02383 *c) * itw(is,ib,ip,ir,ic,
02384 iti);
02385 ++iti;
02386 }
02387 }
02388 }
02389 }
02390 }
02391 }
02392 }
02393
02395
02420 void interp( Tensor6View ia,
02421 ConstTensor7View itw,
02422 ConstTensor6View a,
02423 const ArrayOfGridPosPoly& vgp,
02424 const ArrayOfGridPosPoly& sgp,
02425 const ArrayOfGridPosPoly& bgp,
02426 const ArrayOfGridPosPoly& pgp,
02427 const ArrayOfGridPosPoly& rgp,
02428 const ArrayOfGridPosPoly& cgp)
02429 {
02430 Index nv = vgp.nelem();
02431 Index ns = sgp.nelem();
02432 Index nb = bgp.nelem();
02433 Index np = pgp.nelem();
02434 Index nr = rgp.nelem();
02435 Index nc = cgp.nelem();
02436 assert(is_size(ia,
02437 nv,ns,nb,np,nr,nc));
02438 assert(is_size(itw,
02439 nv,ns,nb,np,nr,nc,
02440 vgp[0].w.nelem()*
02441 sgp[0].w.nelem()*
02442 bgp[0].w.nelem()*
02443 pgp[0].w.nelem()*
02444 rgp[0].w.nelem()*
02445 cgp[0].w.nelem()));
02446
02447
02448
02449
02450 assert( is_same_within_epsilon( itw(0,0,0,0,0,0,Range(joker)).sum(),
02451 1,
02452 sum_check_epsilon ) );
02453
02454
02455 for ( Index iv=0; iv<nv; ++iv )
02456 {
02457 const GridPosPoly& tv = vgp[iv];
02458 for ( Index is=0; is<ns; ++is )
02459 {
02460 const GridPosPoly& ts = sgp[is];
02461 for ( Index ib=0; ib<nb; ++ib )
02462 {
02463 const GridPosPoly& tb = bgp[ib];
02464 for ( Index ip=0; ip<np; ++ip )
02465 {
02466 const GridPosPoly& tp = pgp[ip];
02467 for ( Index ir=0; ir<nr; ++ir )
02468 {
02469 const GridPosPoly& tr = rgp[ir];
02470 for ( Index ic=0; ic<nc; ++ic )
02471 {
02472
02473 const GridPosPoly& tc = cgp[ic];
02474
02475
02476
02477 Numeric& tia = ia(iv,is,ib,ip,ir,ic);
02478 tia = 0;
02479
02480 Index iti = 0;
02481 LOOPIDX(v)
02482 LOOPIDX(s)
02483 LOOPIDX(b)
02484 LOOPIDX(p)
02485 LOOPIDX(r)
02486 LOOPIDX(c)
02487 {
02488 tia += a(*v,
02489 *s,
02490 *b,
02491 *p,
02492 *r,
02493 *c) * itw(iv,is,ib,ip,ir,ic,
02494 iti);
02495 ++iti;
02496 }
02497 }
02498 }
02499 }
02500 }
02501 }
02502 }
02503 }
02504
02505