mt19937_64 Module

64-bit version of the Mersenne Twister pseudorandom number generator.

History

  • Contributors: Rémi Piatek, Takuji Nishimura, Makoto Matsumoto, Jacob Williams See LICENSE file for details.

References

  • T. Nishimura, “Tables of 64-bit Mersenne Twisters” ACM Transactions on Modeling and Computer Simulation 10. (2000) 348–357.
  • M. Matsumoto and T. Nishimura, “Mersenne Twister: a 623-dimensionally equidistributed uniform pseudorandom number generator” ACM Transactions on Modeling and Computer Simulation 8. (Jan. 1998) 3–30.
  • Original source: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/FORTRAN/mt19937-64.f95

Uses

  • module~~mt19937_64~~UsesGraph module~mt19937_64 mt19937_64 iso_fortran_env iso_fortran_env module~mt19937_64->iso_fortran_env

Used by

  • module~~mt19937_64~~UsedByGraph module~mt19937_64 mt19937_64 module~pikaia_oop pikaia_oop module~pikaia_oop->module~mt19937_64 program~test_algen test_algen program~test_algen->module~pikaia_oop

Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: i4 = int32
integer, private, parameter :: i8 = int64
integer(kind=i8), private, parameter :: lm = 2147483647_i8

least significant 31 bits

integer(kind=i8), private, parameter :: matrix_a = -5403634167711393303_i8
integer(kind=i8), private, parameter :: mm = 156_i8
integer(kind=i8), private, parameter :: nn = 312_i8
real(kind=r8), private, parameter :: pi252 = 1.0_r8/(2.0_r8**52)
real(kind=r8), private, parameter :: pi253 = 1.0_r8/(2.0_r8**53)
real(kind=r8), private, parameter :: pi253_1 = 1.0_r8/(2.0_r8**53-1.0_r8)
integer, private, parameter :: r8 = real64
integer(kind=i8), private, parameter :: seed_def = 5489_i8
integer(kind=i8), private, parameter :: um = -2147483648_i8

most significant 33 bits


Derived Types

type, public ::  mt19937

main class for random number generator

Components

Type Visibility Attributes Name Initial
integer(kind=i8), private :: mt(nn) = 0_i8

array for the state vector

integer, private :: mti = nn+1

mti==nn+1 means mt(nn) is not initialized

Type-Bound Procedures

procedure, public :: genrand64_int64
procedure, public :: genrand64_real1
procedure, public :: genrand64_real2
procedure, public :: genrand64_real3
procedure, private :: init_by_array64
procedure, private :: init_genrand64
procedure, private :: init_genrand64_i4
generic, public :: initialize => init_genrand64_i4, init_genrand64, init_by_array64 ../../

call first to initialize


Functions

private function genrand64_int64(me)

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

Arguments

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

Return Value integer(kind=r8)

private function genrand64_real1(me)

Generates a random number on [0,1]-real-interval

Arguments

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

Return Value real(kind=r8)

private function genrand64_real2(me)

Generates a random number on [0,1)-real-interval

Arguments

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

Return Value real(kind=r8)

private function genrand64_real3(me)

Generates a random number on (0,1)-real-interval

Arguments

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

Return Value real(kind=r8)


Subroutines

private subroutine init_by_array64(me, init_key)

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

Arguments

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

private subroutine init_genrand64(me, seed)

Initializes me%mt(nn) with a seed

Arguments

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

private subroutine init_genrand64_i4(me, seed)

Initializes me%mt(nn) with a seed

Arguments

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