Seed derivation helpers for deterministic RNG streams.
More...
#include <stdint.h>
Go to the source code of this file.
|
| uint64_t | sim_seed_normalize (uint64_t seed) |
| | Normalize a seed (zero maps to SIM_SEED_DEFAULT).
|
| |
| uint64_t | sim_seed_mix64 (uint64_t value) |
| | Mix a 64-bit value into a high-quality hash.
|
| |
| uint64_t | sim_seed_tag (const char *tag) |
| | Hash a domain tag into a 64-bit value.
|
| |
| uint64_t | sim_seed_derive (uint64_t base_seed, uint64_t tag_hash, uint64_t index) |
| | Derive a deterministic seed from a base seed, tag hash, and index.
|
| |
| void | sim_seed_stream (uint64_t base_seed, const char *tag, uint64_t index, uint64_t *out_state, uint64_t *out_inc) |
| | Derive a PCG32 stream (state + increment) from a base seed and domain tag.
|
| |
Seed derivation helpers for deterministic RNG streams.
◆ SIM_SEED_DEFAULT
| #define SIM_SEED_DEFAULT 0xA5A5A5A5A5A5A5A5ULL |
Default base seed used when a caller provides zero.
◆ sim_seed_derive()
| uint64_t sim_seed_derive |
( |
uint64_t |
base_seed, |
|
|
uint64_t |
tag_hash, |
|
|
uint64_t |
index |
|
) |
| |
Derive a deterministic seed from a base seed, tag hash, and index.
- Parameters
-
- Returns
- Derived child seed.
◆ sim_seed_mix64()
| uint64_t sim_seed_mix64 |
( |
uint64_t |
value | ) |
|
Mix a 64-bit value into a high-quality hash.
- Parameters
-
- Returns
- Mixed 64-bit value suitable for stream derivation.
◆ sim_seed_normalize()
| uint64_t sim_seed_normalize |
( |
uint64_t |
seed | ) |
|
Normalize a seed (zero maps to SIM_SEED_DEFAULT).
- Parameters
-
| seed | Caller-provided seed. |
- Returns
seed when nonzero, otherwise SIM_SEED_DEFAULT.
◆ sim_seed_stream()
| void sim_seed_stream |
( |
uint64_t |
base_seed, |
|
|
const char * |
tag, |
|
|
uint64_t |
index, |
|
|
uint64_t * |
out_state, |
|
|
uint64_t * |
out_inc |
|
) |
| |
Derive a PCG32 stream (state + increment) from a base seed and domain tag.
- Parameters
-
| base_seed | Base seed; zero is normalized to SIM_SEED_DEFAULT. |
| tag | Null-terminated domain tag for stream separation. |
| index | Numeric substream index. |
| [out] | out_state | Receives the PCG state when non-NULL. |
| [out] | out_inc | Receives the PCG increment when non-NULL. |
◆ sim_seed_tag()
| uint64_t sim_seed_tag |
( |
const char * |
tag | ) |
|
Hash a domain tag into a 64-bit value.
- Parameters
-
| tag | Null-terminated tag; NULL hashes as an empty tag. |
- Returns
- Deterministic 64-bit tag hash.