QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
ranluxuniformrng.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_ranlux_uniform_rng_h
25#define quantlib_ranlux_uniform_rng_h
26
27#include <ql/methods/montecarlo/sample.hpp>
28
29#include <random>
30
31namespace QuantLib {
32
34
46 template <std::size_t P, std::size_t R>
48 public:
50
51 explicit Ranlux64UniformRng(std::uint_fast64_t seed = 19780503U)
52 : ranlux_(ranlux64_base_01(seed)) {}
53
54 sample_type next() const { return {ranlux_()*nx, 1.0}; }
55
56 private:
57 const double nx = 1.0/(std::uint_fast64_t(1) << 48);
58 typedef std::subtract_with_carry_engine<std::uint_fast64_t, 48, 10, 24>
60 mutable std::discard_block_engine<ranlux64_base_01, P, R> ranlux_;
61 };
62
65}
66
67
68#endif
Uniform random number generator.
std::discard_block_engine< ranlux64_base_01, P, R > ranlux_
Ranlux64UniformRng(std::uint_fast64_t seed=19780503U)
std::subtract_with_carry_engine< std::uint_fast64_t, 48, 10, 24 > ranlux64_base_01
Definition: any.hpp:35
Ranlux64UniformRng< 223, 24 > Ranlux3UniformRng
Ranlux64UniformRng< 389, 24 > Ranlux4UniformRng
weighted sample
Definition: sample.hpp:35