Esempio n. 1
0
func main() {
	rand.Seed(time.Now().Unix())

	mt := rand.New(mt64.New())
	mt.Seed(12345)

	ch := make(chan bool)
	for i := 0; i < 21; i++ {
		go PrintInt63(i, mt, ch)
	}
	<-ch
}
func main() {
	initKey := []uint64{0x12345, 0x23456, 0x34567, 0x45678}
	var i uint64

	mt := mt64.New()
	mt.SeedByArray(initKey)

	fmt.Printf("1000 outputs of genrand64_int64()\n") // line from mt19937-64.out.txt
	for i = 0; i < 1000; i++ {
		fmt.Printf("%20d ", mt.Uint64())
		if i%5 == 4 {
			fmt.Printf("\n")
		}
	}

	fmt.Printf("\n1000 outputs of genrand64_real2()\n") // line from mt19937-64.out.txt
	for i = 0; i < 1000; i++ {
		fmt.Printf("%10.8f ", mt.Real2())
		if i%5 == 4 {
			fmt.Printf("\n")
		}
	}
}
func BenchmarkMersenneTwister(b *testing.B) {
	r := mt19937_64.New()
	for i := 0; i < b.N; i++ {
		r.Real1()
	}
}