npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
GaussLegendreQuadrature2D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_GAUSSLEGENDREQUADRATURE2D_HH_
2 #define NPSTAT_GAUSSLEGENDREQUADRATURE2D_HH_
3 
4 /*!
5 // \file GaussLegendreQuadrature2D.hh
6 //
7 // \brief Tensor-product Gauss-Legendre quadratures in long double precision
8 // on rectangular regions
9 //
10 // Author: I. Volobouev
11 //
12 // October 2020
13 */
14 
15 #include <vector>
16 #include <utility>
17 
18 namespace npstat {
20  {
21  public:
22  /**
23  // The number of supported points in each dimension
24  // is the same as for the 1-d Gauss-Legendre quadrature
25  */
26  GaussLegendreQuadrature2D(unsigned npoints0, unsigned npoints1);
27 
28  /** Return the number of quadrature points in the given dimension */
29  unsigned npoints(unsigned dim) const;
30 
31  /** Perform the quadrature on the [a, b] x [c, d] rectangle */
32  template <class Functor>
33  long double integrate(const Functor& fcn,
34  long double a, long double b,
35  long double c, long double d) const;
36  private:
37  std::vector<long double> a0_;
38  std::vector<long double> w0_;
39  std::vector<long double> a1_;
40  std::vector<long double> w1_;
41  unsigned npoints0_;
42  unsigned npoints1_;
43  mutable std::vector<std::pair<long double, long double> > buf_;
44 
45 #ifdef SWIG
46  public:
47  template <class Functor>
48  inline double integrate2(const Functor& fcn,
49  const double a, const double b,
50  const double c, const double d) const
51  {
52  return integrate(fcn, a, b, c, d);
53  }
54 #endif // SWIG
55  };
56 }
57 
58 #include "npstat/nm/GaussLegendreQuadrature2D.icc"
59 
60 #endif // NPSTAT_GAUSSLEGENDREQUADRATURE2D_HH_
Definition: GaussLegendreQuadrature2D.hh:20
GaussLegendreQuadrature2D(unsigned npoints0, unsigned npoints1)
long double integrate(const Functor &fcn, long double a, long double b, long double c, long double d) const
unsigned npoints(unsigned dim) const
Definition: AbsArrayProjector.hh:14