QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
jointstochasticprocess.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 Copyright (C) 2007, 2008 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file jointstochasticprocess.hpp
21 \brief multi model process for hybrid products
22*/
23
24#ifndef quantlib_joint_stochastic_process_hpp
25#define quantlib_joint_stochastic_process_hpp
26
27#include <ql/utilities/null.hpp>
29#include <vector>
30#include <map>
31
32namespace QuantLib {
33
35 public:
36 JointStochasticProcess(std::vector<ext::shared_ptr<StochasticProcess> > l,
38
39 Size size() const override;
40 Size factors() const override;
41
42 Array initialValues() const override;
43 Array drift(Time t, const Array& x) const override;
44 Array expectation(Time t0, const Array& x0, Time dt) const override;
45
46 Matrix diffusion(Time t, const Array& x) const override;
47 Matrix covariance(Time t0, const Array& x0, Time dt) const override;
48 Matrix stdDeviation(Time t0, const Array& x0, Time dt) const override;
49
50 Array apply(const Array& x0, const Array& dx) const override;
51 Array evolve(Time t0, const Array& x0, Time dt, const Array& dw) const override;
52
53 virtual void preEvolve(Time t0, const Array& x0,
54 Time dt, const Array& dw) const = 0;
55 virtual Array postEvolve(Time t0, const Array& x0,
56 Time dt, const Array& dw,
57 const Array& y0) const = 0;
58
59 virtual DiscountFactor numeraire(Time t, const Array& x) const = 0;
60 virtual bool correlationIsStateDependent() const = 0;
61 virtual Matrix crossModelCorrelation(Time t0, const Array& x0) const = 0;
62
63 const std::vector<ext::shared_ptr<StochasticProcess> > &
64 constituents() const;
65
66 void update() override;
67 Time time(const Date& date) const override;
68
69 protected:
70 std::vector<ext::shared_ptr<StochasticProcess> > l_;
71 Array slice(const Array& x, Size i) const;
72
73 private:
74 typedef
75 std::vector<ext::shared_ptr<StochasticProcess> >::const_iterator
77
78 typedef std::vector<ext::shared_ptr<StochasticProcess> >::iterator
80
82 std::vector<Size> vsize_, vfactors_;
83
84 struct CachingKey {
85 CachingKey(const Time t0, const Time dt)
86 : t0_(t0), dt_(dt) {}
87
88 bool operator<(const CachingKey& key) const {
89 return t0_ < key.t0_
90 || ( t0_ == key.t0_ && dt_ < key.dt_);
91 }
94 };
95
96 mutable std::map<CachingKey, Matrix> correlationCache_;
97 };
98
99}
100
101
102#endif
1-D array used in linear algebra.
Definition: array.hpp:52
Concrete date class.
Definition: date.hpp:125
std::vector< ext::shared_ptr< StochasticProcess > > l_
Array slice(const Array &x, Size i) const
virtual Matrix crossModelCorrelation(Time t0, const Array &x0) const =0
Array drift(Time t, const Array &x) const override
returns the drift part of the equation, i.e.,
Size size() const override
returns the number of dimensions of the stochastic process
Array evolve(Time t0, const Array &x0, Time dt, const Array &dw) const override
Matrix diffusion(Time t, const Array &x) const override
returns the diffusion part of the equation, i.e.
Time time(const Date &date) const override
Matrix stdDeviation(Time t0, const Array &x0, Time dt) const override
virtual DiscountFactor numeraire(Time t, const Array &x) const =0
std::map< CachingKey, Matrix > correlationCache_
virtual Array postEvolve(Time t0, const Array &x0, Time dt, const Array &dw, const Array &y0) const =0
virtual void preEvolve(Time t0, const Array &x0, Time dt, const Array &dw) const =0
virtual bool correlationIsStateDependent() const =0
Size factors() const override
returns the number of independent factors of the process
Matrix covariance(Time t0, const Array &x0, Time dt) const override
Array expectation(Time t0, const Array &x0, Time dt) const override
std::vector< ext::shared_ptr< StochasticProcess > >::iterator iterator
Array initialValues() const override
returns the initial values of the state variables
std::vector< ext::shared_ptr< StochasticProcess > >::const_iterator const_iterator
Array apply(const Array &x0, const Array &dx) const override
const std::vector< ext::shared_ptr< StochasticProcess > > & constituents() const
Matrix used in linear algebra.
Definition: matrix.hpp:41
template class providing a null value for a given type.
Definition: null.hpp:76
multi-dimensional stochastic process class.
const DefaultType & t
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
null values
stochastic processes