Oakfield API Documentation 1.0.0
Numerical core APIs
Loading...
Searching...
No Matches
sim_seed.h File Reference

Seed derivation helpers for deterministic RNG streams. More...

#include <stdint.h>
Include dependency graph for sim_seed.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SIM_SEED_DEFAULT   0xA5A5A5A5A5A5A5A5ULL
 

Functions

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.
 

Detailed Description

Seed derivation helpers for deterministic RNG streams.

Macro Definition Documentation

◆ SIM_SEED_DEFAULT

#define SIM_SEED_DEFAULT   0xA5A5A5A5A5A5A5A5ULL

Default base seed used when a caller provides zero.

Function Documentation

◆ 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
base_seedBase seed; zero is normalized to SIM_SEED_DEFAULT.
tag_hashDomain tag hash, often from sim_seed_tag().
indexNumeric substream index.
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
valueInput value.
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
seedCaller-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_seedBase seed; zero is normalized to SIM_SEED_DEFAULT.
tagNull-terminated domain tag for stream separation.
indexNumeric substream index.
[out]out_stateReceives the PCG state when non-NULL.
[out]out_incReceives 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
tagNull-terminated tag; NULL hashes as an empty tag.
Returns
Deterministic 64-bit tag hash.