91#define BJ_RAND_MAX 0x7FFF
254#if defined(BJ_API_LONG_DOUBLE)
255 #define bj_uniform_real_distribution bj_uniform_long_double_distribution
256#elif defined(BJ_API_FLOAT64)
257 #define bj_uniform_real_distribution bj_uniform_double_distribution
259 #define bj_uniform_real_distribution bj_uniform_float_distribution
287 float standard_deviation
302 double standard_deviation
317 long double standard_deviation
329#if defined(BJ_API_LONG_DOUBLE)
330 #define bj_normal_real_distribution bj_normal_long_double_distribution
331#elif defined(BJ_API_FLOAT64)
332 #define bj_normal_real_distribution bj_normal_double_distribution
334 #define bj_normal_real_distribution bj_normal_float_distribution
405#if defined(BJ_API_LONG_DOUBLE)
406 #define bj_normal_real_minmax_distribution bj_normal_long_double_minmax_distribution
407#elif defined(BJ_API_FLOAT64)
408 #define bj_normal_real_minmax_distribution bj_normal_double_minmax_distribution
410 #define bj_normal_real_minmax_distribution bj_normal_float_minmax_distribution
General-purpose definitions for Banjo API.
#define BJ_INLINE
BJ_INLINE expands to an inline specifier appropriate for the toolchain.
float bj_real
Selected real type for float configuration.
uint64_t inc
Stream selector; odd recommended, 0 allowed.
uint64_t state
Current internal state (updated each step).
void bj_seed_pcg32(struct bj_pcg32 *generator, uint64_t seed, uint64_t seq)
Set the generator state from seed and sequence.
uint32_t bj_min_pcg32(void)
Smallest possible value returned by the generator.
long double bj_normal_long_double_minmax_distribution(bj_random_u32_fn next, void *state, long double min, long double max)
Normal from min/max convenience (μ ≈ (min+max)/2, σ ≈ (max-min)/6).
double bj_normal_double_distribution(bj_random_u32_fn next, void *state, double mean, double standard_deviation)
Normal double N(mean, standard_deviation^2).
double bj_normal_double_minmax_distribution(bj_random_u32_fn next, void *state, double min, double max)
Normal from min/max convenience (μ ≈ (min+max)/2, σ ≈ (max-min)/6).
static uint32_t bj_pcg32_generator(void *state)
Adapter for distribution API (void* state).
float bj_normal_float_minmax_distribution(bj_random_u32_fn next, void *state, float min, float max)
Normal from min/max convenience (μ ≈ (min+max)/2, σ ≈ (max-min)/6).
int32_t bj_uniform_int32_distribution(bj_random_u32_fn next, void *state, int32_t low, int32_t high)
Uniform 32-bit integer in [low, high].
long double bj_uniform_long_double_distribution(bj_random_u32_fn next, void *state, long double low, long double high)
Uniform long double in [low, high).
int bj_bernoulli_distribution(bj_random_u32_fn next, void *state, bj_real probability)
Bernoulli(probability).
void bj_discard_pcg32(struct bj_pcg32 *generator, uint64_t z)
Advance the generator state by z steps.
float bj_normal_float_distribution(bj_random_u32_fn next, void *state, float mean, float standard_deviation)
Normal float N(mean, standard_deviation^2).
float bj_uniform_float_distribution(bj_random_u32_fn next, void *state, float low, float high)
Uniform float in [low, high).
uint32_t bj_max_pcg32(void)
Largest possible value returned by the generator.
long double bj_normal_long_double_distribution(bj_random_u32_fn next, void *state, long double mean, long double standard_deviation)
Normal long double N(mean, standard_deviation^2).
void bj_srand(unsigned int seed)
Seed the standard PRNG.
double bj_uniform_double_distribution(bj_random_u32_fn next, void *state, double low, double high)
Uniform double in [low, high).
int bj_rand(void)
Generate a pseudo-random integer in [0, BJ_RAND_MAX].
uint32_t bj_next_pcg32(struct bj_pcg32 *generator)
Advance the generator and return the next 32-bit value.
uint32_t(* bj_random_u32_fn)(void *state)
RNG callback type for generator-agnostic distributions.
C99 math shim with bj_real precision type and scalar utilities.