28#ifndef ROOT_Math_GSLMultiRootSolver
29#define ROOT_Math_GSLMultiRootSolver
31#include "gsl/gsl_vector.h"
32#include "gsl/gsl_matrix.h"
33#include "gsl/gsl_multiroots.h"
34#include "gsl/gsl_blas.h"
75 if (
n == 0)
return false;
77 unsigned int ndim =
funcVec[0]->NDim();
80 MATH_ERROR_MSGVAL(
"GSLMultiRootSolver::InitSolver",
"Wrong function dimension",ndim);
92 virtual const std::string &
Name()
const = 0;
98 const double *
X()
const {
110 const double *
Dx()
const {
120 if (
x ==
nullptr ||
dx ==
nullptr)
return -1;
128 if (
f ==
nullptr)
return -1;
137 virtual int SetSolver(
const std::vector<ROOT::Math::IMultiGenFunction*> &
funcVec,
const double *
x) = 0;
165 fName(std::string(
"undefined"))
195 int SetSolver(
const std::vector<ROOT::Math::IMultiGenFunction*> &
funcVec,
const double *
x)
override {
211 const std::string &
Name()
const override {
216 if (
fSolver ==
nullptr)
return -1;
222 if (
fSolver ==
nullptr)
return nullptr;
228 if (
fSolver ==
nullptr)
return nullptr;
234 if (
fSolver ==
nullptr)
return nullptr;
265 fName(std::string(
"undefined"))
296 int SetSolver(
const std::vector<ROOT::Math::IMultiGenFunction*> &
funcVec,
const double *
x)
override {
303 for (
unsigned int i = 0; i <
n; ++i) {
305 if (func ==
nullptr) {
306 MATH_ERROR_MSG(
"GSLMultiRootSolver::SetSolver",
"Function does not provide gradient interface");
321 const std::string &
Name()
const override {
#define MATH_ERROR_MSGVAL(loc, txt, x)
#define MATH_ERROR_MSG(loc, str)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
GSLMultiRootBaseSolver, internal class for implementing GSL multi-root finders This is the base class...
int TestResidual(double absTol) const
test using abs tolerance Sum |f|_i < absTol
virtual gsl_vector * GetDx() const =0
virtual int SetSolver(const std::vector< ROOT::Math::IMultiGenFunction * > &funcVec, const double *x)=0
virtual gsl_vector * GetRoot() const =0
virtual gsl_vector * GetF() const =0
const double * FVal() const
return function values
const double * X() const
solution values at the current iteration
virtual const std::string & Name() const =0
return name
virtual ~GSLMultiRootBaseSolver()
virtual Destructor
const double * Dx() const
return function steps
bool InitSolver(const std::vector< ROOT::Math::IMultiGenFunction * > &funcVec, const double *x)
init the solver with function list and initial values
virtual int Iterate()=0
perform an iteration
int TestDelta(double absTol, double relTol) const
test using abs and relative tolerance |dx| < absTol + relTol*|x| for every component
wrapper to a multi-dim function with derivatives for multi roots algorithm
gsl_multiroot_function_fdf * GetFunctions()
void SetFunctions(const FuncVector &f, unsigned int n)
Fill gsl function structure from a C++ function iterator and size and number of residuals.
GSLMultiRootDerivSolver, internal class for implementing GSL multi-root finders using derivatives.
gsl_multiroot_fdfsolver * fDerivSolver
GSLMultiRootDerivSolver & operator=(const GSLMultiRootDerivSolver &rhs)=delete
const std::string & Name() const override
return name
int SetSolver(const std::vector< ROOT::Math::IMultiGenFunction * > &funcVec, const double *x) override
set the solver parameters for the case of derivative
gsl_vector * GetRoot() const override
solution values at the current iteration
~GSLMultiRootDerivSolver() override
Destructor (no operations)
GSLMultiRootDerivSolver(const gsl_multiroot_fdfsolver_type *type, int n)
Constructor.
GSLMultiRootDerivSolver(GSLMultiRootDerivSolver &&)=delete
gsl_vector * GetDx() const override
return function steps
int Iterate() override
perform an iteration
std::vector< ROOT::Math::IMultiGradFunction * > fGradFuncVec
void CreateSolver(const gsl_multiroot_fdfsolver_type *type, unsigned int n)
create the solver from the type and size of number of fitting points and number of parameters
GSLMultiRootDerivFunctionWrapper fDerivFunctions
GSLMultiRootDerivSolver(const GSLMultiRootDerivSolver &)=delete
gsl_vector * GetF() const override
return function values
wrapper to a multi-dim function without derivatives for multi roots algorithm
gsl_multiroot_function * GetFunctions()
void SetFunctions(const FuncVector &f, unsigned int n)
Fill gsl function structure from a C++ function iterator and size and number of residuals.
GSLMultiRootSolver, internal class for implementing GSL multi-root finders not using derivatives.
gsl_vector * GetDx() const override
return function steps
void CreateSolver(const gsl_multiroot_fsolver_type *type, unsigned int n)
int Iterate() override
perform an iteration
GSLMultiRootFunctionWrapper fFunctions
gsl_multiroot_fsolver * fSolver
GSLMultiRootSolver(const gsl_multiroot_fsolver_type *type, int n)
Constructor from type and simension of system (number of functions)
GSLMultiRootSolver(const GSLMultiRootSolver &)=delete
const std::string & Name() const override
return name
GSLMultiRootSolver & operator=(const GSLMultiRootSolver &rhs)=delete
GSLMultiRootSolver(GSLMultiRootSolver &&)=delete
gsl_vector * GetRoot() const override
solution values at the current iteration
int SetSolver(const std::vector< ROOT::Math::IMultiGenFunction * > &funcVec, const double *x) override
set the solver parameters
gsl_vector * GetF() const override
return function values
~GSLMultiRootSolver() override
Destructor (no operations)
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...