proj home

Files   Classes   Functions   Hierarchy  

probsysequ01.h

Go to the documentation of this file.
00001 #ifndef PROBSYSEQU01_H
00002 #define PROBSYSEQU01_H
00003 
00004 typedef unsigned int uint;
00005 typedef unsigned int const uintc;
00006 
00007 
00013 class probsysequ01
00014 {
00015 public:
00016 
00018   uint counter;
00019 
00020   double * xi;
00021  
00022   probsysequ01()
00023     : counter(0), xi(new double[2]) {}
00024   ~probsysequ01()
00025     { delete[] xi; }
00026 
00028   void operator () 
00029   (
00030     double & fval 
00031   ) 
00032   {
00033     double t0 = xi[0]-0.1136*(xi[0]+3.0*xi[1])*(1.0-xi[0]);
00034     double t1 = xi[1]+7.5*(2.0*xi[0]-xi[1])*(1.0-xi[1]);
00035     fval = t0*t0 + t1*t1;
00036 //cout << SHOW(fval) << endl;
00037     ++counter;
00038   }
00039 
00041   void partialderivative
00042   (
00043     double & val,
00044     uintc i,
00045     double const h
00046   )
00047   {
00048     assert(i<2);
00049     static double x2[2];
00050 
00051     //Save initial value.
00052     x2[i] = xi[i];
00053 
00054     xi[i] -= h*0.5;
00055     double f0;
00056     operator()(f0);
00057 
00058     double f1;
00059     xi[i] += h;
00060     operator()(f1);
00061 
00062     val = (f1-f0)/h;
00063 
00064     // Restore initial value.
00065     xi[i] = x2[i];
00066   };
00067 
00068 };
00069 
00070 
00071 #endif
00072 
00073 

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