QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ratepseudorootjacobian.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4
5 Copyright (C) 2008 Mark Joshi
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21
22#ifndef quantlib_rate_pseudo_root_hpp
23#define quantlib_rate_pseudo_root_hpp
24
25// to be removed using forward declaration
26
27
29
30/*! Classes for computing derivative of the map taking rates one step
31to the next with respect to a change in the pseudo-root. We do it both
32numerically and analytically to provide an easy test of the analytic method.
33This is useful for pathwise vegas.
34
35Evolution is log Euler.
36
37One is tested against the other in MarketModelTest::testPathwiseVegas
38*/
39
40namespace QuantLib
41{
42
44 {
45 public:
47 Size aliveIndex,
48 Size numeraire,
49 const std::vector<Time>& taus,
50 const std::vector<Matrix>& pseudoBumps,
51 const std::vector<Spread>& displacements);
52
53 void getBumps(const std::vector<Rate>& oldRates,
54 const std::vector<Real>& oneStepDFs, // redundant info but saves time to pass in since will have been needed elsewhere
55 const std::vector<Rate>& newRates, // redundant info but saves time to pass in since will have been needed elsewhere
56 const std::vector<Real>& gaussians,
57 Matrix& B); // B as in page 95 of the GG paper, rows should be number rates long, one row for bump
58
59 private:
60
61 //! this data is always the same
64 std::vector<Time> taus_;
65 std::vector<Matrix> pseudoBumped_;
66 std::vector<Spread> displacements_;
68 std::vector<LMMDriftCalculator> driftsComputers_;
70
71 //! workspace variables
72 std::vector<Real> drifts_;
73 std::vector<Real> bumpedRates_;
74
75 };
76
77
78
79
81 {
82 public:
83 RatePseudoRootJacobian(const Matrix& pseudoRoot,
84 Size aliveIndex,
85 Size numeraire,
86 const std::vector<Time>& taus,
87 const std::vector<Matrix>& pseudoBumps,
88 std::vector<Spread> displacements);
89
90 void getBumps(const std::vector<Rate>& oldRates,
91 const std::vector<Real>& oneStepDFs, // redundant info but saves time to pass in
92 // since will have been needed elsewhere
93 const std::vector<Rate>& newRates, // redundant info but saves time to pass in
94 // since will have been needed elsewhere
95 const std::vector<Real>& gaussians,
96 Matrix& B); // B as in page 95 of the GG paper, rows should be number rates
97 // long, one row for each bump
98
99 private:
100
101 //! this data does not change after construction
104 std::vector<Time> taus_;
105 std::vector<Matrix> pseudoBumps_;
106 std::vector<Spread> displacements_;
109
110 //! workspace variables
111
112 std::vector<Matrix> allDerivatives_;
113 // std::vector<Real> bumpedRates_;
115 std::vector<Real> ratios_;
116
117 };
118
119
121 {
122 public:
124 Size aliveIndex,
125 Size numeraire,
126 const std::vector<Time>& taus,
127 std::vector<Spread> displacements);
128
129 void getBumps(const std::vector<Rate>& oldRates,
130 const std::vector<Real>& oneStepDFs, // redundant info but saves time to pass in
131 // since will have been needed elsewhere
132 const std::vector<Rate>& newRates, // redundant info but saves time to pass in
133 // since will have been needed elsewhere
134 const std::vector<Real>& gaussians,
135 std::vector<Matrix>&
136 B); // one Matrix for each rate, the elements of the matrix are the
137 // derivatives of that rate with respect to each pseudo-root element
138
139 private:
140
141 //! this data does not change after construction
144 std::vector<Time> taus_;
145 std::vector<Matrix> pseudoBumps_;
146 std::vector<Spread> displacements_;
148
149 //! workspace
150
152 std::vector<Real> ratios_;
153
154 };
155
156}
157
158#endif
Matrix used in linear algebra.
Definition: matrix.hpp:41
Matrix pseudoRoot_
this data does not change after construction
void getBumps(const std::vector< Rate > &oldRates, const std::vector< Real > &oneStepDFs, const std::vector< Rate > &newRates, const std::vector< Real > &gaussians, std::vector< Matrix > &B)
Matrix pseudoRoot_
this data does not change after construction
std::vector< Matrix > allDerivatives_
workspace variables
void getBumps(const std::vector< Rate > &oldRates, const std::vector< Real > &oneStepDFs, const std::vector< Rate > &newRates, const std::vector< Real > &gaussians, Matrix &B)
Matrix pseudoRoot_
this data is always the same
void getBumps(const std::vector< Rate > &oldRates, const std::vector< Real > &oneStepDFs, const std::vector< Rate > &newRates, const std::vector< Real > &gaussians, Matrix &B)
std::vector< Real > drifts_
workspace variables
std::vector< LMMDriftCalculator > driftsComputers_
std::size_t Size
size of a container
Definition: types.hpp:58
Drift computation for Libor market model.
Definition: any.hpp:35