1 #ifndef NPSTAT_GAUSSLEGENDREQUADRATURE_HH_
2 #define NPSTAT_GAUSSLEGENDREQUADRATURE_HH_
29 enum {interval_quadrature = 1};
43 inline unsigned npoints()
const {
return npoints_;}
58 void getWeights(
long double* weights,
unsigned len)
const;
64 template <
typename FcnResult,
typename FcnArg>
66 long double a,
long double b)
const;
73 template <
typename FcnResult,
typename FcnArg>
75 long double a,
long double b,
76 unsigned nsplit)
const;
94 const long double* a_;
95 const long double* w_;
96 mutable std::vector<std::pair<long double, long double> > buf_;
101 inline std::vector<double> abscissae2()
const
103 return std::vector<double>(a_, a_+npoints_/2U);
106 inline std::vector<double> weights2()
const
108 return std::vector<double>(w_, w_+npoints_/2U);
111 inline std::vector<double> allabscissae2()
const
114 std::vector<double> abscissae(npoints_);
115 const unsigned halfpoints = npoints_/2;
116 for (
unsigned i=0; i<halfpoints; ++i)
117 abscissae[i] = -a_[halfpoints - 1U - i];
118 for (
unsigned i=halfpoints; i<npoints_; ++i)
119 abscissae[i] = a_[i - halfpoints];
123 inline std::vector<double> allweights2()
const
126 std::vector<double> weights(npoints_);
127 const unsigned halfpoints = npoints_/2;
128 for (
unsigned i=0; i<halfpoints; ++i)
129 weights[i] = w_[halfpoints - 1U - i];
130 for (
unsigned i=halfpoints; i<npoints_; ++i)
131 weights[i] = w_[i - halfpoints];
135 template <
typename FcnResult,
typename FcnArg>
136 inline double integrate2(
const Functor1<FcnResult,FcnArg>& fcn,
137 const double a,
const double b)
const
142 template <
typename FcnResult,
typename FcnArg>
143 inline double integrate2(
const Functor1<FcnResult,FcnArg>& fcn,
144 const double a,
const double b,
145 const unsigned nsplit)
const
153 #include "npstat/nm/GaussLegendreQuadrature.icc"
Base class for quadratures on the [-1, 1] interval.
Interface definitions and concrete simple functors for a variety of functor-based calculations.
Definition: AbsIntervalQuadrature1D.hh:19
Definition: GaussLegendreQuadrature.hh:27
static std::vector< unsigned > allowedNPonts()
long double integrate(const Functor1< FcnResult, FcnArg > &fcn, long double a, long double b) const
void getAbscissae(long double *abscissae, unsigned len) const
void getAllAbscissae(long double *abscissae, unsigned len) const
static bool isAllowed(unsigned npoints)
long double integrate(const Functor1< FcnResult, FcnArg > &fcn, long double a, long double b, unsigned nsplit) const
void getAllWeights(long double *weights, unsigned len) const
GaussLegendreQuadrature(unsigned npoints)
void getWeights(long double *weights, unsigned len) const
unsigned npoints() const
Definition: GaussLegendreQuadrature.hh:43
static unsigned minimalExactRule(unsigned polyDegree)
Definition: AbsArrayProjector.hh:14
Definition: SimpleFunctors.hh:58