init_by_array64 Subroutine

private subroutine init_by_array64(me, init_key)

Initializes by an array with array-length init_key is the array for initializing keys

Type Bound

mt19937

Arguments

Type IntentOptional Attributes Name
class(mt19937), intent(inout) :: me
integer(kind=i8), intent(in) :: init_key(:)

Calls

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

Called by

proc~~init_by_array64~~CalledByGraph proc~init_by_array64 mt19937%init_by_array64 none~initialize mt19937%initialize none~initialize->proc~init_by_array64 proc~init_genrand64_i4 mt19937%init_genrand64_i4 none~initialize->proc~init_genrand64_i4 proc~init_genrand64_i4->none~initialize proc~rninit pikaia_class%rninit proc~rninit->none~initialize proc~pikaia pikaia_class%pikaia proc~pikaia->proc~rninit 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

  subroutine init_by_array64(me,init_key)
    !! Initializes by an array with array-length
    !! `init_key` is the array for initializing keys
    implicit none

    class(mt19937),intent(inout) :: me
    integer(i8), intent(in) :: init_key(:)

    integer(i8), parameter  :: c1 = 3935559000370003845_i8
    integer(i8), parameter  :: c2 = 2862933555777941757_i8
    integer(i8) :: i, j, k, kk, key_length

    call me%init_genrand64(19650218_i8)
    key_length = size(init_key)
    i = 1_i8; j = 0_i8
    k = max(nn, key_length)

    do kk = 1, k
      me%mt(i+1) = ieor(me%mt(i+1), c1 * ieor(me%mt(i), ishft(me%mt(i), -62))) &
                  + init_key(j+1) + j
      i = i+1; j = j+1
      if(i >= nn) then
        me%mt(1) = me%mt(nn)
        i = 1
      end if
      if(j >= key_length) j = 0
    end do

    do kk = 1, nn-1
      me%mt(i+1) = ieor(me%mt(i+1), c2 * ieor(me%mt(i), ishft(me%mt(i), -62))) - i
      i = i+1
      if(i >= nn) then
        me%mt(1) = me%mt(nn)
        i = 1
      end if
    end do

    me%mt(1) = ishft(1_i8, 63)  ! MSB is 1; assuring non-zero initial array

  end subroutine init_by_array64