24#ifndef quantlib_moment_based_gaussian_polynomial_hpp
25#define quantlib_moment_based_gaussian_polynomial_hpp
47 template <
class mp_real>
65 mutable std::vector<mp_real>
b_,
c_;
66 mutable std::vector<std::vector<mp_real> >
z_;
69 template <
class mp_real>
inline
71 : z_(1,
std::vector<mp_real>()) {}
73 template <
class mp_real>
inline
75 if (k == -1)
return mp_real(0.0);
78 const Integer cols = z_[0].size();
82 z_[l].resize(i+1, std::numeric_limits<mp_real>::quiet_NaN());
85 z_.resize(k+1, std::vector<mp_real>(
86 z_[0].size(), std::numeric_limits<mp_real>::quiet_NaN()));
89 if (std::isnan(z_[k][i])) {
93 const mp_real tmp = z(k-1, i+1)
94 - alpha_(k-1)*z(k-1, i) - beta_(k-1)*z(k-2, i);
102 template <
class mp_real>
inline
106 b_.resize(u+1, std::numeric_limits<mp_real>::quiet_NaN());
108 if (std::isnan(
b_[u])) {
114 -z(iu-1, iu)/z(iu-1, iu-1) + z(iu, iu+1)/z(iu, iu);
121 template <
class mp_real>
inline
127 c_.resize(u+1, std::numeric_limits<mp_real>::quiet_NaN());
129 if (std::isnan(
c_[u])) {
131 const mp_real tmp = z(iu, iu) / z(iu-1, iu-1);
142 template <
class mp_real>
inline
144 return alpha_(u).template convert_to<Real>();
152 template <
class mp_real>
inline
154 mp_real
b = beta_(u);
155 return b.template convert_to<Real>();
160 const Real m0 = moment(0);
166 template <
class mp_real>
inline
168 return moment(0).template convert_to<Real>();
orthogonal polynomial for Gaussian quadratures
virtual mp_real moment(Size i) const =0
std::vector< std::vector< mp_real > > z_
Real mu_0() const override
Real beta(Size i) const override
MomentBasedGaussianPolynomial()
Real alpha(Size i) const override
std::vector< mp_real > b_
mp_real alpha_(Size i) const
mp_real z(Integer k, Integer i) const
std::vector< mp_real > c_
mp_real beta_(Size i) const
floating-point comparisons
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
ext::function< Real(Real)> b
orthogonal polynomials for gaussian quadratures
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
bool close_enough(const Quantity &m1, const Quantity &m2, Size n)