43 for (i=1; i <
n; ++i) {
45 e[i-1] = std::sqrt(orthPoly.
beta(i));
59 w_[i] = mu_0*ev[0][i]*ev[0][i] / orthPoly.
w(
x_[i]);
65 const std::vector<Size>& ns,
66 const std::function<ext::shared_ptr<GaussianQuadrature>(
Size)>& genQuad)
67 : weights_(
std::accumulate(ns.begin(), ns.end(),
Size(1),
std::multiplies<>()), 1.0),
68 x_(weights_.size(),
Array(ns.size())) {
70 const Size m = ns.size();
73 std::vector<Size> spacing(m);
75 std::partial_sum(ns.begin(), ns.end()-1, spacing.begin()+1, std::multiplies<>());
77 std::map<Size, Array> n2weights, n2x;
78 for (
auto order: ns) {
79 if (n2x.find(order) == n2x.end()) {
80 const ext::shared_ptr<GaussianQuadrature> quad = genQuad(order);
81 n2x[order] = quad->x();
82 n2weights[order] = quad->weights();
86 for (
Size i=0; i <
n; ++i) {
87 for (
Size j=0; j < m; ++j) {
88 const Size order = ns[j];
89 const Size nx = (i / spacing[j]) % ns[j];
91 x_[i][j] = n2x[order][nx];
100 for (
Size i=0; i <
n; ++i)
109 template <
class Integration>
113 integration_(ext::make_shared<Integration>(
n))
116 template <
class Integration>
120 const Real c1 = 0.5*(
b-a);
121 const Real c2 = 0.5*(a+
b);
123 return c1*integration_->operator()(
124 [c1, c2,
f](
Real x) {
return f(c1*x+c2);});
1-D array used in linear algebra.
orthogonal polynomial for Gaussian quadratures
virtual Real mu_0() const =0
virtual Real alpha(Size i) const =0
virtual Real beta(Size i) const =0
virtual Real w(Real x) const =0
GaussianQuadrature(Size n, const GaussianOrthogonalPolynomial &p)
Matrix used in linear algebra.
Real operator()(const std::function< Real(Array)> &f) const
MultiDimGaussianIntegration(const std::vector< Size > &ns, const std::function< ext::shared_ptr< GaussianQuadrature >(Size)> &genQuad)
template class providing a null value for a given type.
static const Real x20[10]
static const Real w20[10]
tridiag. QR eigen decomposition with explicite shift aka Wilkinson
@ OnlyFirstRowEigenVector
const Matrix & eigenvectors() const
const Array & eigenvalues() const
GaussianQuadratureIntegrator(Size n)
Real integrate(const std::function< Real(Real)> &f, Real a, Real b) const override
#define QL_FAIL(message)
throw an error (possibly with file and line information)
std::function< Real(Real)> b
Integral of a 1-dimensional function using the Gauss quadratures.
std::size_t Size
size of a container
Eigenvalues/eigenvectors of a real symmetric matrix.
tridiag. QR eigen decompositions with implicit shift