Math More Lorenzo Moneta Andrs Zsenei ROOT Meeting

  • Slides: 17
Download presentation
Math. More Lorenzo Moneta, Andràs Zsenei ROOT Meeting 19/8/2005 ROOT meeting, Andràs Zsenei

Math. More Lorenzo Moneta, Andràs Zsenei ROOT Meeting 19/8/2005 ROOT meeting, Andràs Zsenei

Math. More components Special functions (extension of Math. Core) Statistical functions (extension of Math.

Math. More components Special functions (extension of Math. Core) Statistical functions (extension of Math. Core) Derivation Integration Interpolation Root finding 1 dimensional minimization 19/8/2005 ROOT meeting, Andràs Zsenei 2

The Current Implementation The relevant GSL code extracted into mathmore/src/gsl-xxx and compiled automatically (mathmore/Module.

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 19/8/2005 ROOT meeting, Andràs Zsenei 3

Special Functions Those functions from the N 1687 Technical Report on Standard Library Extensions

Special Functions Those functions from the N 1687 Technical Report on Standard Library Extensions that use GSL implementation (http: //www. open-std. org/jtc 1/sc 22/wg 21/docs/papers/2004/n 1687. pdf) For example: Bessel Functions Elliptic Integrals Legendre Polynomials, etc 19/8/2005 ROOT meeting, Andràs Zsenei 4

Special Functions cont’d Free functions following the C++ standard’s naming convention (N 1687) Trivial

Special Functions cont’d Free functions following the C++ standard’s naming convention (N 1687) Trivial use: root [0] g. System->Load("lib. Math. More. so"); root [1] ROOT: : Math: : cyl_bessel_i(1. 2, 2. 4) (double)2. 05567401212170076 e+00 19/8/2005 ROOT meeting, Andràs Zsenei 5

Statistical Functions Cumulative Distribution Functions (CDF) of those distributions from Math. Core which were

Statistical Functions Cumulative Distribution Functions (CDF) of those distributions from Math. Core which were missing: Chi-square, T-distribution, etc The inverses of the CDF-s Free functions callable in a trivial way Naming convention in N 1668, but might change (following up…) http: //www. open-std. org/jtc 1/sc 22/wg 14/www/docs/n 1069. pdf 19/8/2005 ROOT meeting, Andràs Zsenei 6

Function Interface Minimal interface for functions used by all the nu- merical algorithms: IGen.

Function Interface Minimal interface for functions used by all the nu- merical algorithms: IGen. Function, Param. Function, Polynomial (see previous presentations) It would be nice but not necessary if TF 1 would implement this interface class Wrapped. Function<T> 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) 19/8/2005 ROOT meeting, Andràs Zsenei 7

Derivation — an example of the overall design Class Derivator which defines the user

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 appropriate GSL functions Both GSLDerivator. h and GSLDerivator. cxx are in mathmore/src so that implementation details do not pollute ROOT header files 19/8/2005 ROOT meeting, Andràs Zsenei 8

Derivation — an example of the overall design, cont’d Usage with function inheriting from

Derivation — an example of the overall design, cont’d Usage with function inheriting from IGen. Function: ROOT: : Math: : Polynomial *f 1 = new ROOT: : Math: : Polynomial(2); … ROOT: : Math: : Derivator *der = new ROOT: : Math: : Derivator(*f 1); double step = 1 E-8; double x 0 = 2; double result = der->Eval. Central(x 0, step); double error = der->Error(); 19/8/2005 ROOT meeting, Andràs Zsenei 9

Derivation — an example of the overall design, cont’d Usage with a function pointer:

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 = 1 E-8; double x 0 = 2; double result = der->Eval. Central(x 0, step); 19/8/2005 ROOT meeting, Andràs Zsenei 10

Derivation — an example of the overall design, cont’d Usage with modified TF 1

Derivation — an example of the overall design, cont’d Usage with modified TF 1 (or any other callable implementing operator() ): TF 1 *fun 1 = new TF 1("fun 1", "x*x+3*x", 0, 10); ROOT: : Math: : Derivator *der = new ROOT: : Math: : Derivator(ROOT: : Math: : Wrapped. Function<TF 1>(*fun 1)); double step = 1 E-8; double x 0 = 2; double result = der->Eval. Central( x 0, step); 19/8/2005 ROOT meeting, Andràs Zsenei 11

Derivation — an example of the overall design, cont’d Straightforward to add the functionality

Derivation — an example of the overall design, cont’d Straightforward to add the functionality into TF 1’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 19/8/2005 ROOT meeting, Andràs Zsenei 12

Integration Non-adaptive, adaptive and adaptive singular (i. e. taking into account singularities) integration Different

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 semiinfinite ranges 19/8/2005 ROOT meeting, Andràs Zsenei 13

Interpolation Linear, polynomial, Akima and Akima periodic interpolations 19/8/2005 ROOT meeting, Andràs Zsenei 14

Interpolation Linear, polynomial, Akima and Akima periodic interpolations 19/8/2005 ROOT meeting, Andràs Zsenei 14

Root Finding Root finding of one dimensional functions Bracketing algorithms: bisection, false position, Brent-Dekker

Root Finding Root finding of one dimensional functions Bracketing algorithms: bisection, false position, Brent-Dekker Polishing algorithms (derivatives): Newton, secant, Steffenson 19/8/2005 ROOT meeting, Andràs Zsenei 15

Minimization in 1 D 1 dimensional minimization for cases where Minuit or Fumili would

Minimization in 1 D 1 dimensional minimization for cases where Minuit or Fumili would be too much overhead Golden section algorithm Brent algorithm 19/8/2005 ROOT meeting, Andràs Zsenei 16

In progress — Implementation type How can we select the various implementations (GSL, original

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 TF 1) which would allow to move Derivator. h into Math. Core Introduce a class Math. Selector which manages centrally all the default implementations for the numerical algorithms; Plugin. Manager would be convenient but not standalone 19/8/2005 ROOT meeting, Andràs Zsenei 17