Add xoshiro256** generator in LfRng #2

Merged
fputs merged 1 commit from fputs/rng into master 2026-11-05 09:32:25 -08:00 AGit
Owner

Adds LfRng, an xoshiro256** 1.0 stream in a caller-owned struct. Seeding is four SplitMix64 steps and reads no clock or device. src/rng.c keeps the Blackman/Vigna public-domain dedication. jump and long_jump are not included.

lf_rng_next_range uses rejection sampling (zone = (-n) % n in uint64_t) so the result is uniform on [0, n). A power of two consumes one draw. An all-zero state is rejected before the update.

The seed-0 state and the first outputs in the tests match the functions in the brief.

Tested with -DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF. ctest --label-exclude slow: 26/26 passed.

Adds `LfRng`, an xoshiro256** 1.0 stream in a caller-owned struct. Seeding is four SplitMix64 steps and reads no clock or device. `src/rng.c` keeps the Blackman/Vigna public-domain dedication. `jump` and `long_jump` are not included. `lf_rng_next_range` uses rejection sampling (`zone = (-n) % n` in `uint64_t`) so the result is uniform on `[0, n)`. A power of two consumes one draw. An all-zero state is rejected before the update. The seed-0 state and the first outputs in the tests match the functions in the brief. Tested with `-DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF`. `ctest --label-exclude slow`: 26/26 passed.
Add xoshiro256** generator in LfRng
All checks were successful
test / test (pull_request) Successful in 14s
test / sanitize (pull_request) Successful in 16s
ec85a23157
fputs merged commit f790841086 into master 2026-11-05 09:32:25 -08:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
fputs/libflint!2
No description provided.