00001 #include <TooN/optimization/brent.h>
00002 #include <iostream>
00003 #include <cmath>
00004 #include <cstdlib>
00005
00006 using namespace TooN;
00007 using namespace std;
00008
00009
00010
00011 double f(double x)
00012 {
00013 return abs(x-1.2) + .2 * sin(5*x);
00014 }
00015
00016
00017 int main()
00018 {
00019 cout << brent_line_search(-3., .5, 3., f(.5), f, 100) << endl;
00020
00021 cout << "Value should be: " << " 1.2000 -0.0559 " << endl;
00022 }
00023