npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
DiscreteBernsteinPoly1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_DISCRETEBERNSTEINPOLY1D_HH_
2 #define NPSTAT_DISCRETEBERNSTEINPOLY1D_HH_
3 
4 /*!
5 // \file DiscreteBernsteinPoly1D.hh
6 //
7 // \brief Discrete Bernstein polynomials in one dimension
8 //
9 // Author: I. Volobouev
10 //
11 // June 2013
12 */
13 
14 #include <vector>
15 
17 
18 namespace npstat {
20  {
21  public:
22  DiscreteBernsteinPoly1D(unsigned degree, unsigned gridLength);
23 
24  //@{
25  /** A simple inspector of object properties */
26  inline unsigned gridLength() const {return gridLength_;}
27  inline unsigned degree() const {return degree_;}
28  //@}
29 
30  /** Return the value of one of the polynomials for the given cell */
31  double poly(unsigned polyNumber, unsigned gridIndex) const;
32 
33  /** Return the average derivative for the given cell */
34  double derivative(unsigned polyNumber, unsigned gridIndex) const;
35 
36  private:
38 
39  std::vector<double> lookupTable_;
40  std::vector<double> deriTable_;
41  unsigned degree_;
42  unsigned gridLength_;
43  };
44 
45  /**
46  // Extrapolation of Bernstein polynomials to non-integer degrees.
47  // Works significantly slower than the integer version.
48  */
50  {
51  public:
52  DiscreteBeta1D(double effectiveDegree, unsigned gridLength);
53 
54  //@{
55  /** A simple inspector of object properties */
56  inline unsigned gridLength() const {return gridLength_;}
57  inline double degree() const {return degree_;}
58  //@}
59 
60  /** Return the value of the function for the given cell */
61  double poly(double effectivePolyNumber, unsigned gridIndex) const;
62 
63  /** Return the average derivative for the given cell */
64  double derivative(double effectivePolyNumber, unsigned gridIndex) const;
65 
66  private:
68 
69  long double getNorm(double polyNumber) const;
70 
72  long double loggamma_;
73  long double gamma_;
74  long double step_;
75  mutable long double lastNorm_;
76  mutable double lastEffPolyNumber_;
77  double degree_;
78  unsigned gridLength_;
79  };
80 }
81 
82 #endif // NPSTAT_DISCRETEBERNSTEINPOLY1D_HH_
Gauss-Legendre quadratures in long double precision.
Definition: DiscreteBernsteinPoly1D.hh:20
double poly(unsigned polyNumber, unsigned gridIndex) const
unsigned gridLength() const
Definition: DiscreteBernsteinPoly1D.hh:26
double derivative(unsigned polyNumber, unsigned gridIndex) const
Definition: DiscreteBernsteinPoly1D.hh:50
unsigned gridLength() const
Definition: DiscreteBernsteinPoly1D.hh:56
double derivative(double effectivePolyNumber, unsigned gridIndex) const
double poly(double effectivePolyNumber, unsigned gridIndex) const
Definition: GaussLegendreQuadrature.hh:27
Definition: AbsArrayProjector.hh:14