proj home

Files   Classes   Functions   Hierarchy  

exploretest.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void exploretest01 ()
void exploretest02 ()
void exploretest03 ()
void exploretest04 ()
void exploretest05 ()
void exploretest06 ()
void exploretest07 ()
void exploretest08 ()


Function Documentation

void exploretest01 (  ) 

Definition at line 18 of file exploretest.cpp.

References exploreh< FN, XI, T >::indexmax, exploreh< FN, XI, T >::reset(), exploreh< FN, XI, T >::xi, and exploreh< FN, XI, T >::xiSet().

Referenced by main().

00019 {
00020   uintc n(3);
00021   exploreh<probparab,double*,double> g(n);
00022   double xi[n];
00023   g.xiSet((double*)xi);
00024 
00025   double x0[3] = { 0.0, 0.0, 0.0 };
00026 
00027   g.indexmax = 50;
00028   for (g.reset(x0); !g; ++g)
00029     cout << print<double*>(g.xi,g.xi+n) << endl;
00030     //cout << printvec<double*>(g.xi,n) << endl;
00031 
00032   cout << "The exact solution is (1,2,5)" << endl;
00033 
00034 }

void exploretest02 (  ) 

Definition at line 36 of file exploretest.cpp.

References exploreh< FN, XI, T >::indexmax, exploreh< FN, XI, T >::print(), pts, exploreh< FN, XI, T >::reset(), and exploreh< FN, XI, T >::xi.

Referenced by main().

00037 {
00038   vector<pt2> pts;
00039 
00040   uintc psz =7;
00041   double const parray[2*psz] = 
00042   {
00043     0.0, 0.0,
00044     1.0, 1.1,
00045     1.5, 2.8,
00046     2.8, 4.2,
00047     4.8, 4.0,
00048     6.8, 4.2,
00049     8.1, 5.5
00050   };
00051 
00052   for (uint i=0; i<psz; ++i)
00053     pts.push_back( pt2(parray[i*2],parray[i*2+1]) );
00054 
00055   leastsqrs fn(pts);
00056   
00057   exploreh<leastsqrs &,double*,double> g(fn,psz);
00058 
00059   double x0[psz];
00060   for (uint i=0; i<psz; ++i)
00061     x0[i] = pts[i].y;
00062 
00063   //g.h0Set(1.52E-5);
00064 
00065   g.indexmax = 50;
00066 
00067   for (g.reset(x0); !g; ++g)
00068   {
00069     g.print(cout) << endl;
00070   }
00071 
00072   cout << endl << endl;
00073 
00074 
00075   cout << "The result" << endl;
00076   for (uint i=0; i<psz; ++i)
00077   {
00078     cout << pts[i].x << " " << g.xi[i] << endl;
00079   }
00080 
00081 }

void exploretest03 (  ) 

Definition at line 159 of file exploretest.cpp.

References probsysequ01::counter, exploreh< FN, XI, T >::fn, exploreh< FN, XI, T >::hi, probsysequ01::partialderivative(), exploreh< FN, XI, T >::print(), exploreh< FN, XI, T >::reset(), and SHOW.

Referenced by main().

00160 {
00161   cout << "This test is to solve a non-linear system of equations" << endl;
00162   cout << " numerically and terminate the approximation when the" << endl;
00163   cout << " parital derivatives become small." << endl;
00164   exploreh<probsysequ01,double*,double> g(2,0.2,50000);
00165 
00166   double x0[2] = { 0.5, 0.5 };
00167 
00168   g.reset(x0);
00169 
00170   g.print(cout);
00171 
00172 
00173   double zero = 1e-5;
00174   cout << "Iterate until the partial derivative are less than" << endl;
00175   cout << " " << zero << " in magnitude." << endl;
00176   bool valid=true;
00177 
00178   double pd[2];
00179 
00180   for (uint i=0; valid; ++i)
00181   {
00182     g.fn.partialderivative(pd[0],0,g.hi[0]);
00183     g.fn.partialderivative(pd[1],1,g.hi[1]);
00184     if (zero>(abs(pd[0])+abs(pd[1])))
00185       valid=false;
00186 
00187 cout << SHOW(i) << endl;
00188     ++g;
00189 
00190   }
00191 
00192   g.print(cout);
00193   cout << SHOW(g.fn.counter) << endl;
00194 
00195 }

void exploretest04 (  ) 

Definition at line 112 of file exploretest.cpp.

References probparab2::counter, exploreh< FN, XI, T >::fn, exploreh< FN, XI, T >::hasStateChanged, exploreh< FN, XI, T >::indexmax, exploreh< FN, XI, T >::reset(), SHOW, and exploreh< FN, XI, T >::xi.

Referenced by main().

00113 {
00114   cout << "Testing the hasStateChanged variable in exploreh" << endl;
00115   cout << "Looking at d xi" << endl;
00116   exploreh<probparab2,double*,double> g(3);
00117 
00118   double x0[3] = { 0.0, 0.0, 0.0 };
00119   double x1[3];
00120 
00121   g.indexmax = 50;
00122   g.reset(x0);
00123   double dist;
00124   for (g.reset(x0); !g; ++g)
00125   {
00126     if (g.hasStateChanged)
00127     {
00128       dist=0.0;
00129       for (uint k=0; k<3; ++k)
00130       {
00131         x1[k] = g.xi[k]-x0[k];
00132         dist += x1[k]*x1[k];
00133         x0[k] = g.xi[k];
00134       }
00135       cout << SHOW(dist) << endl;
00136     }
00137   }
00138   cout << g.xi[0] << " " << g.xi[1] << " " << g.xi[2]  << endl;
00139   cout << SHOW(g.fn.counter) << endl;
00140   cout << "The exact solution is (1,2,5)" << endl;
00141 }

void exploretest05 (  ) 

Definition at line 83 of file exploretest.cpp.

References exploreh< FN, XI, T >::indexmax, exploreh< FN, XI, T >::reset(), and exploreh< FN, XI, T >::xi.

Referenced by main().

00084 {
00085 
00086   probparab2 fn;
00087   exploreh<probparab2 &,double*,double> g(fn,3);
00088 
00089   double x0[3] = { 0.0, 0.0, 0.0 };
00090 
00091   g.indexmax = 50;
00092   for (g.reset(x0); !g; ++g)
00093     cout << g.xi[0] << " " << g.xi[1] << " " << g.xi[2]  << endl;
00094 
00095   cout << "The exact solution is (1,2,5)" << endl;
00096 
00097 }

void exploretest06 (  ) 

Definition at line 99 of file exploretest.cpp.

References exploreh< FN, XI, T >::indexmax, exploreh< FN, XI, T >::reset(), and exploreh< FN, XI, T >::xi.

Referenced by main().

00100 {
00101   exploreh<probparab2,double*,double> g(3);
00102 
00103   double x0[3] = { 0.0, 0.0, 0.0 };
00104 
00105   g.indexmax = 50;
00106   for (g.reset(x0); !g; ++g)
00107     cout << g.xi[0] << " " << g.xi[1] << " " << g.xi[2]  << endl;
00108 
00109   cout << "The exact solution is (1,2,5)" << endl;
00110 }

void exploretest07 (  ) 

Definition at line 143 of file exploretest.cpp.

References exploreh< FN, XI, T >::indexmax, exploreh< FN, XI, T >::reset(), and exploreh< FN, XI, T >::xi.

Referenced by main().

00144 {
00145   exploreh<probparab3,dumbarray<double>,double> g(3);
00146   double x0[3] = { 0.0, 0.0, 0.0 };
00147 
00148   g.indexmax = 50;
00149   for (g.reset(x0); !g; ++g)
00150     cout << g.xi[0] << " " << g.xi[1] << " " << g.xi[2] << endl;
00151 
00152   cout << "The exact solution is (1,2,5)" << endl;
00153 }

void exploretest08 (  ) 

Definition at line 197 of file exploretest.cpp.

References probrosenbrock01::counter, exploreh< FN, XI, T >::fmin, exploreh< FN, XI, T >::fn, exploreh< FN, XI, T >::indexmax, exploreh< FN, XI, T >::print(), exploreh< FN, XI, T >::reset(), SHOW, and exploreh< FN, XI, T >::xiSet().

Referenced by main().

00198 {
00199   uintc n(2);
00200   exploreh<probrosenbrock01,double*,double> g(n);
00201   double xi[n];
00202   g.xiSet((double*)xi);
00203 
00204   double x0[n] = { 0.0, 0.0 };
00205 
00206   cout << "Enter initial point" << endl;
00207   cin >> x0[0] >> x0[1];
00208 
00209   g.indexmax = 80;
00210   uint i=1;
00211   uintc ireset=300;
00212 
00213   for (g.reset(x0); !g; ++g)
00214   {
00215     if (i%ireset==0)
00216     { 
00217       cout << "resetting g" << endl;
00218       g.reset();
00219     }
00220     ++i;
00221 
00222     g.print(cout);
00223 
00224     //cout << printvec<double*>(g.xi,n) << endl;
00225   }
00226 
00227   cout << SHOW(g.fn.counter) << endl;
00228   cout << SHOW(g.fmin) << endl;
00229 
00230   cout << "The exact solution is (1,1)" << endl;
00231 
00232 }


Generated on Fri Mar 4 00:49:45 2011 for Chelton Evans Source by  doxygen 1.5.8