ROOT  6.06/09
Reference Guide
testMinimization1D.cxx
Go to the documentation of this file.
1 #include "Math/Polynomial.h"
2 #include "Math/GSLMinimizer1D.h"
3 #include "Math/Functor.h"
4 //#include "TF1.h"
5 #include <iostream>
6 
7 
8 
9 
11 
12 
14 
15  std::vector<double> p(3);
16  p[0] = 1;
17  p[1] = -4;
18  p[2] = 1;
19  polyf->SetParameters(&p[0]);
20  //ROOT::Math::Functor1D<ROOT::Math::Base> func(*polyf);
21  ROOT::Math::IGenFunction & func = *polyf;
22 
23 
24  {
25  // default (Brent)
27  min.SetFunction(func,1,-10,10);
28  min.Minimize(100,0.01,0.01);
29  std::cout << "test Min1D " << min.Name() << " Return code " << min.Status() << std::endl;
30 
31  std::cout.precision(20);
32 
33  std::cout << "Found minimum: x = " << min.XMinimum() << " f(x) = " << min.FValMinimum() << std::endl;
34 
35  }
36  {
37  // Golden Section
39  min.SetFunction(func,1,-10,10);
40  min.Minimize(100,0.01,0.01);
41  std::cout << "test Min1D " << min.Name() << " Return code " << min.Status() << std::endl;
42 
43  std::cout.precision(20);
44 
45  std::cout << "Found minimum: x = " << min.XMinimum() << " f(x) = " << min.FValMinimum() << std::endl;
46 
47  }
48 
49 
50 }
51 
52 
53 
54 int main() {
55 
57  return 0;
58 
59 }
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition: IFunction.h:133
bool Minimize(int maxIter, double absTol, double relTol)
Find minimum position iterating until convergence specified by the absolute and relative tolerance or...
double FValMinimum() const
Return function value at current estimate of the minimum.
double XMinimum() const
Return current estimate of the position of the minimum.
int main()
virtual void SetParameters(const double *p)
Set the parameter values.
int Status() const
Return status of last minimization.
Parametric Function class describing polynomials of order n.
Definition: Polynomial.h:63
Minimizer for arbitrary one dimensional functions.
const char * Name() const
Return name of minimization algorithm.
double func(double *x, double *p)
Definition: stressTF1.cxx:213
void testMinimization1D()
void SetFunction(const UserFunc &f, double xmin, double xlow, double xup)
Set, or reset, minimizer to use the function f and the initial search interval [xlow, xup], with a guess for the location of the minimum xmin.