30 cout <<
"Simple interpolation cases\n" 31 <<
"--------------------------\n";
36 cout <<
"og:\n" << og <<
"\n";
37 cout <<
"ng:\n" << ng <<
"\n";
43 cout <<
"gp:\n" << gp <<
"\n";
52 cout <<
"itw:\n" << itw <<
"\n";
58 cout <<
"of:\n" << of <<
"\n";
65 cout <<
"nf:\n" << nf <<
"\n";
75 cout <<
"itw:\n" << itw <<
"\n";
78 Matrix of(og.nelem(),og.nelem(),0);
81 cout <<
"of:\n" << of <<
"\n";
86 interp(nf, itw, of, gp, gp);
88 cout <<
"nf:\n" << nf <<
"\n";
101 Index n = og.nelem();
103 of(2,2,2,2,2,2) = 10;
110 interp(nf, itw, of, gp, gp, gp, gp, gp, gp);
112 cout <<
"nf:\n" << nf <<
"\n";
115 cout <<
"Green 2D:\n" 119 Tensor3 itw(gp.nelem(),gp.nelem(),4);
122 for (
Index i=0; i<itw.ncols(); ++i )
126 Matrix of(og.nelem(),og.nelem(),0);
129 cout <<
"of:\n" << of <<
"\n";
132 Matrix nf(ng.nelem(),ng.nelem());
134 interp(nf, itw, of, gp, gp);
136 cout <<
"nf:\n" << nf <<
"\n";
139 cout <<
"Green 6D:\n" 153 Tensor6 of(og.nelem(),og.nelem(),og.nelem(),og.nelem(),og.nelem(),og.nelem(),0);
154 of(2,2,2,2,2,2) = 10;
159 Tensor6 nf(ng.nelem(),ng.nelem(),ng.nelem(),ng.nelem(),ng.nelem(),ng.nelem());
161 interp(nf, itw, of, gp, gp, gp, gp, gp, gp);
169 cout <<
"Test whether for loop or iterator are quicker\n" 171 <<
"---------------------------------------------\n";
180 cout <<
"Test whether for loop or iterator are quicker\n" 182 <<
"---------------------------------------------\n";
188 for ( ; ai!=ae; ++ai, ++i )
197 cout <<
"Green type interpolation of all pages of a Tensor3\n";
202 Vector a_pgrid(1,3,1), a_rgrid(1,3,1), a_cgrid(1,3,1);
203 Tensor3 a( a_pgrid.nelem(), a_rgrid.nelem(), a_cgrid.
nelem() );
213 Vector n_rgrid(1,5,.5), n_cgrid(1,5,.5);
214 Tensor3 n( a_pgrid.nelem(), n_rgrid.nelem(), n_cgrid.
nelem() );
222 gridpos( n_rgp, a_rgrid, n_rgrid );
223 gridpos( n_cgp, a_cgrid, n_cgrid );
231 for (
Index i=0; i<a.npages(); ++i )
238 interp( np, itw, ap, n_rgp, n_cgp );
244 cout <<
"Original field:\n";
245 for (
Index i=0; i<a.npages(); ++i )
248 cout <<
"Interpolated field:\n";
249 for (
Index i=0; i<n.npages(); ++i )
255 cout <<
"Very simple interpolation case\n";
260 cout <<
"Original grid:\n" << og <<
"\n";
261 cout <<
"New grid:\n" << ng <<
"\n";
267 cout <<
"Grid positions:\n" << gp;
273 cout <<
"Interpolation weights:\n" << itw <<
"\n";
279 cout <<
"Original field:\n" << of <<
"\n";
286 cout <<
"New field:\n" << nf <<
"\n";
291 cout <<
"Simple extrapolation cases\n" 292 <<
"--------------------------\n";
297 cout <<
"og:\n" << og <<
"\n";
298 cout <<
"ng:\n" << ng <<
"\n";
304 cout <<
"gp:\n" << gp <<
"\n";
313 cout <<
"itw:\n" << itw <<
"\n";
317 for (
Index i=0; i<og.nelem(); ++i )
320 cout <<
"of:\n" << of <<
"\n";
327 cout <<
"nf:\n" << nf <<
"\n";
337 cout <<
"itw:\n" << itw <<
"\n";
340 Matrix of(og.nelem(),og.nelem(),0);
343 cout <<
"of:\n" << of <<
"\n";
348 interp(nf, itw, of, gp, gp);
350 cout <<
"nf:\n" << nf <<
"\n";
357 Matrix itw(gp.nelem(),64);
363 Index n = og.nelem();
365 of(2,2,2,2,2,2) = 10;
372 interp(nf, itw, of, gp, gp, gp, gp, gp, gp);
374 cout <<
"nf:\n" << nf <<
"\n";
377 cout <<
"Green 2D:\n" 381 Tensor3 itw(gp.nelem(),gp.nelem(),4);
384 for (
Index i=0; i<itw.ncols(); ++i )
388 Matrix of(og.nelem(),og.nelem(),0);
391 cout <<
"of:\n" << of <<
"\n";
394 Matrix nf(ng.nelem(),ng.nelem());
396 interp(nf, itw, of, gp, gp);
398 cout <<
"nf:\n" << nf <<
"\n";
401 cout <<
"Green 6D:\n" 415 Tensor6 of(og.nelem(),og.nelem(),og.nelem(),og.nelem(),og.nelem(),og.nelem(),0);
416 of(2,2,2,2,2,2) = 10;
421 Tensor6 nf(ng.nelem(),ng.nelem(),ng.nelem(),ng.nelem(),ng.nelem(),ng.nelem());
423 interp(nf, itw, of, gp, gp, gp, gp, gp, gp);
433 Vector new_x(0, 21, +0.25);
448 y2[i] = pow(x[i],3) + 2;
461 interp(y1_lin, itw, y1, gp);
462 interp(y2_lin, itw, y2, gp);
463 interp(y3_lin, itw, y3, gp);
465 cout <<
"y1_lin = ["<< y1_lin <<
"];\n";
466 cout <<
"y2_lin = ["<< y2_lin <<
"];\n";
467 cout <<
"y3_lin = ["<< y3_lin <<
"];\n";
481 cout <<
"y1_cub = ["<< y1_cub <<
"];\n";
482 cout <<
"y2_cub = ["<< y2_cub <<
"];\n";
483 cout <<
"y3_cub = ["<< y3_cub <<
"];\n";
497 interp(y1_new, itwp, y1, gpp);
498 interp(y2_new, itwp, y2, gpp);
499 interp(y3_new, itwp, y3, gpp);
501 cout <<
"y1_new = ["<< y1_new <<
"];\n";
502 cout <<
"y2_new = ["<< y2_new <<
"];\n";
503 cout <<
"y3_new = ["<< y3_new <<
"];\n";
508 cout <<
"Very simple interpolation case for the " 509 <<
"new higher order polynomials.\n";
514 cout <<
"Original grid:\n" << og <<
"\n";
515 cout <<
"New grid:\n" << ng <<
"\n";
523 cout <<
"Grid positions:\n" << gp;
526 Matrix itw(gp.nelem(),order+1);
529 cout <<
"Interpolation weights:\n" << itw <<
"\n";
535 cout <<
"Original field:\n" << of <<
"\n";
542 cout <<
"New field (order=" << order <<
"):\n" << nf <<
"\n";
544 cout <<
"All orders systematically:\n";
545 for (order=0; order<5; ++order)
548 itw.resize(gp.nelem(),order+1);
552 cout <<
"order " << order <<
": ";
553 for (
Index i=0; i<nf.nelem(); ++i)
554 cout << setw(8) << nf[i] <<
" ";
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.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
This file contains basic functions to handle XML data files.
ConstIterator1D begin() const
Return const iterator to first element.
ConstIterator1D end() const
Return const iterator behind last element.
Header file for interpolation.cc.
Index nelem() const
Returns the number of elements.
This file contains the definition of Array.
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
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)
Set up grid positions for higher order interpolation.
Header file for interpolation_poly.cc.
The class MakeVector is a special kind of Vector that can be initialized explicitly from one or more ...
A constant view of a Matrix.
The iterator class for sub vectors.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.