CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Genfun::DefiniteIntegral Class Reference

#include <DefiniteIntegral.hh>

+ Inheritance diagram for Genfun::DefiniteIntegral:

Classes

class  Clockwork
 

Public Types

enum  Type { CLOSED , OPEN }
 

Public Member Functions

 DefiniteIntegral (double a, double b, Type=CLOSED)
 
 DefiniteIntegral (const DefiniteIntegral &)
 
DefiniteIntegraloperator= (const DefiniteIntegral &)
 
 ~DefiniteIntegral ()
 
virtual double operator[] (const AbsFunction &function) const
 
unsigned int numFunctionCalls () const
 
void setEpsilon (double eps)
 
void setMaxIter (unsigned int maxIter)
 
void setMinOrder (unsigned int order)
 
- Public Member Functions inherited from Genfun::AbsFunctional
 AbsFunctional ()
 
virtual ~AbsFunctional ()
 
virtual double operator[] (const AbsFunction &function) const =0
 

Detailed Description

Author

Definition at line 25 of file DefiniteIntegral.hh.

Member Enumeration Documentation

◆ Type

Constructor & Destructor Documentation

◆ DefiniteIntegral() [1/2]

Genfun::DefiniteIntegral::DefiniteIntegral ( double  a,
double  b,
Type  type = CLOSED 
)

Definition at line 119 of file DefiniteIntegral.cc.

119 :
120 c(new Clockwork()) {
121 c->a = a;
122 c->b = b;
123 c->type = type;
124 c->nFunctionCalls = 0;
125 c->MAXITER = type==OPEN ? 20 : 14;
126 c->EPS = 1.0E-6;
127 c->K = 5;
128 }

◆ DefiniteIntegral() [2/2]

Genfun::DefiniteIntegral::DefiniteIntegral ( const DefiniteIntegral right)

Definition at line 134 of file DefiniteIntegral.cc.

135 :AbsFunctional(right), c(new Clockwork(*right.c)) {
136 }

◆ ~DefiniteIntegral()

Genfun::DefiniteIntegral::~DefiniteIntegral ( )

Definition at line 130 of file DefiniteIntegral.cc.

130 {
131 delete c;
132 }

Member Function Documentation

◆ numFunctionCalls()

unsigned int Genfun::DefiniteIntegral::numFunctionCalls ( ) const

Definition at line 219 of file DefiniteIntegral.cc.

219 {
220 return c->nFunctionCalls;
221 }

◆ operator=()

DefiniteIntegral & Genfun::DefiniteIntegral::operator= ( const DefiniteIntegral right)

Definition at line 138 of file DefiniteIntegral.cc.

138 {
139 if (this!=&right) {
140 delete c;
141 c = new Clockwork(*right.c);
142 }
143 return *this;
144 }

◆ operator[]()

double Genfun::DefiniteIntegral::operator[] ( const AbsFunction function) const
virtual

Implements Genfun::AbsFunctional.

Definition at line 158 of file DefiniteIntegral.cc.

158 {
159
160 const Clockwork::QuadratureRule * rule = c->type==OPEN ?
161 (Clockwork::QuadratureRule *) new Clockwork::XtMidpointQuadratureRule() :
162 (Clockwork::QuadratureRule *) new Clockwork::TrapezoidQuadratureRule();
163 double xMult=rule->stepMultiplier();
164
165 c->nFunctionCalls=0;
166 std::vector<double> s(c->MAXITER+2),h(c->MAXITER+2);
167 h[1]=1.0;
168 for (unsigned int j=1;j<=c->MAXITER;j++) {
169 s[j]=rule->integrate(function, c->a, c->b, j);
170 c->nFunctionCalls=rule->numFunctionCalls();
171 if (j>=c->K) {
172 double ss(0.), dss(0.);
173 c->polint(h.begin()+j-c->K,s.begin()+j-c->K,0.0,ss, dss);
174 if (fabs(dss) <= c->EPS*fabs(ss)) {
175 delete rule;
176 return ss;
177 }
178 }
179 s[j+1]=s[j];
180 h[j+1]=h[j]/xMult/xMult;
181 }
182 delete rule;
183 throw std::runtime_error("DefiniteIntegral: too many steps. No convergence");
184 return 0.0; // Never get here.
185 }
void polint(std::vector< double >::iterator xArray, std::vector< double >::iterator yArray, double x, double &y, double &deltay) const

◆ setEpsilon()

void Genfun::DefiniteIntegral::setEpsilon ( double  eps)

Definition at line 146 of file DefiniteIntegral.cc.

146 {
147 c->EPS=eps;
148 }

◆ setMaxIter()

void Genfun::DefiniteIntegral::setMaxIter ( unsigned int  maxIter)

Definition at line 150 of file DefiniteIntegral.cc.

150 {
151 c->MAXITER=maxIter;
152 }

◆ setMinOrder()

void Genfun::DefiniteIntegral::setMinOrder ( unsigned int  order)

Definition at line 154 of file DefiniteIntegral.cc.

154 {
155 c->K=(minOrder+1)/2;
156 }

The documentation for this class was generated from the following files: