PCG-XSH-RR 64/32 generator: 64-bit LCG state with a 32-bit output permutation, plus a per-stream odd increment.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int64), | public | :: | increment | = | PCG_DEFAULT_INCREMENT |
Stream increment; always odd, which is what makes streams distinct. |
|
| integer(kind=int64), | public | :: | state | = | 0_int64 |
Explicit 64-bit LCG state (fixed width, not |
Next 32-bit output, returned as the int32 with the same bit pattern
as the reference implementation’s uint32_t result. Roughly half of
the returned values are therefore negative; use next_real_dp or
next_below if a magnitude is wanted.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pcg32_t), | intent(inout) | :: | self |
Full 64-bit random word built from two consecutive 32-bit outputs; the
first output supplies the high half. Fixing the order here is what makes
next_real_dp and next_below reproducible for this engine.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pcg32_t), | intent(inout) | :: | self |
Seed the generator, following the reference pcg32_srandom_r: the
stream selector is shifted left and forced odd to become the LCG
increment, then the state is warmed up, offset by the requested state
and warmed up again.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pcg32_t), | intent(inout) | :: | self | |||
| integer(kind=int64), | intent(in) | :: | state | |||
| integer(kind=int64), | intent(in) | :: | seq |
type :: pcg32_t !! PCG-XSH-RR 64/32 generator: 64-bit LCG state with a 32-bit output !! permutation, plus a per-stream odd increment. integer(int64) :: state = 0_int64 !! Explicit 64-bit LCG state (fixed width, not `default_int`). integer(int64) :: increment = PCG_DEFAULT_INCREMENT !! Stream increment; always odd, which is what makes streams distinct. contains procedure :: seed => pcg32_seed procedure :: next => pcg32_next procedure :: next_u64 => pcg32_next_u64 end type pcg32_t