29 unsigned long scrambleSeed)
30 : dimensionality_(dimensionality), seed_(seed), directionIntegers_(directionIntegers),
31 integerSequence_(dimensionality), sequence_(
std::vector<
Real>(dimensionality), 1.0) {
36 s =
static_cast<std::uint32_t
>(mt.
nextInt32());
47 for (
Size k = 0; k <
n + 1; ++k) {
57 const std::uint8_t bitReverseTable[] = {
58 0U, 128U, 64U, 192U, 32U, 160U, 96U, 224U, 16U, 144U, 80U, 208U, 48U, 176U,
59 112U, 240U, 8U, 136U, 72U, 200U, 40U, 168U, 104U, 232U, 24U, 152U, 88U, 216U,
60 56U, 184U, 120U, 248U, 4U, 132U, 68U, 196U, 36U, 164U, 100U, 228U, 20U, 148U,
61 84U, 212U, 52U, 180U, 116U, 244U, 12U, 140U, 76U, 204U, 44U, 172U, 108U, 236U,
62 28U, 156U, 92U, 220U, 60U, 188U, 124U, 252U, 2U, 130U, 66U, 194U, 34U, 162U,
63 98U, 226U, 18U, 146U, 82U, 210U, 50U, 178U, 114U, 242U, 10U, 138U, 74U, 202U,
64 42U, 170U, 106U, 234U, 26U, 154U, 90U, 218U, 58U, 186U, 122U, 250U, 6U, 134U,
65 70U, 198U, 38U, 166U, 102U, 230U, 22U, 150U, 86U, 214U, 54U, 182U, 118U, 246U,
66 14U, 142U, 78U, 206U, 46U, 174U, 110U, 238U, 30U, 158U, 94U, 222U, 62U, 190U,
67 126U, 254U, 1U, 129U, 65U, 193U, 33U, 161U, 97U, 225U, 17U, 145U, 81U, 209U,
68 49U, 177U, 113U, 241U, 9U, 137U, 73U, 201U, 41U, 169U, 105U, 233U, 25U, 153U,
69 89U, 217U, 57U, 185U, 121U, 249U, 5U, 133U, 69U, 197U, 37U, 165U, 101U, 229U,
70 21U, 149U, 85U, 213U, 53U, 181U, 117U, 245U, 13U, 141U, 77U, 205U, 45U, 173U,
71 109U, 237U, 29U, 157U, 93U, 221U, 61U, 189U, 125U, 253U, 3U, 131U, 67U, 195U,
72 35U, 163U, 99U, 227U, 19U, 147U, 83U, 211U, 51U, 179U, 115U, 243U, 11U, 139U,
73 75U, 203U, 43U, 171U, 107U, 235U, 27U, 155U, 91U, 219U, 59U, 187U, 123U, 251U,
74 7U, 135U, 71U, 199U, 39U, 167U, 103U, 231U, 23U, 151U, 87U, 215U, 55U, 183U,
75 119U, 247U, 15U, 143U, 79U, 207U, 47U, 175U, 111U, 239U, 31U, 159U, 95U, 223U,
76 63U, 191U, 127U, 255U};
78 inline std::uint32_t reverseBits(std::uint32_t x) {
79 return (bitReverseTable[x & 0xff] << 24) | (bitReverseTable[(x >> 8) & 0xff] << 16) |
80 (bitReverseTable[(x >> 16) & 0xff] << 8) | (bitReverseTable[(x >> 24) & 0xff]);
83 inline std::uint32_t laine_karras_permutation(std::uint32_t x, std::uint32_t seed) {
92 inline std::uint32_t nested_uniform_scramble(std::uint32_t x, std::uint32_t seed) {
94 x = laine_karras_permutation(x, seed);
105 inline std::uint64_t local_hash_mix(std::uint64_t x) {
106 const std::uint64_t m = 0xe9846af9b1a615d;
115 inline std::uint64_t local_hash(
const std::uint64_t
v) {
116 std::uint64_t seed = 0;
117 seed = (
v >> 32) + local_hash_mix(seed);
118 seed = (
v & 0xFFFFFFFF) + local_hash_mix(seed);
122 inline std::uint64_t local_hash_combine(std::uint64_t x,
const uint64_t
v) {
123 return local_hash_mix(x + 0x9e3779b9 + local_hash(
v));
131 Size i = 0, group = 0;
135 seed = local_hash_combine(seed, g);
137 nested_uniform_scramble(
integerSequence_[i],
static_cast<std::uint32_t
>(seed));
141 "Burley2020SobolRsg::nextIn32Sequence(): period exceeded");
scrambled Sobol sequence following Burley, 2020
const std::vector< std::uint32_t > & skipTo(std::uint32_t n) const
SobolRsg::DirectionIntegers directionIntegers_
const std::vector< std::uint32_t > & nextInt32Sequence() const
ext::shared_ptr< SobolRsg > sobolRsg_
std::vector< std::uint32_t > group4Seeds_
const SobolRsg::sample_type & nextSequence() const
std::uint32_t nextSequenceCounter_
std::vector< std::uint32_t > integerSequence_
Burley2020SobolRsg(Size dimensionality, unsigned long seed=42, SobolRsg::DirectionIntegers directionIntegers=SobolRsg::Jaeckel, unsigned long scrambleSeed=43)
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
ext::shared_ptr< BlackVolTermStructure > v