27#ifndef quantlib_multi_path_generator_hpp
28#define quantlib_multi_path_generator_hpp
57 bool brownianBridge =
false);
76 : brownianBridge_(brownianBridge), process_(process), generator_(
std::move(generator)),
77 next_(
MultiPath(process->size(), times), 1.0) {
80 process->factors()*(times.
size()-1),
82 <<
") is not equal to ("
83 << process->factors() <<
" * " << times.
size()-1
84 <<
") the number of factors "
85 <<
"times the number of time steps");
106 if (brownianBridge_) {
108 QL_FAIL(
"Brownian bridge not supported");
112 typedef typename GSG::sample_type sequence_type;
113 const sequence_type& sequence_ =
114 antithetic ? generator_.lastSequence()
115 : generator_.nextSequence();
117 Size m = process_->size();
118 Size n = process_->factors();
122 Array asset = process_->initialValues();
123 for (
Size j=0; j<m; j++)
124 path[j].front() = asset[j];
127 next_.weight = sequence_.weight;
129 const TimeGrid& timeGrid = path[0].timeGrid();
132 Size offset = (i-1)*
n;
134 dt = timeGrid.
dt(i-1);
136 std::transform(sequence_.value.begin()+offset,
137 sequence_.value.begin()+offset+
n,
141 std::copy(sequence_.value.begin()+offset,
142 sequence_.value.begin()+offset+
n,
145 asset = process_->evolve(
t, asset, dt, temp);
146 for (
Size j=0; j<m; j++)
147 path[j][i] = asset[j];
1-D array used in linear algebra.
const_iterator begin() const
Generates a multipath from a random number generator.
const sample_type & antithetic() const
Sample< MultiPath > sample_type
ext::shared_ptr< StochasticProcess > process_
MultiPathGenerator(const ext::shared_ptr< StochasticProcess > &, const TimeGrid &, GSG generator, bool brownianBridge=false)
const sample_type & next() const
Correlated multiple asset paths.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Correlated multiple asset paths.