pcg32_seed Subroutine

private subroutine pcg32_seed(self, state, seq)

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 Bound

pcg32_t

Arguments

Type IntentOptional Attributes Name
class(pcg32_t), intent(inout) :: self
integer(kind=int64), intent(in) :: state
integer(kind=int64), intent(in) :: seq

Calls

proc~~pcg32_seed~~CallsGraph proc~pcg32_seed pcg32_t%pcg32_seed proc~pcg32_step pcg32_step proc~pcg32_seed->proc~pcg32_step proc~u64_add u64_add proc~pcg32_seed->proc~u64_add proc~pcg32_step->proc~u64_add proc~rotate_right32 rotate_right32 proc~pcg32_step->proc~rotate_right32 proc~u64_mul u64_mul proc~pcg32_step->proc~u64_mul proc~u64_shr u64_shr proc~pcg32_step->proc~u64_shr

Variables

Type Visibility Attributes Name Initial
integer(kind=int64), private :: discard

Source Code

   subroutine pcg32_seed(self, state, seq)
      !! 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.
      class(pcg32_t), intent(inout) :: self
      integer(int64), intent(in) :: state
      integer(int64), intent(in) :: seq

      integer(int64) :: discard

      self%increment = ior(ishft(seq, 1), 1_int64)
      self%state = 0_int64
      discard = pcg32_step(self)
      self%state = u64_add(self%state, state)
      discard = pcg32_step(self)
   end subroutine pcg32_seed