| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2005 Klaus Spanderen |
| 5 | Copyright (C) 2005 StatPro Italia srl |
| 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 | /*! \file stochasticprocessarray.hpp |
| 22 | \brief Array of correlated 1-D stochastic processes |
| 23 | */ |
| 24 | |
| 25 | #ifndef quantlib_stochastic_process_array_hpp |
| 26 | #define quantlib_stochastic_process_array_hpp |
| 27 | |
| 28 | #include <ql/stochasticprocess.hpp> |
| 29 | #include <vector> |
| 30 | |
| 31 | namespace QuantLib { |
| 32 | |
| 33 | //! %Array of correlated 1-D stochastic processes |
| 34 | /*! \ingroup processes */ |
| 35 | class StochasticProcessArray : public StochasticProcess { |
| 36 | public: |
| 37 | StochasticProcessArray( |
| 38 | const std::vector<ext::shared_ptr<StochasticProcess1D> >&, |
| 39 | const Matrix& correlation); |
| 40 | // stochastic process interface |
| 41 | Size size() const override; |
| 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 | Time time(const Date&) const override; |
| 54 | // inspectors |
| 55 | const ext::shared_ptr<StochasticProcess1D>& process(Size i) const; |
| 56 | Matrix correlation() const; |
| 57 | protected: |
| 58 | std::vector<ext::shared_ptr<StochasticProcess1D> > processes_; |
| 59 | Matrix sqrtCorrelation_; |
| 60 | }; |
| 61 | |
| 62 | } |
| 63 | |
| 64 | |
| 65 | #endif |
| 66 | |