#include <vector/MultiArray.hpp>
#include <vector/CatmullSplineIpol.hpp>
#include <vector/CubicIpol.hpp>
#include <vector/FastCubicIpol.hpp>
#include <vector/LinearIpol.hpp>
#include <vector/NearestNeighborIpol.hpp>
#include <vector/Interpolate.hpp>
#include <time.h>
int MA2()
{
enum { NX = 19, NY = 10 };
D.set(0.0);
D[ MIndex(2,5) ] = 9.0;
D[ MIndex(12,7) ] = 5.0;
{for(int y=0; y<D.Size()[1]; y++)
{
for(int x=0; x<D.Size()[0]; x++)
}}
I = 2,5;
double value = D[ I ];
cout <<
"Indexed Value = " << value <<
endl;
cout <<
"5th slice is " << D[5] <<
endl;
if (value != D[5][2])
return 0;
cout <<
"Value at 2,5 is " << value <<
endl;
cout <<
"------------------------" <<
endl;
double V2 = LI.eval();
if (
fabs(V2 -6.075) > 1E-10 )
return 0;
for(point[0]=2.0; point[0]<3.0; point[0]+=0.1)
{
cout <<
"Ipol2D[ " << point <<
"] = " << LI.eval() <<
endl;
}
cout <<
"2D Interpolation successfully demonstrated.\n" <<
endl;
return 1;
}
{
for(index_t i=0; i<D.count(); i++)
}
int MA3()
{
enum { NX=13, NY=10, NZ=23 };
cout <<
"Demonstration of Interpolating within a 3D array" <<
endl;
D.set(0.0);
I = 5,6,7;
D[ I ] = 100.0;
double value = D[ I ];
assert(value==100.0);
for(double fr=0; fr<1; fr+=0.1)
{
point = 5.1, 6.2, 7+fr;
cout <<
"Interpolation @" << point
<< "\t Linear: " << LI.eval()
<< "\t FCubic: " << LIfc.eval()
<< "\t Cubic: " << LIc.eval()
<< "\t Catmull: " << LIcs.eval()
}
#if 0
{
cerr <<
"-------------------------------------------------" <<
endl;
clock_t start, finish;
int N =1000000;
start = clock(); {for(int i=0; i<N; i++) LIn.eval();} finish = clock();
fprintf(stderr, "No Ipol: %2.1f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC );
start = clock(); {for(int i=0; i<N; i++) LI.eval();} finish = clock();
fprintf(stderr, "Linear Ipol: %2.1f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC );
start = clock(); {for(int i=0; i<N; i++) LIfc.eval();} finish = clock();
fprintf(stderr, "FCubic Ipol: %2.1f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC );
start = clock(); {for(int i=0; i<N; i++) LIc.eval();} finish = clock();
fprintf(stderr, "Cubic Ipol: %2.1f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC );
start = clock(); {for(int i=0; i<N; i++) LIcs.eval();} finish = clock();
fprintf(stderr, "CSplineIpol: %2.1f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC );
}
#endif
return 1;
}
void plain()
{
Dims = 10,10,10;
double *d =
new double[Dims.
size()];
I = 5,5,5;
double value = d[ I.
linear(Dims) ];
delete d;
}
int InterpolationExample()
{
int r=0;
r = MA2();
r += MA3();
return r;
}
_Tp fabs(const std::complex< _Tp > &__z)
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Catmull-Rom cubic spline interpolation.
Definition CatmullSplineIpol.hpp:53
Cubic interpolation using Hermite polynoms.
Definition CubicIpol.hpp:70
Fast cubic interpolation which requires the same number of sampling points as the linear interpolatio...
Definition FastCubicIpol.hpp:58
Implementation of an Iterator to a sequence of elements, which might be contiguous or a projection of...
Definition vector/Iterator.hpp:525
Linear interpolation.
Definition LinearIpol.hpp:40
Definition MultiArray.hpp:371
A multidimensional index that is automatically a lower-dimensional index via recursion.
Definition MultiIndex.hpp:449
index_t linear(const MultiIndex &Dimens) const
Compute the linear index from the given dimensionator.
Definition MultiIndex.hpp:1520
index_t size() const noexcept
Recursive function to compute the entire number of elements.
Definition MultiIndex.hpp:774
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
The interpolator template.
Definition Interpolate.hpp:63