Skip to main content

pcg_seek

Function pcg_seek 

Source
pub fn pcg_seek(seed: u64, inc: u64, position: u64) -> u64
Expand description

Seek to an arbitrary position in the PCG sequence in O(log N) time.

Uses the “distance” algorithm that exponentiates the LCG recurrence via repeated squaring, equivalent to computing state_N directly from seed without iterating through positions 0..N.

  • seed: initial LCG state
  • inc: LCG increment (must be odd; typically 2 * stream + 1)
  • position: the sequence index to seek to