mt19937_64

package module
v0.0.0-...-1d1d0a5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2013 License: MIT Imports: 1 Imported by: 2

README

mt19937_64

64bit Mersenne Twister (MT19937-64) written in Go. Implements the "Source interface" from "math/rand". Example use of the interface can be found in tests/mt19937_64_concurency.go.

Testing

Reproduces original test vectors http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/mt19937-64.out.txt. See tests/mt19937_64_test_vectors.go and data/mt19937-64.out.txt for details. Concurency safety is tested in tests/mt19937_64_concurency.go.

The MIT License (MIT)

Documentation

Overview

64bit Mersenne Twister (MT19937_64) written in Go.

note: "unsigned long long" = "uint64" therefore "genrand_int64()" --> "Uint64()"

Index

Constants

View Source
const (
	MT_VEC_LEN  uint64 = 312
	MT_VEC_LEN2 uint64 = 156

	MT_MAG_LEN uint64 = 2
	MT_MAG_0   uint64 = 0
	MT_MAG_1   uint64 = 0xB5026F5AA96619E9

	MT_MOST_33  uint64 = 0xFFFFFFFF80000000
	MT_LEAST_31 uint64 = 0x000000007FFFFFFF

	MT_DEFAULT_SEED       uint64 = 5489
	MT_DEFAULT_SEED_ARRAY uint64 = 19650218

	MT_INIT         uint64 = 6364136223846793005
	MT_INIT_ARRAY_J uint64 = 3935559000370003845
	MT_INIT_ARRAY_I uint64 = 2862933555777941757

	MT_UINT64_SHR_29 uint64 = 0x5555555555555555
	MT_UINT64_SHL_17 uint64 = 0x71D67FFFEDA60000
	MT_UINT64_SHL_37 uint64 = 0xFFF7EEE000000000

	MT_REAL1_DIV float64 = 9007199254740991.0
	MT_REAL2_DIV float64 = 9007199254740992.0
	MT_REAL3_DIV float64 = 4503599627370496.0
)

All magic numbers are defined here.

Variables

This section is empty.

Functions

This section is empty.

Types

type MT

type MT struct {
	// contains filtered or unexported fields
}

Main MT19937_64 data struct.

func New

func New() *MT

func (*MT) Int63

func (mt *MT) Int63() int64

Generate an integer on [0, 2^63 - 1].

func (*MT) Real1

func (mt *MT) Real1() float64

Generate a float on [0, 1].

func (*MT) Real2

func (mt *MT) Real2() float64

Generate a float on [0, 1).

func (*MT) Real3

func (mt *MT) Real3() float64

Generate a float on (0, 1).

func (*MT) Seed

func (mt *MT) Seed(seed int64)

Seed with an int64 integer. To implement the "Source interface" from "math/rand".

func (*MT) SeedByArray

func (mt *MT) SeedByArray(initKey []uint64)

Seed with an array.

func (*MT) SeedByUint

func (mt *MT) SeedByUint(seed uint64)

Seed with an uint64 integer.

func (*MT) Uint64

func (mt *MT) Uint64() uint64

Generate an integer on [0, 2^64 - 1].

Directories

Path Synopsis
Check if "mt19937_64" random number generator is concurency safe.
Check if "mt19937_64" random number generator is concurency safe.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL