CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

CLHEP/GenericFunctions/DefiniteIntegral.hh
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: DefiniteIntegral.hh,v 1.2 2003/09/06 14:04:13 boudreau Exp $
00003 //-------------------------------------------------------------//
00004 //                                                             //
00005 // This functional returns the definite integral of a function //
00006 // between lower bound and upper bound b.                      //
00007 //                                                             //
00008 //-------------------------------------------------------------//
00009 
00010 #ifndef _DefiniteIntegral_h_
00011 #define _DefiniteIntegral_h_
00012 #include "CLHEP/GenericFunctions/AbsFunctional.hh"
00013 
00014 namespace Genfun {
00015 
00020   class DefiniteIntegral:public AbsFunctional {
00021 
00022   public:
00023   
00024     // Constructor:
00025     DefiniteIntegral(double a, double b);
00026 
00027     // Destructor:
00028     ~DefiniteIntegral();
00029 
00030     // Take the definite integral of a function between the bounds:
00031     virtual double operator [] (const AbsFunction & function) const;
00032 
00033     // Retrieve the number of function calls for the last operation:
00034     unsigned int numFunctionCalls() const;
00035 
00036   private:
00037 
00038     // Trapezoid calculation:
00039     double _trapzd( const AbsFunction & function, double a, double b, int j) const;
00040 
00041     // Polynomial interpolation:
00042     void _polint(double *xArray, double *yArray, double x, double & y, double & deltay) const;
00043 
00044     double _a;                          // lower limit of integration
00045     double _b;                          // upper limit of integration
00046 
00047     static const int _K;                // Order
00048     static const int _KP;               // Const dim of certain arrays.
00049   
00050     // buffered value for _trapzd calculation:
00051     mutable double _sTrap;
00052     mutable unsigned int _nFunctionCalls;
00053   };
00054 } // namespace Genfun
00055 #endif