Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
irhwstateprocess.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21namespace QuantExt {
22
23Array IrHwStateProcess::initialValues() const { return Array(size(), 0.0); }
24
25Array IrHwStateProcess::drift(Time t, const Array& s) const {
26 Array ones(parametrization_->n(), 1.0);
27 Array x(s.begin(), std::next(s.begin(), parametrization_->n()));
28 Array drift_x = parametrization_->y(t) * ones - parametrization_->kappa(t) * x;
30 return drift_x;
31 Array drift_int_x = x;
32 Array result(2 * parametrization_->n());
33 std::copy(drift_x.begin(), drift_x.end(), result.begin());
34 std::copy(drift_int_x.begin(), drift_int_x.end(), std::next(result.begin(), parametrization_->n()));
35 return result;
36}
37
38Matrix IrHwStateProcess::diffusion(Time t, const Array& s) const {
39 Matrix res(size(), factors(), 0.0);
40 for (Size i = 0; i < parametrization_->n(); ++i) {
41 for (Size j = 0; j < res.columns(); ++j) {
42 res(i, j) = parametrization_->sigma_x(t)(j, i);
43 }
44 }
45 // the rest of the diffusion rows (if present for the aux state) is zero
46 return res;
47}
48
49} // namespace QuantExt
Matrix diffusion(Time t, const Array &s) const override
Size size() const override
Array drift(Time t, const Array &s) const override
Size factors() const override
QuantLib::ext::shared_ptr< IrHwParametrization > parametrization_
Array initialValues() const override
ir hw model state process