20#ifndef quantlib_math_multidimquadrature_hpp
21#define quantlib_math_multidimquadrature_hpp
30#ifndef QL_PATCH_SOLARIS
61 std::vector<Real> term =
f(
x_[i]);
62 std::for_each(term.begin(), term.end(),
63 [&](
Real x) ->
Real { return x * w_[i]; });
64 std::vector<Real> sum = term;
66 for (i--; i >= 0; --i) {
69 std::transform(term.begin(), term.end(), sum.begin(),
98 template<
class RetType_T>
100 const std::vector<Real>& arg)>&
f)
const
102 return integrate<RetType_T>(
f);
111 template<
class RetType_T>
113 const std::vector<Real>& v1)>&
f)
const;
128 template<Size levelSpawn>
131 [&](ext::function<
Real (
const std::vector<Real>&)>
f,
Real x){
132 return scalarIntegrator<levelSpawn>(
f, x);
135 [&](
const ext::function<std::vector<Real>(
const std::vector<Real>&)>&
f,
Real x){
136 return vectorIntegratorVR<levelSpawn>(
f, x);
144 template <
int intgDepth>
146 const ext::function<
Real (
const std::vector<Real>& arg1)>&
f,
147 const Real mFctr)
const
153 template <
int intgDepth>
155 const ext::function<std::vector<Real>(
const std::vector<Real>& arg1)>&
f,
156 const Real mFctr)
const
172 ext::function<
Real (ext::function<
Real (
173 const std::vector<Real>& varg2)> f1,
176 ext::function<std::vector<Real> (
const ext::function<std::vector<Real>(
177 const std::vector<Real>& vvarg2)>& vf1,
190 const ext::function<
Real (
const std::vector<Real>& v1)>&
f)
const
198 inline Real GaussianQuadMultidimIntegrator::integrate<Real>(
199 const ext::function<
Real (
const std::vector<Real>& v1)>&
f)
const
210 inline std::vector<Real> GaussianQuadMultidimIntegrator::integrate<std::vector<Real>>(
211 const ext::function<std::vector<Real> (
const std::vector<Real>& v1)>&
f)
const
213 return integralV_([&](
Real x){
return integrationEntriesVR_[dimension_-1](ext::cref(
f), x); });
218 inline Real GaussianQuadMultidimIntegrator::scalarIntegrator<1>(
219 const ext::function<
Real (
const std::vector<Real>& arg1)>&
f,
220 const Real mFctr)
const
228 inline std::vector<Real>
229 GaussianQuadMultidimIntegrator::vectorIntegratorVR<1>(
230 const ext::function<std::vector<Real> (
const std::vector<Real>& arg1)>&
f,
231 const Real mFctr)
const
239 inline void GaussianQuadMultidimIntegrator::spawnFcts<1>()
const {
241 Real x) {
return scalarIntegrator<1>(
f, x); };
243 [&](
const ext::function<std::vector<Real>(
const std::vector<Real>&)>&
f,
Real x) {
244 return vectorIntegratorVR<1>(
f, x);
generalized Gauss-Hermite integration
VectorIntegrator(Size n, Real mu=0.0)
std::vector< Real > operator()(const F &f) const
Integrates a vector or scalar function of vector domain.
std::vector< ext::function< Real(ext::function< Real(const std::vector< Real > &varg2)> f1, const Real r3)> > integrationEntries_
Buffer to allow acces to integrations. We do not know at which.
RetType_T operator()(const ext::function< RetType_T(const std::vector< Real > &arg)> &f) const
Integrates function f over .
std::vector< Real > varBuffer_
Real scalarIntegrator(const ext::function< Real(const std::vector< Real > &arg1)> &f, const Real mFctr) const
static const Size maxDimensions_
RetType_T integrate(const ext::function< RetType_T(const std::vector< Real > &v1)> &f) const
void spawnFcts() const
Recursive template methods to statically generate (at this.
Size order() const
Integration quadrature order.
std::vector< ext::function< std::vector< Real >(const ext::function< std::vector< Real >(const std::vector< Real > &vvarg2)> &vf1, const Real vr3)> integrationEntriesVR_
GaussHermiteIntegration integral_
The actual integrators.
VectorIntegrator integralV_
std::vector< Real > vectorIntegratorVR(const ext::function< std::vector< Real >(const std::vector< Real > &arg1)> &f, const Real mFctr) const
Maps function, bind and cref to either the boost or std implementation.
Integral of a 1-dimensional function using the Gauss quadratures.
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
Global definitions and compiler switches.