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

#include <InterpolatingPolynomial.hh>

+ Inheritance diagram for Genfun::InterpolatingPolynomial:

Public Member Functions

 InterpolatingPolynomial ()
 
 InterpolatingPolynomial (const InterpolatingPolynomial &right)
 
virtual ~InterpolatingPolynomial ()
 
virtual double operator() (double argument) const override
 
virtual double operator() (const Argument &a) const override
 
void addPoint (double x, double y)
 
void getRange (double &min, double &max) const
 
- Public Member Functions inherited from Genfun::AbsFunction
 AbsFunction ()
 
 AbsFunction (const AbsFunction &right)
 
virtual ~AbsFunction ()
 
virtual unsigned int dimensionality () const
 
virtual double operator() (double argument) const =0
 
virtual double operator() (const Argument &argument) const =0
 
virtual AbsFunctionclone () const =0
 
virtual FunctionComposition operator() (const AbsFunction &f) const
 
virtual ParameterComposition operator() (const AbsParameter &p) const
 
Derivative derivative (const Variable &v) const
 
Derivative prime () const
 
virtual bool hasAnalyticDerivative () const
 
virtual Derivative partial (unsigned int) const
 

Detailed Description

Author

Definition at line 21 of file InterpolatingPolynomial.hh.

Constructor & Destructor Documentation

◆ InterpolatingPolynomial() [1/2]

Genfun::InterpolatingPolynomial::InterpolatingPolynomial ( )

Definition at line 13 of file InterpolatingPolynomial.cc.

◆ InterpolatingPolynomial() [2/2]

Genfun::InterpolatingPolynomial::InterpolatingPolynomial ( const InterpolatingPolynomial right)

Definition at line 17 of file InterpolatingPolynomial.cc.

18 :Genfun::AbsFunction(),xPoints(right.xPoints)
19 {}

◆ ~InterpolatingPolynomial()

Genfun::InterpolatingPolynomial::~InterpolatingPolynomial ( )
virtual

Definition at line 21 of file InterpolatingPolynomial.cc.

21 {
22 }

Member Function Documentation

◆ addPoint()

void Genfun::InterpolatingPolynomial::addPoint ( double  x,
double  y 
)

Definition at line 60 of file InterpolatingPolynomial.cc.

60 {
61 xPoints.push_back(std::make_pair(x,y));
62 }

◆ getRange()

void Genfun::InterpolatingPolynomial::getRange ( double min,
double max 
) const

Definition at line 64 of file InterpolatingPolynomial.cc.

64 {
65 min=DBL_MAX, max=-DBL_MAX;
66 for (unsigned int i=0;i<xPoints.size();i++) {
67 min = std::min(min,xPoints[i].first);
68 max = std::max(max,xPoints[i].first);
69 }
70 }

◆ operator()() [1/2]

virtual double Genfun::InterpolatingPolynomial::operator() ( const Argument a) const
inlineoverridevirtual

Implements Genfun::AbsFunction.

Definition at line 38 of file InterpolatingPolynomial.hh.

38{return operator() (a[0]);}
virtual double operator()(double argument) const override

◆ operator()() [2/2]

double Genfun::InterpolatingPolynomial::operator() ( double  argument) const
overridevirtual

Implements Genfun::AbsFunction.

Definition at line 24 of file InterpolatingPolynomial.cc.

24 {
25 double y=0.0;
26 double deltay=0; // also gives error;
27 double dif = fabs(x-xPoints[0].first),dift;
28 const unsigned int _K = (unsigned int)xPoints.size(),_KP=_K+1;
29 std::vector<double>c(_KP),d(_KP);
30 int ns=0;
31 for (unsigned int i=0;i<_K;i++) {
32 dift=fabs(x-xPoints[i].first);
33 if (dift<dif) {
34 ns=i;
35 dif=dift;
36 }
37 c[i]=d[i]=xPoints[i].second;
38 }
39 y = xPoints[ns--].second;
40 for (unsigned int m=0;m<_K-1;m++) {
41 for (unsigned int i=0;i<_K-m-1;i++) {
42 double ho = xPoints[i].first-x;
43 double hp= xPoints[i+m+1].first-x;
44 double w=c[i+1]-d[i];
45 double den=ho-hp;
46 if (den==0)
47 std::cerr
48 << "Error in polynomial extrapolation"
49 << std::endl;
50 den=w/den;
51 d[i]=hp*den;
52 c[i]=ho*den;
53 }
54 deltay = 2*(ns+1) < (int)(_K-m-1) ? c[ns+1]: d[ns--];
55 y += deltay;
56 }
57 return y;
58 }

Referenced by operator()().


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