00001 00002 00003 00004 00005 00006 00007 // to compile: g++ -I. -lm Secant.cpp<br /> 00008 #include "Secant.h" 00009 #include <math.h> 00010 00011 00013 class secant_functor { 00014 public: 00016 double _offset; 00017 00019 secant_functor( double offset) : _offset(offset) { } 00020 00022 double f( double x) { 00023 return exp( x) - _offset; 00024 } 00025 00026 }; 00027 00028 int main() { 00029 secant_functor sf( 5); 00030 00031 SecantSolve0< secant_functor, double > foobar( 1.0, 10.0, 0.0, 1e-8, 100, sf, &secant_functor::f); 00032 00033 foobar.do_iteration( true); 00034 00035 foobar.set_check_boundary( true); 00036 foobar.set_max_x( 1.6); 00037 00038 foobar.do_iteration( true); 00039 00040 return 0; 00041 }
1.5.1