24#ifndef quantext_piecewiselinear_irlgm1f_parametrization_hpp
25#define quantext_piecewiselinear_irlgm1f_parametrization_hpp
51 const Array& hTimes,
const Array& h,
const std::string&
name = std::string(),
52 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& alphaConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>(),
53 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& hConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>());
56 const Array&
alpha,
const std::vector<Date>& hDates,
const Array& h,
const std::string&
name = std::string(),
57 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& alphaConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>(),
58 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& hConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>());
60 Real
zeta(
const Time t)
const override;
61 Real
H(
const Time t)
const override;
62 Real
alpha(
const Time t)
const override;
63 Real
kappa(
const Time t)
const override;
64 Real
Hprime(
const Time t)
const override;
65 Real
Hprime2(
const Time t)
const override;
67 const QuantLib::ext::shared_ptr<Parameter>
parameter(
const Size)
const override;
68 void update()
const override;
71 Real
direct(
const Size i,
const Real x)
const override;
72 Real
inverse(
const Size j,
const Real y)
const override;
82 const Currency& currency,
const Handle<TS>& termStructure,
const Array& alphaTimes,
const Array& alpha,
83 const Array& hTimes,
const Array& h,
const std::string& name,
84 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& alphaConstraint,
85 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& hConstraint)
93 const Currency& currency,
const Handle<TS>& termStructure,
const std::vector<Date>& alphaDates,
const Array& alpha,
94 const std::vector<Date>& hDates,
const Array& h,
const std::string& name,
95 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& alphaConstraint,
96 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& hConstraint)
103 QL_REQUIRE(helper1().t().size() + 1 == alpha.size(),
104 "alpha size (" << alpha.size() <<
") inconsistent to times size (" << helper1().t().size() <<
")");
105 QL_REQUIRE(helper2().t().size() + 1 == h.size(),
106 "h size (" << h.size() <<
") inconsistent to times size (" << helper1().t().size() <<
")");
108 for (Size i = 0; i < helper1().p()->size(); ++i) {
109 helper1().p()->setParam(i,
inverse(0, alpha[i]));
111 for (Size i = 0; i < helper2().p()->size(); ++i) {
112 helper2().p()->setParam(i,
inverse(1, h[i]));
120 return i == 0 ? helper1().direct(x) : helper2().direct(x);
124 return i == 0 ? helper1().inverse(y) : helper2().inverse(y);
128 return helper1().int_y_sqr(t) / (this->scaling_ * this->scaling_);
132 return this->scaling_ * helper2().int_y_sqr(t) + this->shift_;
136 return helper1().y(t) / this->scaling_;
144 return this->scaling_ * helper2().y(t);
158 QL_REQUIRE(i < 2,
"parameter " << i <<
" does not exist, only have 0..1");
160 return helper1().t();
162 return helper2().t();
168 QL_REQUIRE(i < 2,
"parameter " << i <<
" does not exist, only have 0..1");
170 return helper1().p();
172 return helper2().p();
void update() const override
const Handle< TS > termStructure() const
Lgm 1f Piecewise Linear Parametrization.
Real zeta(const Time t) const override
Real kappa(const Time t) const override
Real Hprime(const Time t) const override
Lgm1fPiecewiseLinearParametrization(const Currency ¤cy, const Handle< TS > &termStructure, const Array &alphaTimes, const Array &alpha, const Array &hTimes, const Array &h, const std::string &name=std::string(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &alphaConstraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &hConstraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
void update() const override
Real alpha(const Time t) const override
Real H(const Time t) const override
void initialize(const Array &alpha, const Array &h)
Real direct(const Size i, const Real x) const override
Real inverse(const Size j, const Real y) const override
const Array & parameterTimes(const Size) const override
const QuantLib::ext::shared_ptr< Parameter > parameter(const Size) const override
Real Hprime2(const Time t) const override
const std::string & name() const
virtual const Currency & currency() const
Piecewise Constant Helper 11.
Interest Rate Linear Gaussian Markov 1 factor parametrization.
QuantLib::SparseMatrix inverse(QuantLib::SparseMatrix m)
Lgm1fPiecewiseLinearParametrization< YieldTermStructure > IrLgm1fPiecewiseLinearParametrization
helper classes for piecewise constant parametrizations