mt19937_type Derived Type

type, public :: mt19937_type

Mersenne-Twister object. Allows multiple, independent instances to be used within a program


Contents

Source Code


Components

Type Visibility Attributes Name Initial
integer, public :: mt(0:N_mt19937-1)

The array for the state vector

integer, public :: mti = N_mt19937+1

mti==N+1 means mt[N] is not initialized


Type-Bound Procedures

procedure, public, :: set_seed

  • private subroutine set_seed(this, seed)

    Set initial seed of a mt19937_type instance

    Set initial seeds to mt[N] using the generator Line 25 of Table 1 in [KNUTH 1981, The Art of Computer Programming Vol. 2 (2nd Ed.), pp102]

    Arguments

    Type IntentOptional Attributes Name
    class(mt19937_type), intent(inout) :: this
    integer, intent(in) :: seed

procedure, public, :: generate

  • private function generate(this)

    Generate a random number from a mt19937_type

    Arguments

    Type IntentOptional Attributes Name
    class(mt19937_type), intent(inout) :: this

    Return Value real

Source Code

  type mt19937_type
    integer :: mt(0:N_mt19937-1) !< The array for the state vector
    integer :: mti = N_mt19937+1 !< mti==N+1 means mt[N] is not initialized
  contains
    procedure :: set_seed
    procedure :: generate
  end type mt19937_type