Download presentation
Presentation is loading. Please wait.
Published byAdam Jennings Modified over 9 years ago
1
MathMore Lorenzo Moneta, Andràs Zsenei ROOT Meeting 19/8/2005
2
19/8/2005ROOT meeting, Andràs Zsenei2 MathMore components Special functions (extension of MathCore) Statistical functions (extension of MathCore) Derivation Integration Interpolation Root finding 1 dimensional minimization
3
19/8/2005ROOT meeting, Andràs Zsenei3 The Current Implementation The relevant GSL code extracted into mathmore/src/gsl-xxx and compiled automatically (mathmore/Module.mk) Easily maintainable and updateable compared to direct copy of the algorithms into ROOT classes
4
19/8/2005ROOT meeting, Andràs Zsenei4 Special Functions Those functions from the N1687 Technical Report on Standard Library Extensions that use GSL implementa- tion ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1687.pdf ) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1687.pdf For example: Bessel Functions Elliptic Integrals Legendre Polynomials, etc
5
19/8/2005ROOT meeting, Andràs Zsenei5 Special Functions cont’d Free functions following the C++ standard’s naming convention (N1687) Trivial use: root [0] gSystem->Load("libMathMore.so"); root [1] ROOT::Math::cyl_bessel_i(1.2, 2.4) (double)2.05567401212170076e+00
6
19/8/2005ROOT meeting, Andràs Zsenei6 Statistical Functions Cumulative Distribution Functions (CDF) of those distributions from MathCore which were missing: Chi-square, T-distribution, etc The inverses of the CDF-s Free functions callable in a trivial way Naming convention in N1668, but might change (following up…) http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1069.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1069.pdf
7
19/8/2005ROOT meeting, Andràs Zsenei7 Function Interface Minimal interface for functions used by all the nu- merical algorithms: IGenFunction, ParamFunction, Polynomial (see previous presentations) It would be nice but not necessary if TF1 would implement this interface class WrappedFunction which wraps any C++ callable object (C free functions, functors, etc...) Reviewed by CMS — several of the recommendations implemented Still a few questions: Gradients: interface or feature testing NVI (Non-Virtual Interface)
8
19/8/2005ROOT meeting, Andràs Zsenei8 Derivation — an example of the overall design Class Derivator which defines the user interface (constructors, member functions) and has an instance of GSLDerivator Class GSLDerivator which calls the appropri- ate GSL functions Both GSLDerivator.h and GSLDerivator.cxx are in mathmore/src so that implementa- tion details do not pollute ROOT header files
9
19/8/2005ROOT meeting, Andràs Zsenei9 Derivation — an example of the overall design, cont’d Usage with function inheriting from IGenFunction: ROOT::Math::Polynomial *f1 = new ROOT::Math::Polynomial(2); … ROOT::Math::Derivator *der = new ROOT::Math::Derivator(*f1); double step = 1E-8; double x0 = 2; double result = der->EvalCentral(x0, step); double error = der->Error();
10
19/8/2005ROOT meeting, Andràs Zsenei10 Derivation — an example of the overall design, cont’d Usage with a function pointer: double myfunc ( double x, void * ) { return std::pow( x, 1.5); } ROOT::Math::Derivator *der = new ROOT::Math::Derivator(myfunc); double step = 1E-8; double x0 = 2; double result = der->EvalCentral(x0, step);
11
19/8/2005ROOT meeting, Andràs Zsenei11 Derivation — an example of the overall design, cont’d Usage with modified TF1 (or any other callable implementing operator() ): TF1 *fun1 = new TF1("fun1","x*x+3*x",0,10); ROOT::Math::Derivator *der = new ROOT::Math::Derivator(ROOT::Math::WrappedFunction (*fun1)); double step = 1E-8; double x0 = 2; double result = der->EvalCentral( x0, step);
12
19/8/2005ROOT meeting, Andràs Zsenei12 Derivation — an example of the overall design, cont’d Straightforward to add the functionality into TF1’s Derivative() so that it is trans-parent to the old user (disadvantage: cre-ates a Derivator object for each call) If performance is a major issue there is always the possibility to create the object oriented way as shown previously + use function pointers
13
19/8/2005ROOT meeting, Andràs Zsenei13 Integration Non-adaptive, adaptive and adaptive singular (i.e. taking into account singularities) integration Different Gauss-Konrod rules can be selected Possibility to use infinite and semi- infinite ranges
14
19/8/2005ROOT meeting, Andràs Zsenei14 Interpolation Linear, polynomial, Akima and Akima periodic interpola- tions
15
19/8/2005ROOT meeting, Andràs Zsenei15 Root Finding Root finding of one dimensional functions Bracketing algorithms: bisection, false position, Brent-Dekker Polishing algorithms (derivatives): Newton, secant, Steffenson
16
19/8/2005ROOT meeting, Andràs Zsenei16 Minimization in 1 D 1 dimensional minimization for cases where Minuit or Fumili would be too much overhead Golden section algorithm Brent algorithm
17
19/8/2005ROOT meeting, Andràs Zsenei17 In progress — Implementation type How can we select the various implementations (GSL, original ROOT, Cernlib, etc..)? An additional constructor for class Derivator which takes implementation type so that Derivator constructs an instance of worker class according to implementation chosen (i.e. GSL) Have also a default implementation (for example used by TF1) which would allow to move Derivator.h into MathCore Introduce a class MathSelector which manages centrally all the default implementations for the numerical algorithms; PluginManager would be convenient but not standalone
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.