39 const Real
sx,
const Size nx);
45 std::vector<Real>
stateGrid(
const Real t)
const;
48 template <
typename ValueType = Real>
49 std::vector<ValueType>
rollback(
const std::vector<ValueType>& v,
const Real t1,
const Real t0,
50 const ValueType zero = ValueType(0.0))
const;
53 const QuantLib::ext::shared_ptr<LinearGaussMarkovModel>&
model()
const {
return model_; }
56 QuantLib::ext::shared_ptr<LinearGaussMarkovModel>
model_;
64template <
typename ValueType>
66 const ValueType zero)
const {
67 if (QuantLib::close_enough(t0, t1))
69 QL_REQUIRE(t0 < t1,
"LgmConvolutionSolver::rollback(): t0 (" << t0 <<
") < t1 (" << t1 <<
") required.");
70 Real sigma = std::sqrt(
model_->parametrization()->zeta(t1));
71 Real dx = sigma /
static_cast<Real
>(
nx_);
72 if (QuantLib::close_enough(t0, 0.0)) {
74 ValueType value(zero);
75 for (
int i = 0; i <= 2 *
my_; i++) {
77 Real kp =
y_[i] * sigma / dx +
mx_;
79 int kk = int(floor(kp));
84 (kk < 0 ? v[0] : (kk + 1 > 2 *
mx_ ? v[2 *
mx_] : (kp - kk) * v[kk + 1] + (1.0 + kk - kp) * v[kk]));
86 return std::vector<ValueType>(2 *
mx_ + 1, value);
88 std::vector<ValueType> value(2 *
mx_ + 1, zero);
90 Real std = std::sqrt(
model_->parametrization()->zeta(t1) -
model_->parametrization()->zeta(t0));
91 Real dx2 = std::sqrt(
model_->parametrization()->zeta(t0)) /
static_cast<Real
>(
nx_);
92 for (
int k = 0; k <= 2 *
mx_; k++) {
93 for (
int i = 0; i <= 2 *
my_; i++) {
95 Real kp = (dx2 * (k -
mx_) +
y_[i] * std) / dx +
mx_;
97 int kk = int(floor(kp));
102 (kk < 0 ? v[0] : (kk + 1 > 2 *
mx_ ? v[2 *
mx_] : (kp - kk) * v[kk + 1] + (1.0 + kk - kp) * v[kk]));
Numerical convolution solver for the LGM model.
std::vector< ValueType > rollback(const std::vector< ValueType > &v, const Real t1, const Real t0, const ValueType zero=ValueType(0.0)) const
const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > & model() const
std::vector< Real > stateGrid(const Real t) const
QuantLib::ext::shared_ptr< LinearGaussMarkovModel > model_
JY INF index sigma component.