Veritable Lasagna
An Allocator & Data Structure Library for C.
|
Go to the source code of this file.
Macros | |
#define | VL_H_RANDOM_SPLIT(randPtr, resultPtr) (*((vl_ularge_t*)(resultPtr)) = vlRandNext(randPtr)) |
This macro distributes random bytes to the specified pointer. | |
#define | vlRandFx4(randPtr, resultPtr) |
Generates four random floats. | |
Typedefs | |
typedef vl_ularge_t | vl_rand |
Random state type. | |
Functions | |
vl_rand | vlRandInit () |
Initializes a random state (aka, seed) based on the current time. | |
vl_rand | vlRandNext (vl_rand *rand) |
Returns the "next" 64-bit integer. | |
void | vlRandFill (vl_rand *rand, void *mem, vl_ularge_t len) |
Fills the specified region of memory with random bytes. | |
vl_float32_t | vlRandF (vl_rand *randPtr) |
Generate a random float. | |
void | vlRandFx2 (vl_rand *randPtr, vl_float32_t *resultPtr) |
Generates two random floats. | |
vl_float64_t | vlRandD (vl_rand *randPtr) |
Generate a random double. | |
#define VL_H_RANDOM_SPLIT | ( | randPtr, | |
resultPtr ) (*((vl_ularge_t*)(resultPtr)) = vlRandNext(randPtr)) |
This macro distributes random bytes to the specified pointer.
This macro results in a reinterpretation suitable for all integer types, but not for floating point types.
The total number of bytes distributed is equal to sizeof(vl_ularge_t).
#define vlRandFx4 | ( | randPtr, | |
resultPtr ) |
Generates four random floats.
Range of returned floats is in range of 0...1.
randPtr | pointer to random state |
resultPtr | where the result will be stored. |
typedef vl_ularge_t vl_rand |
Random state type.
The PRNG algorithm used by the VL library is splitmix64 or splitmix32. It offers fast pseudo-random number generation and passes Big Crush with minimal state. All vlRand* functions are almost entirely branchless.
vl_float64_t vlRandD | ( | vl_rand * | randPtr | ) |
Generate a random double.
Range of returned value is in 0...1.
randPtr | pointer to random state |
vl_float32_t vlRandF | ( | vl_rand * | randPtr | ) |
Generate a random float.
Range of returned value is in 0...1.
randPtr | pointer to random state |
void vlRandFill | ( | vl_rand * | rand, |
void * | mem, | ||
vl_ularge_t | len ) |
Fills the specified region of memory with random bytes.
This function operates on blocks of 8 bytes at a time, until it fills in the last few remaining bytes.
rand | rand state |
mem | destination |
len | total number of bytes to fill. |
void vlRandFx2 | ( | vl_rand * | randPtr, |
vl_float32_t * | resultPtr ) |
Generates two random floats.
Range of returned floats is in range of 0...1.
randPtr | pointer to random state |
resultPtr | where the result will be stored |
vl_rand vlRandInit | ( | ) |
Initializes a random state (aka, seed) based on the current time.
This function can be skipped entirely, assuming another seed integer can be provided.