24#ifndef quantlib_isotropic_random_walk_hpp
25#define quantlib_isotropic_random_walk_hpp
43 template <
class Distribution,
class Engine>
50 unsigned long seed = 0)
57 template <
class InputIterator>
64 for (
Size i = 0; i <
dim_ - 2; i++) {
65 *first++ = radius*cos(phi)*(*weight++);
69 *first++ = radius*cos(2.0*phi)*(*weight++);
70 *first = radius*sin(2.0*phi)*(*weight);
74 *first = -radius*(*weight);
76 *first = radius*(*weight);
94 const Array& lowerBound,
const Array& upperBound) {
96 "Incompatible dimension and lower bound");
98 "Incompatible dimension and upper bound");
100 Array bounds = upperBound - lowerBound;
101 Real maxBound = bounds[0];
102 for (
Size j = 1; j < dim; j++) {
103 if (bounds[j] > maxBound) maxBound = bounds[j];
107 maxBound = 1.0 / maxBound;
1-D array used in linear algebra.
1-D array used in linear algebra.
const Real * const_iterator
bool empty() const
whether the array is empty
Size size() const
dimension of the array
const_iterator begin() const
void nextReal(InputIterator first)
Distribution distribution_
MersenneTwisterUniformRng rng_
void setDimension(Size dim, const Array &lowerBound, const Array &upperBound)
void setDimension(Size dim)
IsotropicRandomWalk(Engine eng, Distribution dist, Size dim, Array weights=Array(), unsigned long seed=0)
void setDimension(Size dim, const Array &weights)
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container