GridSearch.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 // to compile:  g++ -I. -lm GridSearch.cpp<br />
00008 #include "GridSearch.h"
00009 #include <math.h>
00010 
00012 class somefunc {
00013 public:
00014   double a, b, c, d, e;
00015   
00016   somefunc( double A, double B, double C, double D, double E) : a(A), b(B), c(C), d(D), e(E) { }
00017 
00018   double f( double x) {
00019     return exp( a + b + c * x * x  +  d * x * x * x +  e * x * x * x * x);
00020   }
00021 
00022 };
00023 
00024 
00025 int main() {
00026   somefunc sf( -1, 2, 3, -.125, -.125);
00027 
00028   GridSearch< somefunc, double > foobar( 201, -10.0, .1, sf, &somefunc::f);
00029 
00030   foobar.do_iteration( true);
00031 
00032   cout << "x_max = " << foobar.get_x_max() << endl;
00033   cout << "f_x_max = " << foobar.get_f_x_max() << endl;
00034 
00035   return 0;
00036 }

Generated on Fri Jan 7 12:36:18 2011 for public_options by  doxygen 1.5.1