30 : times_(times), vols_(vols), reversions_(reversions),
31 T_(
T), revZero_(reversions.size(), false) {
34 "number of volatilities ("
35 << vols.
size() <<
") compared to number of times ("
38 "number of reversions ("
39 << vols.
size() <<
") compared to number of times ("
40 <<
times_.
size() <<
" must be bigger by one, or exactly "
41 "1 reversion must be given");
42 for (
int i = 0; i < ((int)times.
size()) - 1; i++)
43 QL_REQUIRE(times[i] < times[i + 1],
"times must be increasing ("
44 << times[i] <<
"@" << i <<
" , "
45 << times[i + 1] <<
"@" << i + 1
67 const Time dt)
const {
69 std::pair<Real, Real> key;
70 key = std::make_pair(w,
t);
73 return xw * (k->second);
79 cache1_.insert(std::make_pair(key, res2));
84 const Time dt)
const {
88 std::pair<Real, Real> key;
89 key = std::make_pair(w,
t);
100 for (
int l = 0; l <= k - 1; l++) {
105 (1.0 - exp(-2.0 *
rev(l) *
111 for (
int j = l + 1; j <= k - 1; j++)
151 cache2a_.insert(std::make_pair(key, res));
157 const Time dt)
const {
161 std::pair<Real, Real> key;
162 key = std::make_pair(w,
t);
185 for (
int j = k + 1; j <= l - 1; j++)
226 res += -
vol(k) *
vol(k) * res2;
229 cache2b_.insert(std::make_pair(key, res));
238 std::pair<Real, Real> key;
239 key = std::make_pair(w,
t);
250 : (1.0 - exp(2.0 *
rev(k) *
260 cache3_.insert(std::make_pair(key, res));
279 (1.0 - exp(-2.0 *
rev(i) *
284 cache4_.insert(std::make_pair(key, res));
289 std::pair<Real, Real> key;
290 key = std::make_pair(w,
t);
308 cache5_.insert(std::make_pair(key, res));
320 return static_cast<int>(
331 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.