genrand64_int64 Function

private function genrand64_int64(me)

Generates a random number on [-2^63, 2^63-1]-interval

Type Bound

mt19937

Arguments

Type IntentOptional Attributes Name
class(mt19937), intent(inout) :: me

Return Value integer(kind=r8)


Calls

proc~~genrand64_int64~~CallsGraph proc~genrand64_int64 mt19937%genrand64_int64 proc~init_genrand64 mt19937%init_genrand64 proc~genrand64_int64->proc~init_genrand64

Called by

proc~~genrand64_int64~~CalledByGraph proc~genrand64_int64 mt19937%genrand64_int64 proc~genrand64_real1 mt19937%genrand64_real1 proc~genrand64_real1->proc~genrand64_int64 proc~genrand64_real2 mt19937%genrand64_real2 proc~genrand64_real2->proc~genrand64_int64 proc~genrand64_real3 mt19937%genrand64_real3 proc~genrand64_real3->proc~genrand64_int64 proc~urand pikaia_class%urand proc~urand->proc~genrand64_real1 proc~cross pikaia_class%cross proc~cross->proc~urand proc~mutate pikaia_class%mutate proc~mutate->proc~urand proc~pikaia pikaia_class%pikaia proc~pikaia->proc~urand proc~pikaia->proc~cross proc~pikaia->proc~mutate proc~select_parents pikaia_class%select_parents proc~pikaia->proc~select_parents proc~stdrep pikaia_class%stdrep proc~pikaia->proc~stdrep proc~select_parents->proc~urand proc~stdrep->proc~urand proc~solve_with_pikaia pikaia_class%solve_with_pikaia proc~solve_with_pikaia->proc~pikaia program~test_algen test_algen program~test_algen->proc~solve_with_pikaia

Source Code

  integer(r8) function genrand64_int64(me)
    !! Generates a random number on [-2^63, 2^63-1]-interval

    implicit none

    class(mt19937),intent(inout) :: me

    integer(i8),parameter :: mag01(0:1) = [0_i8, matrix_a]

    integer(i8) :: x
    integer     :: i

    if(me%mti >= nn) then ! generate nn words at one time

      ! if init_genrand64() has not been called, a default initial seed is used
      if(me%mti == nn+1) call me%init_genrand64(seed_def)

      do i = 1, nn-mm
        x = ior(iand(me%mt(i),um), iand(me%mt(i+1), lm))
        me%mt(i) = ieor(ieor(me%mt(i+mm), ishft(x, -1)), mag01(iand(x, 1_i8)))
      end do

      do i = nn-mm+1, nn-1
        x = ior(iand(me%mt(i), um), iand(me%mt(i+1), lm))
        me%mt(i) = ieor(ieor(me%mt(i+mm-nn), ishft(x, -1)), mag01(iand(x, 1_i8)))
      end do

      x = ior(iand(me%mt(nn), um), iand(me%mt(1), lm))
      me%mt(nn) = ieor(ieor(me%mt(mm), ishft(x, -1)), mag01(iand(x, 1_i8)))

      me%mti = 0

    end if

    me%mti = me%mti + 1
    x = me%mt(me%mti)

    x = ieor(x, iand(ishft(x,-29), 6148914691236517205_i8))
    x = ieor(x, iand(ishft(x, 17), 8202884508482404352_i8))
    x = ieor(x, iand(ishft(x, 37),   -2270628950310912_i8))
    x = ieor(x, ishft(x, -43))

    genrand64_int64 = x

  end function genrand64_int64