1 / 17

MathMore

This ROOT meeting discusses the MathMore components, including extensions for special and statistical functions, derivation, integration, interpolation, root finding, and 1-dimensional minimization. The implementation uses GSL code extracted into MathMore, making it easily maintainable and updateable. Examples of special functions and statistical functions are provided, along with a discussion on function interface and derivation design. The meeting also covers integration, interpolation, root finding, and minimization techniques.

Download Presentation

MathMore

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MathMore Lorenzo Moneta, Andràs Zsenei ROOT Meeting 19/8/2005

  2. MathMore components • Special functions (extension of MathCore) • Statistical functions (extension of MathCore) • Derivation • Integration • Interpolation • Root finding • 1 dimensional minimization ROOT meeting, Andràs Zsenei

  3. 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 ROOT meeting, Andràs Zsenei

  4. 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) • For example: • Bessel Functions • Elliptic Integrals • Legendre Polynomials, etc ROOT meeting, Andràs Zsenei

  5. 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 ROOT meeting, Andràs Zsenei

  6. 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 ROOT meeting, Andràs Zsenei

  7. 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<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) ROOT meeting, Andràs Zsenei

  8. 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 ROOT meeting, Andràs Zsenei

  9. 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(); ROOT meeting, Andràs Zsenei

  10. 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); ROOT meeting, Andràs Zsenei

  11. 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<TF1>(*fun1)); double step = 1E-8; double x0 = 2; double result = der->EvalCentral( x0, step); ROOT meeting, Andràs Zsenei

  12. 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 ROOT meeting, Andràs Zsenei

  13. 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 ROOT meeting, Andràs Zsenei

  14. Interpolation • Linear, polynomial, Akima and Akima periodic interpola-tions ROOT meeting, Andràs Zsenei

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

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

  17. 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 ROOT meeting, Andràs Zsenei

More Related