ANIMA  4.0
animaBoostBisectionRootFindingAlgorithm.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__, "Boost bisection 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 = boost::math::tools::bisect(boostFunction, this->GetLowerBound(), this->GetUpperBound(), rootTolerance, maximumNumberOfIterations);
22 
23  return (r.first + r.second) / 2.0;
24 }
25 
26 } // end namespace anima
void SetRootFindingFunction(BaseCostFunctionType *f)