Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RootFinder.cxx
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Authors: David Gonzalez Maline 01/2008
3
4 /**********************************************************************
5 * *
6 * Copyright (c) 2006 CERN *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 * *
12 **********************************************************************/
13
14#include "Math/RootFinder.h"
17
18#include "RConfigure.h"
19
20#ifndef MATH_NO_PLUGIN_MANAGER
21
22#include "TROOT.h"
23#include "TPluginManager.h"
24
25#else // case no plugin manager is available
26#ifdef R__HAS_MATHMORE
28#endif
29
30#endif
31
32#include <cassert>
33
34#include "Math/Error.h"
35
36namespace ROOT {
37namespace Math {
38
39
41 fSolver(nullptr)
42{
43 // constructor passing type (default is kBRENT)
45}
46
48{
49 // set method - Use the plug-in manager if method is implemented in MathMore
50 if ( type == RootFinder::kBRENT )
51 {
53 return true;
54 }
55
56#ifdef MATH_NO_PLUGIN_MANAGER // no PM available
57#ifdef R__HAS_MATHMORE
58
59 switch(type) {
60
61 case kGSL_BISECTION:
63 break;
64 case kGSL_FALSE_POS:
66 break;
67 case kGSL_BRENT:
69 break;
70 case kGSL_NEWTON:
72 break;
73 case kGSL_SECANT:
75 break;
76 case kGSL_STEFFENSON:
78 break;
79 default:
80 MATH_ERROR_MSG("RootFinder::SetMethod","RootFinderMethod type is not available in MathCore");
81 fSolver = 0;
82 return false;
83 break;
84 };
85
86#else
87 MATH_ERROR_MSG("RootFinder::SetMethod","RootFinderMethod type is not available in MathCore");
88 return false;
89#endif
90
91#else // case of using Plugin Manager
93 std::string stype;
94
95 switch(type) {
96
97 case kGSL_BISECTION:
98 stype = "Bisection";
99 break;
100 case kGSL_FALSE_POS:
101 stype = "FalsePos";
102 break;
103 case kGSL_BRENT:
104 stype = "Brent";
105 break;
106 case kGSL_NEWTON:
107 stype = "Newton";
108 break;
109 case kGSL_SECANT:
110 stype = "Secant";
111 break;
112 case kGSL_STEFFENSON:
113 stype = "Steffenson";
114 break;
115 default:
116 MATH_ERROR_MSG("RootFinder::SetMethod","RootFinderMethod type is not available in MathCore");
117 fSolver = nullptr;
118 return false;
119 break;
120 };
121
122 if ((h = gROOT->GetPluginManager()->FindHandler("ROOT::Math::IRootFinderMethod", stype.c_str() ))) {
123 if (h->LoadPlugin() == -1) {
124 MATH_ERROR_MSG("RootFinder::SetMethod","Error loading RootFinderMethod");
125 return false;
126 }
127
128 fSolver = reinterpret_cast<ROOT::Math::IRootFinderMethod *>( h->ExecPlugin(0) );
129 assert(fSolver != nullptr);
130 }
131 else {
132 MATH_ERROR_MSG("RootFinder::SetMethod","Error loading RootFinderMethod");
133 return false;
134 }
135
136#endif
137
138 return true;
139}
140
141
143{
144 // destructor
145 delete fSolver;
146}
147
148
149}
150}
#define MATH_ERROR_MSG(loc, str)
Definition Error.h:83
#define h(i)
Definition RSha256.hxx:106
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
#define gROOT
Definition TROOT.h:406
Class for finding the root of a one dimensional function using the Brent algorithm.
Interface for finding function roots of one-dimensional functions.
bool SetMethod(RootFinder::EType type=RootFinder::kBRENT)
RootFinder(RootFinder::EType type=RootFinder::kBRENT)
Construct a Root-Finder algorithm.
IRootFinderMethod * fSolver
Definition RootFinder.h:200
Roots::Bisection Bisection algorithm, simplest algorithm for bracketing the roots of a function,...
Brent-Dekker algorithm which combines an interpolation strategy with the bisection algorithm See the ...
False Position algorithm based on linear interpolation.
a Newton algorithm, which computes the derivative at each iteration See the GSL manual for more infor...
Secant algorithm, simplified version of Newton method, which does not require the derivative at every...
Steffenson method, providing the fastes convergence.
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...