-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
ranluxuniformrng.hpp
73 lines (53 loc) · 2.31 KB
/
ranluxuniformrng.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2009 Klaus Spanderen
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
/*! \file ranluxuniformrng.hpp
\brief "Luxury" random number generator.
*/
#ifndef quantlib_ranlux_uniform_rng_h
#define quantlib_ranlux_uniform_rng_h
#include <ql/methods/montecarlo/sample.hpp>
#include <boost/random/ranlux.hpp>
namespace QuantLib {
//! Uniform random number generator
/*! M. Luescher's "luxury" random number generator
Implementation is a proxy for the corresponding boost random
number generator. For more detail see the boost documentation and:
M.Luescher, A portable high-quality random number generator for
lattice field theory simulations, Comp. Phys. Comm. 79 (1994) 100
Available luxury levels:
Ranlux3: Any theoretically possible correlations have very small change
of being observed.
Ranlux4: highest possible luxury.
*/
class Ranlux3UniformRng {
public:
typedef Sample<Real> sample_type;
explicit Ranlux3UniformRng(Size seed = 19780503U)
: ranlux3_(boost::random::ranlux64_base_01(seed)) {}
sample_type next() const { return {ranlux3_(), 1.0}; }
private:
mutable boost::ranlux64_3_01 ranlux3_;
};
class Ranlux4UniformRng {
public:
typedef Sample<Real> sample_type;
explicit Ranlux4UniformRng(Size seed = 19780503U)
: ranlux4_(boost::random::ranlux64_base_01(seed)) {}
sample_type next() const { return {ranlux4_(), 1.0}; }
private:
mutable boost::ranlux64_4_01 ranlux4_;
};
}
#endif