]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/random/mersenne-twister/mersenne-twister.factor
use radix literals
[factor.git] / basis / random / mersenne-twister / mersenne-twister.factor
index 9fd82a30626a10eb6b4b0985eeca45776bc83a62..908e62fe665e12ee94f104164e4b53a7f527461d 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 ! mersenne twister based on 
 ! http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
-USING: alien.c-types kernel math namespaces sequences
+USING: alien.c-types alien.data kernel math namespaces sequences
 sequences.private system init accessors math.ranges random
 math.bitwise combinators specialized-arrays fry ;
 SPECIALIZED-ARRAY: uint
@@ -14,7 +14,7 @@ TUPLE: mersenne-twister { seq uint-array } { i fixnum } ;
 
 CONSTANT: n 624
 CONSTANT: m 397
-CONSTANT: a uint-array{ 0 HEX: 9908b0df }
+CONSTANT: a uint-array{ 0 0x9908b0df }
 
 : y ( n seq -- y )
     [ nth-unsafe 31 mask-bit ]
@@ -44,13 +44,13 @@ CONSTANT: a uint-array{ 0 HEX: 9908b0df }
     ] each-integer ; inline
 
 : init-mt-seq ( seed -- seq )
-    32 bits n <uint-array>
+    32 bits n uint <c-array>
     [ set-first ] [ init-mt-rest ] [ ] tri ; inline
 
 : mt-temper ( y -- yt )
     dup -11 shift bitxor
-    dup 7 shift HEX: 9d2c5680 bitand bitxor
-    dup 15 shift HEX: efc60000 bitand bitxor
+    dup 7 shift 0x9d2c5680 bitand bitxor
+    dup 15 shift 0xefc60000 bitand bitxor
     dup -18 shift bitxor ; inline
 
 : next-index  ( mt -- i )