20#include <ql/legacy/libormarketmodels/lfmcovarparam.hpp>
21#include <ql/math/integrals/kronrodintegral.hpp>
25 class LfmCovarianceParameterization::Var_Helper {
27 Var_Helper(
const LfmCovarianceParameterization* param,
Size i,
Size j);
32 const LfmCovarianceParameterization* param_;
35 LfmCovarianceParameterization::Var_Helper::Var_Helper(
36 const LfmCovarianceParameterization* param,
38 : i_(i), j_(j), param_(param) {}
40 Real LfmCovarianceParameterization::Var_Helper::operator()(Real t)
const {
41 const Matrix m = param_->diffusion(t);
43 return std::inner_product(m.row_begin(i_), m.row_end(i_),
44 m.row_begin(j_),
Real(0.0));
48 Matrix sigma = this->diffusion(t, x);
53 Matrix LfmCovarianceParameterization::integratedCovariance(
Time t,
const Array& x)
const {
58 QL_REQUIRE(x.
empty(),
"can not handle given x here");
60 Matrix tmp(size_, size_,0.0);
62 for (
Size i=0; i<size_; ++i) {
63 for (
Size j=0; j<=i;++j) {
64 Var_Helper helper(
this, i, j);
66 for (
Size k=0; k < 64; ++k) {
67 tmp[i][j]+=integrator(helper, k*t/64.,(k+1)*t/64.);
1-D array used in linear algebra.
bool empty() const
whether the array is empty
Integral of a 1-dimensional function using the Gauss-Kronrod methods.
Matrix used in linear algebra.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Matrix transpose(const Matrix &m)