File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed
Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,13 @@ fn get_first_state(seed_data []u32) []u64 {
7373
7474// calculate_state returns a random state array calculated from the `seed_data`.
7575@[ignore_overflow]
76- fn calculate_state (seed_data []u32 , mut state []u64 ) [] u64 {
76+ fn calculate_state (seed_data []u32 , mut state []u64 ) {
7777 lo := u64 (seed_data[0 ])
7878 hi := u64 (seed_data[1 ])
7979 state[0 ] = u64 ((hi << 32 ) | lo)
8080 for j := 1 ; j < nn; j++ {
8181 state[j] = u64 (6364136223846793005 ) * (state[j - 1 ] ^ (state[j - 1 ] >> 62 )) + u64 (j)
8282 }
83- return * state
8483}
8584
8685// seed sets the current random state based on `seed_data`.
@@ -90,7 +89,7 @@ pub fn (mut rng MT19937RNG) seed(seed_data []u32) {
9089 eprintln ('mt19937 needs only two 32bit integers as seed: [lower, higher]' )
9190 exit (1 )
9291 }
93- rng. state = calculate_state (seed_data, mut rng.state)
92+ calculate_state (seed_data, mut rng.state)
9493 rng.mti = nn
9594 rng.bytes_left = 0
9695 rng.buffer = 0
Original file line number Diff line number Diff line change @@ -24,8 +24,7 @@ fn mt19937_basic_test() {
2424fn gen_randoms (seed_data []u32 , bound int ) []u64 {
2525 bound_u64 := u64 (bound)
2626 mut randoms := []u64 {len: (20 )}
27- x := mt19937 .MT19937 RNG{}
28- mut rnd := rand.PRNG (x)
27+ mut rnd := & rand.PRNG (& mt19937 .MT19937 RNG{})
2928 rnd.seed (seed_data)
3029 for i in 0 .. 20 {
3130 randoms[i] = rnd.u64n (bound_u64 ) or { panic ("Couldn't obtain random u64" ) }
You can’t perform that action at this time.
0 commit comments