random.c file
Classes
- struct normal_stream
Functions
- static auto from_bits(const uint64_t bits) -> double
-
static auto splitmix64_next(vm_
rng* rng) -> uint64_t -
static auto uniform_open(vm_
rng* rng) -> double - static auto ln_positive(const double x) -> double
- static auto sin_small(const double x) -> double
- static auto cos_small(const double x) -> double
- static void sincos_unit(double u, double* sn, double* cs)
-
static void box_muller(vm_
rng* rng, double* z0, double* z1) -
static auto standard_normal(normal_
stream* stream) -> double -
static auto scaled(const double z,
const double scale) -> vm_
float_ t -
static void store(const vm_
mat* A, const int r, const int c, const vm_ float_ t v) -
static auto square_ready(const vm_
mat* A) -> bool -
void vm_rng_seed(vm_
rng* rng, uint64_t seed) - Seed
rngand advance splitmix64 once. -
auto vm_goe(const vm_
mat* A, vm_ rng* rng) -> bool - Overwrite
Awith a GOE matrix. -
auto vm_gue(const vm_
mat* Ar, const vm_ mat* Ai, vm_ rng* rng) -> bool - Overwrite
ArandAiwith the real and imaginary parts of a GUE matrix.
Function documentation
void vm_rng_seed(vm_ rng* rng,
uint64_t seed)
Seed rng and advance splitmix64 once.
| Parameters | |
|---|---|
| rng | Generator to seed. |
| seed | Any value, including 0. |
The stored counter is seed plus the splitmix64 increment, so seed 0 is a valid state. A null rng is ignored.
bool vm_goe(const vm_ mat* A,
vm_ rng* rng)
Overwrite A with a GOE matrix.
| Parameters | |
|---|---|
| A | Square column-major matrix. Overwritten on success. |
| rng | Seeded generator. |
| Returns | true on success. |
A is square and rows >= 1. Diagonal entries are N(0, 2). Off-diagonal entries are N(0, 1). Row i draws the diagonal first, then columns j > i, and that one value is stored at both (i, j) and (j, i). A Box–Muller partner left over at the end of the call is discarded.
A null rng, a null matrix, a null data pointer, a non-square, or rows < 1 returns false and does not write. rng is left unchanged.
bool vm_gue(const vm_ mat* Ar,
const vm_ mat* Ai,
vm_ rng* rng)
Overwrite Ar and Ai with the real and imaginary parts of a GUE matrix.
| Parameters | |
|---|---|
| Ar | Real part. Overwritten on success. |
| Ai | Imaginary part. Overwritten on success. |
| rng | Seeded generator. |
| Returns | true on success. |
Both matrices are square and have the same order, at least 1. Diagonal real entries are N(0, 1). Diagonal imaginary entries are 0. Off-diagonal real and imaginary entries are each N(0, 1/2). Row i draws the diagonal real first, then for each j > i the real part and then the imaginary part. The real value is stored at both (i, j) and (j, i). The imaginary value is stored at (i, j) and its negation at (j, i). A Box–Muller partner left over at the end of the call is discarded.
A null rng, a null matrix, a null data pointer, a non-square, rows < 1, or two different orders returns false and does not write. rng is left unchanged.