Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

maininterpolator.cpp

Go to the documentation of this file.
00001 #include "..\common\date.h"
00002 #include "..\common\interpolator.h"
00003 #include<valarray>
00004 
00005 bool maininterpolator(void){
00006         valarray<Real> x1(4);
00007     valarray<Real> x2(4);
00008     valarray<Real> temp(4);
00009     valarray<valarray<Real> > y(4);
00010     Integer i,j;
00011     for(i=0;i<4;i++)
00012     {
00013             x1[i]=i/10.0;
00014             x2[i]=i/10.0;
00015     }
00016     
00017     for(i=0;i<4;i++)
00018     {
00019             for(j=0;j<4;j++)
00020                   temp[j]=sin(x1[i]+x2[j]*x2[j]);
00021 
00022             y[i].resize(4);
00023             y[i]=temp;
00024     }
00025 
00026     interpolator terneuve(x1, x2, y);
00027         Integer n1 = x1.size();
00028         Integer n2 = x2.size();
00029 
00030 //  Real tab[] = {0.15,0.25,0.35,0.45};
00031 //  valarray<Real> temp(tab, 4);
00032 
00033 
00034   Real res;
00035 
00036   Real x_i = 0.251;//x1[1];
00037   Real x_j = 0.129;//x2[2];
00038   Real x_k = 0.1;
00039   res = terneuve.interpolate(x_i,x_j);
00040 //  res = terneuve.interpolate(x_k,x_j);
00041 
00042   cout<<" f(x1,x2)=sin(x1+x2*x2)"<<endl;
00043   cout<<"we give in input f(x1,x2) for (x1,x2) in {0,0.1,0.2,0.3}"<<endl;
00044   cout<<"we want to interpolate f for x1=0.251 and x2=0.129"<<endl;
00045   cout<<"the interpolation gives  "<<res<<endl;
00046   cout<<"and the true value is 0.26445472"<<endl;
00047   return false;
00048 }

Note: Generated nightly - reload for latest version
Generated on Thu Dec 22 23:12:36 2005 for terreneuve by doxygen 1.3.6