|
||||
File indexing completed on 2025-01-18 10:10:16
0001 // @(#)root/mathcore:$Id$ 0002 // Authors: David Gonzalez Maline 01/2008 0003 0004 /********************************************************************** 0005 * * 0006 * Copyright (c) 2006 , LCG ROOT MathLib Team * 0007 * * 0008 * * 0009 **********************************************************************/ 0010 0011 // Header file for GaussIntegrator 0012 // 0013 // Created by: David Gonzalez Maline : Wed Jan 16 2008 0014 // 0015 0016 #ifndef ROOT_Math_GaussLegendreIntegrator 0017 #define ROOT_Math_GaussLegendreIntegrator 0018 0019 0020 #include "Math/GaussIntegrator.h" 0021 0022 0023 namespace ROOT { 0024 namespace Math { 0025 0026 //___________________________________________________________________________________________ 0027 /** 0028 User class for performing function integration. 0029 0030 It will use the Gauss-Legendre Method for function integration in a given interval. 0031 This class is implemented from TF1::Integral(). 0032 0033 @ingroup Integration 0034 0035 */ 0036 0037 class GaussLegendreIntegrator: public GaussIntegrator { 0038 public: 0039 0040 /** Basic constructor of GaussLegendreIntegrator. 0041 \@param num Number of desired points to calculate the integration. 0042 \@param eps Desired relative error. 0043 */ 0044 GaussLegendreIntegrator(int num = 10 ,double eps=1e-12); 0045 0046 /** Default Destructor */ 0047 ~GaussLegendreIntegrator() override; 0048 0049 /** Set the number of points used in the calculation of the 0050 integral */ 0051 void SetNumberPoints(int num); 0052 0053 /** Set the desired relative Error. */ 0054 void SetRelTolerance (double) override; 0055 0056 /** This method is not implemented. */ 0057 void SetAbsTolerance (double) override; 0058 0059 0060 /** Returns the arrays x and w containing the abscissa and weight of 0061 the Gauss-Legendre n-point quadrature formula. 0062 0063 Gauss-Legendre: W(x)=1 -1<x<1 0064 (j+1)P_{j+1} = (2j+1)xP_j-jP_{j-1} 0065 */ 0066 void GetWeightVectors(double *x, double *w) const; 0067 0068 int GetNumberPoints() const { return fNum; } 0069 0070 /** 0071 return number of function evaluations in calculating the integral 0072 This is equivalent to the number of points 0073 */ 0074 int NEval() const override { return fNum; } 0075 0076 0077 /// get the option used for the integration 0078 ROOT::Math::IntegratorOneDimOptions Options() const override; 0079 0080 // set the options 0081 void SetOptions(const ROOT::Math::IntegratorOneDimOptions & opt) override; 0082 0083 private: 0084 0085 /** 0086 Integration surrogate method. Return integral of passed function in interval [a,b] 0087 Reimplement method of GaussIntegrator using CalcGaussLegendreSamplingPoints 0088 */ 0089 double DoIntegral (double a, double b, const IGenFunction* func) override; 0090 0091 /** 0092 Type: unsafe but fast interface filling the arrays x and w (static method) 0093 0094 Given the number of sampling points this routine fills the arrays x and w 0095 of length num, containing the abscissa and weight of the Gauss-Legendre 0096 n-point quadrature formula. 0097 0098 Gauss-Legendre: W(x)=1 -1<x<1 0099 (j+1)P_{j+1} = (2j+1)xP_j-jP_{j-1} 0100 0101 num is the number of sampling points (>0) 0102 x and w are arrays of size num 0103 eps is the relative precision 0104 0105 If num<=0 or eps<=0 no action is done. 0106 0107 Reference: Numerical Recipes in C, Second Edition 0108 */ 0109 void CalcGaussLegendreSamplingPoints(); 0110 0111 0112 protected: 0113 int fNum; ///< Number of points used in the estimation of the integral. 0114 double* fX; ///< Abscisa of the points used. 0115 double* fW; ///< Weights of the points used. 0116 0117 }; 0118 0119 } // end namespace Math 0120 0121 } // end namespace ROOT 0122 0123 #endif /* ROOT_Math_GaussLegendreIntegrator */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |