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

Contents


Variables

TypeVisibilityAttributesNameInitial
integer, private, parameter:: r8 =real64
integer, private, parameter:: i4 =int32
integer, private, parameter:: i8 =int64
integer(kind=i8), private, parameter:: nn =312_i8
integer(kind=i8), private, parameter:: mm =156_i8
integer(kind=i8), private, parameter:: seed_def =5489_i8
integer(kind=i8), private, parameter:: matrix_a =-5403634167711393303_i8
integer(kind=i8), private, parameter:: um =-2147483648_i8

most significant 33 bits

integer(kind=i8), private, parameter:: lm =2147483647_i8

least significant 31 bits

real(kind=r8), private, parameter:: pi253_1 =1.0_r8/(2.0_r8**53-1.0_r8)
real(kind=r8), private, parameter:: pi253 =1.0_r8/(2.0_r8**53)
real(kind=r8), private, parameter:: pi252 =1.0_r8/(2.0_r8**52)

Derived Types

type, public :: mt19937

main class for random number generator

Components

TypeVisibilityAttributesNameInitial
integer(kind=i8), public :: mt(nn) =0_i8

array for the state vector

integer, public :: mti =nn+1

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

Type-Bound Procedures

generic, public :: initialize => init_genrand64_i4, init_genrand64, init_by_array64

call first to initialize

procedure, public :: init_genrand64
procedure, public :: init_by_array64
procedure, public :: init_genrand64_i4
procedure, public :: genrand64_real1
procedure, public :: genrand64_real2
procedure, public :: genrand64_real3
procedure, public :: genrand64_int64

Functions

private function genrand64_int64(me)

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

Arguments

TypeIntentOptionalAttributesName
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

TypeIntentOptionalAttributesName
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

TypeIntentOptionalAttributesName
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

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

Return Value real(kind=r8)


Subroutines

private subroutine init_genrand64_i4(me, seed)

Initializes me%mt(nn) with a seed

Arguments

TypeIntentOptionalAttributesName
class(mt19937), intent(inout) :: me
integer(kind=i4), intent(in) :: seed

private subroutine init_genrand64(me, seed)

Initializes me%mt(nn) with a seed

Arguments

TypeIntentOptionalAttributesName
class(mt19937), intent(inout) :: me
integer(kind=i8), intent(in) :: seed

private subroutine init_by_array64(me, init_key)

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

Arguments

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