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
00031
00032
00033
00034 Real res;
00035
00036 Real x_i = 0.251;
00037 Real x_j = 0.129;
00038 Real x_k = 0.1;
00039 res = terneuve.interpolate(x_i,x_j);
00040
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 }