Piecewise Constant Helper 3.
More...
#include <qle/models/piecewiseconstanthelper.hpp>
|
| PiecewiseConstantHelper3 (const Array &t1, const Array &t2, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint1=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint2=QuantLib::ext::make_shared< QuantLib::NoConstraint >()) |
|
| PiecewiseConstantHelper3 (const std::vector< Date > &dates1, const std::vector< Date > &dates2, const Handle< YieldTermStructure > &yts, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint1=QuantLib::ext::make_shared< QuantLib::NoConstraint >(), const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint2=QuantLib::ext::make_shared< QuantLib::NoConstraint >()) |
|
const Array & | t1 () const |
|
const Array & | t2 () const |
|
const Array & | tUnion () const |
|
const QuantLib::ext::shared_ptr< Parameter > | p1 () const |
|
const QuantLib::ext::shared_ptr< Parameter > | p2 () const |
|
void | update () const |
|
Real | y1 (const Time t) const |
|
Real | y2 (const Time t) const |
|
Real | int_y1_sqr_exp_2_int_y2 (const Time t) const |
| int_0^t y1^2(s) exp(2*int_0^s y2(u) du) ds More...
|
|
Real | direct1 (const Real x) const |
|
Real | inverse1 (const Real y) const |
|
Real | direct2 (const Real x) const |
|
Real | inverse2 (const Real y) const |
|
Piecewise Constant Helper 3.
Definition at line 127 of file piecewiseconstanthelper.hpp.
◆ PiecewiseConstantHelper3() [1/2]
PiecewiseConstantHelper3 |
( |
const Array & |
t1, |
|
|
const Array & |
t2, |
|
|
const QuantLib::ext::shared_ptr< QuantLib::Constraint > & |
constraint1 = QuantLib::ext::make_shared< QuantLib::NoConstraint >() , |
|
|
const QuantLib::ext::shared_ptr< QuantLib::Constraint > & |
constraint2 = QuantLib::ext::make_shared< QuantLib::NoConstraint >() |
|
) |
| |
◆ PiecewiseConstantHelper3() [2/2]
PiecewiseConstantHelper3 |
( |
const std::vector< Date > & |
dates1, |
|
|
const std::vector< Date > & |
dates2, |
|
|
const Handle< YieldTermStructure > & |
yts, |
|
|
const QuantLib::ext::shared_ptr< QuantLib::Constraint > & |
constraint1 = QuantLib::ext::make_shared< QuantLib::NoConstraint >() , |
|
|
const QuantLib::ext::shared_ptr< QuantLib::Constraint > & |
constraint2 = QuantLib::ext::make_shared< QuantLib::NoConstraint >() |
|
) |
| |
◆ t1()
const Array & t1 |
( |
| ) |
const |
◆ t2()
const Array & t2 |
( |
| ) |
const |
◆ tUnion()
const Array & tUnion |
( |
| ) |
const |
◆ p1()
const QuantLib::ext::shared_ptr< Parameter > p1 |
( |
| ) |
const |
◆ p2()
const QuantLib::ext::shared_ptr< Parameter > p2 |
( |
| ) |
const |
◆ update()
Definition at line 236 of file piecewiseconstanthelper.hpp.
236 {
237 std::vector<Real> tTmp(
t1_.begin(),
t1_.end());
238 tTmp.insert(tTmp.end(),
t2_.begin(),
t2_.end());
239 std::sort(tTmp.begin(), tTmp.end());
240 std::vector<Real>::const_iterator end =
241 std::unique(tTmp.begin(), tTmp.end(), [](const Real x, const Real y) { return QuantLib::close_enough(x, y); });
242 tTmp.resize(end - tTmp.begin());
243 tUnion_ = Array(tTmp.begin(), tTmp.end());
246 for (Size i = 0; i <
tUnion_.size() + 1; ++i) {
247
252 }
253 Real
sum = 0.0, sum2 = 0.0;
256 for (Size i = 0; i <
tUnion_.size(); ++i) {
257 Real t0 = (i == 0 ? 0.0 :
tUnion_[i - 1]);
260 Real b2Tmp = (i == 0 ? 0.0 :
b_[i - 1]);
263 } else {
267 }
269 }
270}
Real direct1(const Real x) const
Real direct2(const Real x) const
Real sum(const Cash &c, const Cash &d)
◆ y1()
Real y1 |
( |
const Time |
t | ) |
const |
◆ y2()
Real y2 |
( |
const Time |
t | ) |
const |
◆ int_y1_sqr_exp_2_int_y2()
Real int_y1_sqr_exp_2_int_y2 |
( |
const Time |
t | ) |
const |
int_0^t y1^2(s) exp(2*int_0^s y2(u) du) ds
Definition at line 330 of file piecewiseconstanthelper.hpp.
330 {
331 if (t < 0.0)
332 return 0.0;
334 Real res = 0.0;
335 if (i >= 1)
336 res +=
c_[std::min(i - 1,
c_.size() - 1)];
339 Real t0 = (i == 0 ? 0.0 :
tUnion_[i - 1]);
340 Real b2Tmp = (i == 0 ? 0.0 :
b_[i - 1]);
342 res += b * b * std::exp(2.0 * b2Tmp) * (t - t0);
343 } else {
344 res += b * b * (std::exp(2.0 * b2Tmp + 2.0 * a * (t - t0)) - std::exp(2.0 * b2Tmp)) / (2.0 * a);
345 }
346 return res;
347}
◆ direct1()
Real direct1 |
( |
const Real |
x | ) |
const |
◆ inverse1()
Real inverse1 |
( |
const Real |
y | ) |
const |
◆ direct2()
Real direct2 |
( |
const Real |
x | ) |
const |
◆ inverse2()
Real inverse2 |
( |
const Real |
y | ) |
const |
◆ zeroCutoff_
◆ t1_
◆ t2_
◆ tUnion_
◆ y1_
◆ y2_
◆ y1Union_
◆ y2Union_
◆ b_
◆ c_