#include "Math/IFunction.h"
#include "Math/GSLRootFinderDeriv.h"
#include "Math/GSLRootHelper.h"
#include "GSLRootFdFSolver.h"
#include "GSLFunctionWrapper.h"
#include "gsl/gsl_roots.h"
#include "gsl/gsl_errno.h"
#include <iostream>
namespace ROOT {
namespace Math {
GSLRootFinderDeriv::GSLRootFinderDeriv() 
{ 
   
   fFunction = new GSLFunctionDerivWrapper(); 
}
GSLRootFinderDeriv::~GSLRootFinderDeriv() 
{
   
   if (fFunction) delete fFunction;
}
GSLRootFinderDeriv::GSLRootFinderDeriv(const GSLRootFinderDeriv &) 
{
}
GSLRootFinderDeriv & GSLRootFinderDeriv::operator = (const GSLRootFinderDeriv &rhs) 
{
   
   if (this == &rhs) return *this;  
   
   return *this;
}
void GSLRootFinderDeriv::SetFunction(  GSLFuncPointer f, GSLFuncPointer df, GSLFdFPointer Fdf, void * p, double Root) {
   
   fRoot = Root;
   fFunction->SetFuncPointer( f ); 
   fFunction->SetDerivPointer( df ); 
   fFunction->SetFdfPointer( Fdf ); 
   fFunction->SetParams( p ); 
   gsl_root_fdfsolver_set( fS->Solver(), fFunction->GetFunc(), Root); 
}
void GSLRootFinderDeriv::SetSolver(GSLRootFdFSolver * s ) {
   
   fS = s; 
}
void GSLRootFinderDeriv::FreeSolver( ) { 
   
   if (fS) delete fS; 
}
int GSLRootFinderDeriv::Iterate() { 
   
   
   if (!fFunction->IsValid() ) {
      std::cerr << "GSLRootFinderDeriv - Error: Function is not valid" << std::endl;
      return -1; 
   }
   
   int status = gsl_root_fdfsolver_iterate(fS->Solver()); 
   
   fPrevRoot = fRoot;
   fRoot =  gsl_root_fdfsolver_root(fS->Solver() ); 
   return status; 
}
double GSLRootFinderDeriv::Root() const {
   
   return fRoot; 
}
const char * GSLRootFinderDeriv::Name() const {
   
   return gsl_root_fdfsolver_name(fS->Solver() ); 
}
int GSLRootFinderDeriv::Solve (int maxIter, double absTol, double relTol) 
{ 
   
   int iter = 0; 
   int status = 0; 
   do { 
      iter++; 
      
      status = Iterate();
      if (status != GSL_SUCCESS) return status; 
      status = GSLRootHelper::TestDelta(fRoot, fPrevRoot, absTol, relTol);
      if (status == GSL_SUCCESS) { 
         fIter = iter;
         return status; 
      }
      
      
      
   }
   while (status == GSL_CONTINUE && iter < maxIter); 
   return status;
}
} 
} 
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.