QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Xoshiro256StarStarUniformRng Class Reference

Uniform random number generator. More...

#include <xoshiro256starstaruniformrng.hpp>

+ Collaboration diagram for Xoshiro256StarStarUniformRng:

Public Types

typedef Sample< Realsample_type
 

Public Member Functions

 Xoshiro256StarStarUniformRng (std::uint64_t seed=0)
 
 Xoshiro256StarStarUniformRng (std::uint64_t s0, std::uint64_t s1, std::uint64_t s2, std::uint64_t s3)
 
sample_type next () const
 
Real nextReal () const
 return a random number in the (0.0, 1.0)-interval More...
 
std::uint64_t nextInt64 () const
 return a random integer in the [0,0xffffffffffffffffULL]-interval More...
 

Static Private Member Functions

static std::uint64_t rotl (std::uint64_t x, std::int32_t k)
 

Private Attributes

std::uint64_t s0_
 
std::uint64_t s1_
 
std::uint64_t s2_
 
std::uint64_t s3_
 

Detailed Description

Uniform random number generator.

xoshiro256** random number generator of period 2**256-1

For more details see https://prng.di.unimi.it/ and its reference implementation https://prng.di.unimi.it/xoshiro256starstar.c

Tests:
the correctness of the returned values is tested by checking them against the reference implementation in c.

Definition at line 56 of file xoshiro256starstaruniformrng.hpp.

Member Typedef Documentation

◆ sample_type

Definition at line 58 of file xoshiro256starstaruniformrng.hpp.

Constructor & Destructor Documentation

◆ Xoshiro256StarStarUniformRng() [1/2]

Xoshiro256StarStarUniformRng ( std::uint64_t  seed = 0)
explicit

If the given seed is 0, a random seed will be chosen based on clock().

Definition at line 54 of file xoshiro256starstaruniformrng.cpp.

+ Here is the call graph for this function:

◆ Xoshiro256StarStarUniformRng() [2/2]

Xoshiro256StarStarUniformRng ( std::uint64_t  s0,
std::uint64_t  s1,
std::uint64_t  s2,
std::uint64_t  s3 
)

Make sure that s0, s1, s2 and s3 are chosen randomly. Otherwise, the results of the first random numbers might not be well distributed. Especially s0 = s1 = s2 = s3 = 0 does not work and will always return 0.

Definition at line 62 of file xoshiro256starstaruniformrng.cpp.

Member Function Documentation

◆ next()

sample_type next ( ) const

returns a sample with weight 1.0 containing a random number in the (0.0, 1.0) interval

Definition at line 70 of file xoshiro256starstaruniformrng.hpp.

+ Here is the call graph for this function:

◆ nextReal()

Real nextReal ( ) const

return a random number in the (0.0, 1.0)-interval

Definition at line 73 of file xoshiro256starstaruniformrng.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextInt64()

std::uint64_t nextInt64 ( ) const

return a random integer in the [0,0xffffffffffffffffULL]-interval

Definition at line 76 of file xoshiro256starstaruniformrng.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rotl()

static std::uint64_t rotl ( std::uint64_t  x,
std::int32_t  k 
)
staticprivate

Definition at line 94 of file xoshiro256starstaruniformrng.hpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ s0_

std::uint64_t s0_
mutableprivate

Definition at line 95 of file xoshiro256starstaruniformrng.hpp.

◆ s1_

std::uint64_t s1_
private

Definition at line 95 of file xoshiro256starstaruniformrng.hpp.

◆ s2_

std::uint64_t s2_
private

Definition at line 95 of file xoshiro256starstaruniformrng.hpp.

◆ s3_

std::uint64_t s3_
private

Definition at line 95 of file xoshiro256starstaruniformrng.hpp.