ANIMA  4.0
animaTOMS748RootFindingAlgorithm.cxx
Go to the documentation of this file.
2 #include <boost/math/tools/roots.hpp>
3 
4 namespace anima
5 {
6 
8 {
9  unsigned int numParameters = this->GetRootFindingFunction()->GetNumberOfParameters();
10  if (numParameters > 1)
11  throw itk::ExceptionObject(__FILE__, __LINE__, "TOMS748 algorithm does not implement multi-dimensional optimization. Only one parameter allowed.");
12 
13  RootFindingFunctionBoostBridge boostFunction;
14  boostFunction.SetRootFindingFunction(this->GetRootFindingFunction());
15 
16  boost::uintmax_t maximumNumberOfIterations = this->GetMaximumNumberOfIterations();
17 
18  RootToleranceBoostBridge rootTolerance;
20 
21  std::pair <double,double> r;
22 
24  r = boost::math::tools::toms748_solve(boostFunction, this->GetLowerBound(), this->GetUpperBound(), this->GetFunctionValueAtInitialLowerBound(), this->GetFunctionValueAtInitialUpperBound(), rootTolerance, maximumNumberOfIterations);
25  else
26  r = boost::math::tools::toms748_solve(boostFunction, this->GetLowerBound(), this->GetUpperBound(), rootTolerance, maximumNumberOfIterations);
27 
28  return (r.first + r.second) / 2.0;
29 }
30 
31 } // end namespace anima
void SetRootFindingFunction(BaseCostFunctionType *f)