Presentation is loading. Please wait.

Presentation is loading. Please wait.

MathMore Lorenzo Moneta, Andràs Zsenei ROOT Workshop 30/9/2005.

Similar presentations


Presentation on theme: "MathMore Lorenzo Moneta, Andràs Zsenei ROOT Workshop 30/9/2005."— Presentation transcript:

1 MathMore Lorenzo Moneta, Andràs Zsenei ROOT Workshop 30/9/2005

2 30/09/2005ROOT2005 Workshop, Andràs Zsenei2 MathMore components  Special functions  Statistical functions  Generic interfaces  Derivation  Integration  Interpolation  Root finding  Chebyshev polynomials

3 30/09/2005ROOT2005 Workshop, Andràs Zsenei3 The Current Implementation  The relevant GSL code extracted into mathmore/src/gsl-xxx and compiled automatically  A GSL tar file is in CVS with the extracted code  Works on all supported platforms (thanks to Bertrand Bellenot for the Windows port)  Easily maintainable and updateable compared to direct copy of the algorithms into ROOT classes

4 30/09/2005ROOT2005 Workshop, Andràs Zsenei4 Special Functions  Defined in the N1687 Technical Report on Standard Library Extensions  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  Basic functions in mathcore:  Error functions, gamma functions  The less used and those that use GSL imple- mentation a re i n mathmore  Bessel functions, elliptic integrals, Legendre polynomials etc  Possibility to migrate functions between mathcore and mathmore transparently for the user

5 30/09/2005ROOT2005 Workshop, 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 30/09/2005ROOT2005 Workshop, Andràs Zsenei6 Mathematical Functions tests  New functions improve on the precision of TMath  Extensive tests of numerical accuracy, comparisons with other libraries (Mathematica, Nag) ROOT::Math::erfc and relative difference compared to Mathematica (  ≈ 10 -15) TMath::Erfc and relative difference compared to Mathematica (  ≈ 10 -7)

7 30/09/2005ROOT2005 Workshop, Andràs Zsenei7 Statistical Functions  Common functions used in statistics with a coherent naming scheme :  Probability density functions (pdf)  Cumulative distributions (lower tail and upper tail)  Inverse of cumulative distributions  Examples:  chisquared_pdf  chisquared_prob, chisquared_quant  chisquared_prob_inv, chisquared_quant_inv  Naming convention proposed for the C++ standard in N1668, but might change (to be followed closely)  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1069.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1069.pdf

8 30/09/2005ROOT2005 Workshop, Andràs Zsenei8 Statistical Functions Tests  =1.0  =2.0  =3.0  10 -16 Lognormal PDF (left) and its Relative Difference Compared to Mathematica (right)

9 30/09/2005ROOT2005 Workshop, Andràs Zsenei9 Function Interfaces

10 30/09/2005ROOT2005 Workshop, Andràs Zsenei10 Function Interface  Minimal interface for functions used by all the numerical algorithms: IGenFunction, ParamFunction, Polynomial (see previous presentations)  class WrappedFunction which wraps any C++ callable object (C free functions, functors, etc...)  Reviewed by C++ experts — several of the recommendations implemented

11 30/09/2005ROOT2005 Workshop, Andràs Zsenei11 Derivation  Adaptive central difference algorithm using a 5-point rule  Adaptive forward difference algorithm using a 4-point rule  Adaptive backward difference algorithm using a 4-point rule

12 30/09/2005ROOT2005 Workshop, Andràs Zsenei12 Derivation — an example of the overall design  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 x0 = 2; double result = der->EvalCentral(x0); double error = der->Error();

13 30/09/2005ROOT2005 Workshop, Andràs Zsenei13 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 x0 = 2; double result = der->EvalCentral(x0);

14 30/09/2005ROOT2005 Workshop, Andràs Zsenei14 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

15 30/09/2005ROOT2005 Workshop, Andràs Zsenei15 Integration Example // user provided free C function double myFunc ( double x) {… } // wrap the function ROOT::Math::WrappedFunction wFunc(myFunc); // create integrator and integrate ROOT::Math::Integrator ig(wFunc); Double result = ig.Integral(a, b); Double error = ig.Error();  WrappedFunction can be replaced with any IGenFunction in the Integrator

16 30/09/2005ROOT2005 Workshop, Andràs Zsenei16 Interpolation  Linear, polynomial, Akima and Akima periodic interpola- tions

17 30/09/2005ROOT2005 Workshop, Andràs Zsenei17 Root Finding  Root finding of one dimensional functions  Bracketing algorithms: bisection, false position, Brent-Dekker  Polishing algorithms (derivatives): Newton, secant, Steffenson

18 30/09/2005ROOT2005 Workshop, Andràs Zsenei18 Next Steps  Eliminate duplication  Other parts of the ROOT should use mathcore/mathmore  Moving functionality from TMath into mathcore/mathmore (TMath will remain for backward compatibility)  Implement incomplete gamma function in mathcore (for  2 )  A more detailed discussion is needed to finalize function interfaces (signatures)  Prototype version of TF1 using algorithms from mathcore and implementing function interface  Add algorithms for multi-dimensional functions  New additions according to user requests (ex. FFT)

19 30/09/2005ROOT2005 Workshop, Andràs Zsenei19 Conclusions  Mathmore is available in ROOT 5.04/00 ( --enable-mathmore switch in configure)  Works on all supported platforms  Documentation available at  http://seal.web.cern.ch/seal/MathLibs/MathMore-5_0_4/html/index.html http://seal.web.cern.ch/seal/MathLibs/MathMore-5_0_4/html/index.html

20 30/09/2005ROOT2005 Workshop, Andràs Zsenei20 References  Special and Random number C++ extension proposal  link to C++ extension draft  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  Statistical functions proposal to C++ standard  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1069.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1069.pdf  MathCore reference doc  http://seal.web.cern.ch/seal/MathLibs/MathCore-5_0_4/html http://seal.web.cern.ch/seal/MathLibs/MathCore-5_0_4/html  MathMore reference doc  http://seal.web.cern.ch/seal/MathLibs/MathMore-5_0_4/html http://seal.web.cern.ch/seal/MathLibs/MathMore-5_0_4/html  SEAL Math Web site  http:://cern.ch/mathlib http:://cern.ch/mathlib  New C++ Minuit Web site  http:://cern.ch/minuit http:://cern.ch/minuit


Download ppt "MathMore Lorenzo Moneta, Andràs Zsenei ROOT Workshop 30/9/2005."

Similar presentations


Ads by Google