QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
multipath.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) 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 <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 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
29#include <utility>
30
31namespace 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 Size assetNumber() const { return multiPath_.size(); }
48 Size pathSize() const { return multiPath_[0].length(); }
49 //@}
50 //! \name read/write access to components
51 //@{
52 const Path& operator[](Size j) const { return multiPath_[j]; }
53 const Path& at(Size j) const { return multiPath_.at(j); }
54 Path& operator[](Size j) { return multiPath_[j]; }
55 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
Correlated multiple asset paths.
Definition: multipath.hpp:39
const Path & operator[](Size j) const
Definition: multipath.hpp:52
std::vector< Path > multiPath_
Definition: multipath.hpp:58
Path & operator[](Size j)
Definition: multipath.hpp:54
const Path & at(Size j) const
Definition: multipath.hpp:53
Size pathSize() const
Definition: multipath.hpp:48
Path & at(Size j)
Definition: multipath.hpp:55
Size assetNumber() const
Definition: multipath.hpp:47
single-factor random walk
Definition: path.hpp:40
time grid class
Definition: timegrid.hpp:43
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
STL namespace.
single factor random walk