1 #ifndef NPSTAT_ABSINTERVALQUADRATURE1D_HH_
2 #define NPSTAT_ABSINTERVALQUADRATURE1D_HH_
23 virtual unsigned npoints()
const = 0;
24 virtual void getAllAbscissae(
long double* absc,
unsigned len)
const = 0;
25 virtual void getAllWeights(
long double* weights,
unsigned len)
const = 0;
35 template <
class Functor>
37 const Functor& weight,
const long double left,
38 const long double right)
const
40 return weightedIntegrationPointsHlp<Functor,std::pair<double,double> >(
44 template <
class Functor>
45 inline std::vector<std::pair<long double,long double> > weightedIntegrationPointsLD(
46 const Functor& weight,
const long double left,
47 const long double right)
const
49 return weightedIntegrationPointsHlp<Functor,std::pair<long double,long double> >(
55 template <
class Functor,
class Pair>
56 inline std::vector<Pair> weightedIntegrationPointsHlp(
57 const Functor& weight,
const long double left,
58 const long double right)
const
60 const unsigned npt = this->npoints();
61 std::vector<long double> buf(npt*2U);
62 long double* absc = &buf[0];
63 long double* w = absc + npt;
64 this->getAllAbscissae(absc, npt);
65 this->getAllWeights(w, npt);
66 const long double midpoint = (left + right)/2.0L;
67 const long double unit = (right - left)/2.0L;
69 std::vector<Pair> result(npt);
70 for (
unsigned i=0; i<npt; ++i)
72 const long double x = midpoint + unit*absc[i];
73 result[i] = Pair(x, unit*w[i]*weight(x));
Definition: AbsIntervalQuadrature1D.hh:19
std::vector< std::pair< double, double > > weightedIntegrationPoints(const Functor &weight, const long double left, const long double right) const
Definition: AbsIntervalQuadrature1D.hh:36
Definition: AbsArrayProjector.hh:14