/src/quantlib/ql/methods/montecarlo/multipath.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl |
5 | | Copyright (C) 2003, 2004, 2005, 2006 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 | | <https://www.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 multipath.hpp |
22 | | \brief Correlated multiple asset paths |
23 | | */ |
24 | | |
25 | | #ifndef quantlib_montecarlo_multi_path_hpp |
26 | | #define quantlib_montecarlo_multi_path_hpp |
27 | | |
28 | | #include <ql/methods/montecarlo/path.hpp> |
29 | | #include <utility> |
30 | | |
31 | | namespace QuantLib { |
32 | | |
33 | | //! Correlated multiple asset paths |
34 | | /*! MultiPath contains the list of paths for each asset, i.e., |
35 | | multipath[j] is the path followed by the j-th asset. |
36 | | |
37 | | \ingroup mcarlo |
38 | | */ |
39 | | class MultiPath { |
40 | | public: |
41 | | MultiPath() = default; |
42 | | MultiPath(Size nAsset, |
43 | | const TimeGrid& timeGrid); |
44 | | MultiPath(std::vector<Path> multiPath); |
45 | | //! \name inspectors |
46 | | //@{ |
47 | 0 | Size assetNumber() const { return multiPath_.size(); } |
48 | 0 | Size pathSize() const { return multiPath_[0].length(); } |
49 | | //@} |
50 | | //! \name read/write access to components |
51 | | //@{ |
52 | 0 | const Path& operator[](Size j) const { return multiPath_[j]; } |
53 | 0 | const Path& at(Size j) const { return multiPath_.at(j); } |
54 | 0 | Path& operator[](Size j) { return multiPath_[j]; } |
55 | 0 | Path& at(Size j) { return multiPath_.at(j); } |
56 | | //@} |
57 | | private: |
58 | | std::vector<Path> multiPath_; |
59 | | }; |
60 | | |
61 | | |
62 | | // inline definitions |
63 | | |
64 | | inline MultiPath::MultiPath(Size nAsset, const TimeGrid& timeGrid) |
65 | | : multiPath_(nAsset,Path(timeGrid)) { |
66 | | QL_REQUIRE(nAsset > 0, "number of asset must be positive"); |
67 | | } |
68 | | |
69 | | inline MultiPath::MultiPath(std::vector<Path> multiPath) : multiPath_(std::move(multiPath)) {} |
70 | | } |
71 | | |
72 | | |
73 | | #endif |