32 : times_(times), vols_(vols), reversions_(reversions),
33 T_(
T), revZero_(reversions.size(), false) {
36 "number of volatilities ("
37 << vols.
size() <<
") compared to number of times ("
40 "number of reversions ("
41 << vols.
size() <<
") compared to number of times ("
42 <<
times_.
size() <<
" must be bigger by one, or exactly "
43 "1 reversion must be given");
44 for (
int i = 0; i < ((int)times.
size()) - 1; i++)
45 QL_REQUIRE(times[i] < times[i + 1],
"times must be increasing ("
46 << times[i] <<
"@" << i <<
" , "
47 << times[i + 1] <<
"@" << i + 1
69 const Time dt)
const {
71 std::pair<Real, Real> key;
72 key = std::make_pair(w,
t);
73 std::map<std::pair<Real, Real>,
Real>::const_iterator k =
cache1_.find(key);
75 return xw * (k->second);
81 cache1_.insert(std::make_pair(key, res2));
86 const Time dt)
const {
90 std::pair<Real, Real> key;
91 key = std::make_pair(w,
t);
92 std::map<std::pair<Real, Real>,
Real>::const_iterator k =
102 for (
int l = 0; l <= k - 1; l++) {
107 (1.0 - exp(-2.0 *
rev(l) *
113 for (
int j = l + 1; j <= k - 1; j++)
153 cache2a_.insert(std::make_pair(key, res));
159 const Time dt)
const {
163 std::pair<Real, Real> key;
164 key = std::make_pair(w,
t);
165 std::map<std::pair<Real, Real>,
Real>::const_iterator k =
187 for (
int j = k + 1; j <= l - 1; j++)
228 res += -
vol(k) *
vol(k) * res2;
231 cache2b_.insert(std::make_pair(key, res));
240 std::pair<Real, Real> key;
241 key = std::make_pair(w,
t);
242 std::map<std::pair<Real, Real>,
Real>::const_iterator k =
cache3_.find(key);
252 : (1.0 - exp(2.0 *
rev(k) *
262 cache3_.insert(std::make_pair(key, res));
269 std::map<Real, Real>::const_iterator k =
cache4_.find(key);
281 (1.0 - exp(-2.0 *
rev(i) *
286 cache4_.insert(std::make_pair(key, res));
291 std::pair<Real, Real> key;
292 key = std::make_pair(w,
t);
293 std::map<std::pair<Real, Real>,
Real>::const_iterator k =
cache5_.find(key);
310 cache5_.insert(std::make_pair(key, res));
322 return static_cast<int>(
333 const Real floor)
const {
1-D array used in linear algebra.
const_iterator end() const
Size size() const
dimension of the array
const_iterator begin() const
template class providing a null value for a given type.
int upperIndex(Time t) const
Real cappedTime(Size index, Real cap=Null< Real >()) const
std::vector< bool > revZero_
GsrProcessCore(const Array ×, const Array &vols, const Array &reversions, Real T=60.0)
Real expectation_x0dep_part(Time w, Real xw, Time dt) const
std::map< Real, Real > cache4_
Real expectation_rn_part(Time w, Time dt) const
Real flooredTime(Size index, Real floor=Null< Real >()) const
std::map< std::pair< Real, Real >, Real > cache2a_
Real expectation_tf_part(Time w, Time dt) const
Real vol(Size index) const
const Array & reversions_
std::map< std::pair< Real, Real >, Real > cache1_
bool revZero(Size index) const
std::map< std::pair< Real, Real >, Real > cache2b_
Real time2(Size index) const
std::map< std::pair< Real, Real >, Real > cache3_
int lowerIndex(Time t) const
Real G(Time t, Time w) const
std::map< std::pair< Real, Real >, Real > cache5_
Real variance(Time w, Time dt) const
Real rev(Size index) const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_MIN_POSITIVE_REAL
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Core computations for the gsr process in risk neutral and T-forward measure.