minor cleanup
parent
53d21c6c7a
commit
d27252e232
|
@ -15,14 +15,13 @@ TUPLE: mersenne-twister seq i ;
|
||||||
: mt-m 397 ; inline
|
: mt-m 397 ; inline
|
||||||
: mt-a HEX: 9908b0df ; inline
|
: mt-a HEX: 9908b0df ; inline
|
||||||
|
|
||||||
: calculate-y ( y1 y2 mt -- y )
|
: calculate-y ( n seq -- y )
|
||||||
tuck
|
|
||||||
[ nth 32 mask-bit ]
|
[ nth 32 mask-bit ]
|
||||||
[ nth 31 bits ] 2bi* bitor ; inline
|
[ [ 1+ ] [ nth ] bi* 31 bits ] 2bi bitor ; inline
|
||||||
|
|
||||||
: (mt-generate) ( n mt-seq -- next-mt )
|
: (mt-generate) ( n seq -- next-mt )
|
||||||
[
|
[
|
||||||
[ dup 1+ ] [ calculate-y ] bi*
|
calculate-y
|
||||||
[ 2/ ] [ odd? mt-a 0 ? ] bi bitxor
|
[ 2/ ] [ odd? mt-a 0 ? ] bi bitxor
|
||||||
] [
|
] [
|
||||||
[ mt-m + ] [ nth ] bi*
|
[ mt-m + ] [ nth ] bi*
|
||||||
|
|
Loading…
Reference in New Issue