Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Attributes | List of all members
PiecewiseConstantHelper1 Class Reference

Piecewise Constant Helper 1. More...

#include <qle/models/piecewiseconstanthelper.hpp>

+ Inheritance diagram for PiecewiseConstantHelper1:
+ Collaboration diagram for PiecewiseConstantHelper1:

Public Member Functions

 PiecewiseConstantHelper1 (const Array &t, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
 
 PiecewiseConstantHelper1 (const std::vector< Date > &dates, const Handle< YieldTermStructure > &yts, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &constraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
 
const Array & t () const
 
const QuantLib::ext::shared_ptr< Parameter > p () const
 
void update () const
 
Real y (const Time t) const
 
Real int_y_sqr (const Time t) const
 int_0^t y^2(s) ds More...
 
Real direct (const Real x) const
 
Real inverse (const Real y) const
 

Protected Attributes

const Array t_
 
const QuantLib::ext::shared_ptr< PseudoParametery_
 

Private Attributes

std::vector< Real > b_
 

Detailed Description

Piecewise Constant Helper 1.

Definition at line 40 of file piecewiseconstanthelper.hpp.

Constructor & Destructor Documentation

◆ PiecewiseConstantHelper1() [1/2]

PiecewiseConstantHelper1 ( const Array &  t,
const QuantLib::ext::shared_ptr< QuantLib::Constraint > &  constraint = QuantLib::ext::make_shared< QuantLib::NoConstraint >() 
)

◆ PiecewiseConstantHelper1() [2/2]

PiecewiseConstantHelper1 ( const std::vector< Date > &  dates,
const Handle< YieldTermStructure > &  yts,
const QuantLib::ext::shared_ptr< QuantLib::Constraint > &  constraint = QuantLib::ext::make_shared< QuantLib::NoConstraint >() 
)

Member Function Documentation

◆ t()

const Array & t ( ) const

Definition at line 172 of file piecewiseconstanthelper.hpp.

+ Here is the caller graph for this function:

◆ p()

const QuantLib::ext::shared_ptr< Parameter > p ( ) const

Definition at line 174 of file piecewiseconstanthelper.hpp.

174{ return y_; }
const QuantLib::ext::shared_ptr< PseudoParameter > y_
+ Here is the caller graph for this function:

◆ update()

void update ( ) const

Definition at line 180 of file piecewiseconstanthelper.hpp.

180 {
181 Real sum = 0.0;
182 b_.resize(t_.size());
183 for (Size i = 0; i < t_.size(); ++i) {
184 sum += direct(y_->params()[i]) * direct(y_->params()[i]) * (t_[i] - (i == 0 ? 0.0 : t_[i - 1]));
185 b_[i] = sum;
186 }
187}
Real sum(const Cash &c, const Cash &d)
Definition: bondbasket.cpp:107
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ y()

Real y ( const Time  t) const

this returns the transformed value

Definition at line 272 of file piecewiseconstanthelper.hpp.

272 {
273 return direct(QL_PIECEWISE_FUNCTION(t_, y_->params(), t));
274}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ int_y_sqr()

Real int_y_sqr ( const Time  t) const

int_0^t y^2(s) ds

Definition at line 288 of file piecewiseconstanthelper.hpp.

288 {
289 if (t < 0.0)
290 return 0.0;
291 Size i = std::upper_bound(t_.begin(), t_.end(), t) - t_.begin();
292 Real res = 0.0;
293 if (i >= 1)
294 res += b_[std::min(i - 1, b_.size() - 1)];
295 Real a = direct(y_->params()[std::min(i, y_->size() - 1)]);
296 res += a * a * (t - (i == 0 ? 0.0 : t_[i - 1]));
297 return res;
298}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ direct()

Real direct ( const Real  x) const

Definition at line 176 of file piecewiseconstanthelper.hpp.

176{ return x * x; }
+ Here is the caller graph for this function:

◆ inverse()

Real inverse ( const Real  y) const

Definition at line 178 of file piecewiseconstanthelper.hpp.

178{ return std::sqrt(y); }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ t_

const Array t_
protected

Definition at line 59 of file piecewiseconstanthelper.hpp.

◆ y_

const QuantLib::ext::shared_ptr<PseudoParameter> y_
protected

y are the raw values in the sense of parameter transformation

Definition at line 61 of file piecewiseconstanthelper.hpp.

◆ b_

std::vector<Real> b_
mutableprivate

Definition at line 64 of file piecewiseconstanthelper.hpp.