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

GenericFunctions/DefiniteIntegral.hh
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: DefiniteIntegral.hh,v 1.2 2003/09/06 14:04:13 boudreau Exp $
3 //-------------------------------------------------------------//
4 // //
5 // This functional returns the definite integral of a function //
6 // between lower bound and upper bound b. //
7 // //
8 //-------------------------------------------------------------//
9 
10 #ifndef _DefiniteIntegral_h_
11 #define _DefiniteIntegral_h_
13 
14 namespace Genfun {
15 
20  class DefiniteIntegral:public AbsFunctional {
21 
22  public:
23 
24  // Constructor:
25  DefiniteIntegral(double a, double b);
26 
27  // Destructor:
29 
30  // Take the definite integral of a function between the bounds:
31  virtual double operator [] (const AbsFunction & function) const;
32 
33  // Retrieve the number of function calls for the last operation:
34  unsigned int numFunctionCalls() const;
35 
36  private:
37 
38  // Trapezoid calculation:
39  double _trapzd( const AbsFunction & function, double a, double b, int j) const;
40 
41  // Polynomial interpolation:
42  void _polint(double *xArray, double *yArray, double x, double & y, double & deltay) const;
43 
44  double _a; // lower limit of integration
45  double _b; // upper limit of integration
46 
47  static const int _K; // Order
48  static const int _KP; // Const dim of certain arrays.
49 
50  // buffered value for _trapzd calculation:
51  mutable double _sTrap;
52  mutable unsigned int _nFunctionCalls;
53  };
54 } // namespace Genfun
55 #endif