31 "initialRates do not match");
38 "Evolution times do not match");
40 const Matrix& totalCovariance1
42 const Matrix& totalCovariance2
44 const std::vector<Time>& maturities =
47 std::vector<Volatility> result(totalCovariance1.
columns());
49 Real diff = totalCovariance1[i][i]-totalCovariance2[i][i];
50 result[i] = std::sqrt(diff/maturities[i]);
60 "initialRates do not match");
67 "Evolution times do not match");
69 "the index given is greater than the number of steps");
71 const std::vector<Time>& evolutionTimes
73 std::vector<Spread> result(evolutionTimes.size());
75 Time previousEvolutionTime = 0;
76 for (
Size i=0; i<evolutionTimes.size(); ++i) {
77 Time currentEvolutionTime = evolutionTimes[i];
78 Time dt = currentEvolutionTime - previousEvolutionTime;
81 Real diff = covariance1[index][index] - covariance2[index][index];
82 result[i] = std::sqrt(diff/dt);
83 previousEvolutionTime = currentEvolutionTime;
90 const std::vector<ext::shared_ptr<PiecewiseConstantVariance> >&
91 piecewiseConstantVariances) {
93 == piecewiseConstantVariances.front()->rateTimes(),
94 "correlations and volatilities intertave");
95 std::vector<Matrix> pseudoRoots;
96 const std::vector<Time>& rateTimes
97 = piecewiseConstantVariances.front()->rateTimes();
98 for (
Size i=1; i<rateTimes.size(); ++i) {
99 Time sqrtTau = std::sqrt(rateTimes[i]-rateTimes[i-1]);
100 const Matrix& correlations
103 for (
Size j=0; j<correlations.
rows(); ++j) {
105 = piecewiseConstantVariances[j]->volatility(i)*sqrtTau;
106 std::transform(correlations.
row_begin(j),
109 [=](
Real x) ->
Real { return x * volatility; });
111 pseudoRoots.push_back(pseudoRoot);
Market-model evolution description.
const std::vector< Time > & evolutionTimes() const
Size numberOfSteps() const
base class for market models
virtual const Matrix & covariance(Size i) const
virtual const Matrix & totalCovariance(Size endIndex) const
virtual const std::vector< Rate > & initialRates() const =0
virtual Size numberOfSteps() const =0
virtual const EvolutionDescription & evolution() const =0
Matrix used in linear algebra.
const_row_iterator row_begin(Size i) const
const_row_iterator row_end(Size i) const
virtual const Matrix & correlation(Size i) const
virtual const std::vector< Time > & times() const =0
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
std::vector< Matrix > coterminalSwapPseudoRoots(const PiecewiseConstantCorrelation &piecewiseConstantCorrelation, const std::vector< ext::shared_ptr< PiecewiseConstantVariance > > &piecewiseConstantVariances)
std::vector< Spread > rateInstVolDifferences(const MarketModel &marketModel1, const MarketModel &marketModel2, Size index)
std::vector< Volatility > rateVolDifferences(const MarketModel &marketModel1, const MarketModel &marketModel2)