]> gitweb.factorcode.org Git - factor.git/commitdiff
Rename random.pcg-mwc[-vec] to random.pcg[-vec]
authorAlexander Ilin <alex.ilin@protonmail.com>
Tue, 4 Jan 2022 19:01:17 +0000 (20:01 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 20 Jan 2023 22:15:14 +0000 (14:15 -0800)
12 files changed:
extra/random/pcg-mwc-vec/authors.txt [deleted file]
extra/random/pcg-mwc-vec/pcg-mwc-vec.factor [deleted file]
extra/random/pcg-mwc-vec/tags.txt [deleted file]
extra/random/pcg-mwc/authors.txt [deleted file]
extra/random/pcg-mwc/pcg-mwc.factor [deleted file]
extra/random/pcg-mwc/tags.txt [deleted file]
extra/random/pcg-vec/authors.txt [new file with mode: 0644]
extra/random/pcg-vec/pcg-vec.factor [new file with mode: 0644]
extra/random/pcg-vec/tags.txt [new file with mode: 0644]
extra/random/pcg/authors.txt [new file with mode: 0644]
extra/random/pcg/pcg.factor [new file with mode: 0644]
extra/random/pcg/tags.txt [new file with mode: 0644]

diff --git a/extra/random/pcg-mwc-vec/authors.txt b/extra/random/pcg-mwc-vec/authors.txt
deleted file mode 100644 (file)
index 8e1955f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Alexander Ilin
diff --git a/extra/random/pcg-mwc-vec/pcg-mwc-vec.factor b/extra/random/pcg-mwc-vec/pcg-mwc-vec.factor
deleted file mode 100644 (file)
index fbbafe5..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-! Copyright (C) 2022 Alexander Ilin.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types arrays kernel math math.bitwise
-random sequences ;
-IN: random.pcg-mwc-vec
-
-! https://github.com/tkaitchuck/Mwc256XXA64/blob/main/impl/src/gen64.rs
-! https://www.pcg-random.org/
-
-! The state is an array of four u64 values in this order: x1, x2, x3, c.
-! Since we are only returning 32 bits per step of this 64-bit PRNG, the rest are
-! saved in the rem field.
-TUPLE: Mwc256XXA64 state rem ;
-
-<PRIVATE
-
-CONSTANT: MULTIPLIER 0xfeb3_4465_7c0a_f413
-
-: big>d/d ( n -- low high )
-    dup -64 shift [ 64 bits ] bi@ ; inline
-
-: multiply ( n -- low high )
-    MULTIPLIER * big>d/d ; inline
-
-: permute ( high x1 x2 x3 -- n )
-    [ bitxor ] 2bi@ W+ ; inline
-
-: rot-state ( obj x1 c -- obj' )
-    [ over state>> first2 ] dip 4array >>state ; inline
-
-: update-state ( obj low high -- )
-    [ over state>> last + big>d/d ] dip W+ rot-state drop ; inline
-
-: next-u64 ( obj -- n )
-    dup state>> third multiply [ pick state>> first3 permute ] keep
-    swap [ update-state ] dip ; inline
-
-! If cache is f, use quot to produce a new pair of values from obj: one to be
-! cached, and one to be used. Otherwise return cache as value and cache' = f.
-: cache ( obj cache/f quot: ( obj -- n1 n2 ) -- value cache' )
-    [ nip f ] swap if* ; inline
-
-PRIVATE>
-
-: <Mwc256XXA64> ( key1 key2 -- obj )
-    0xcafef00dd15ea5e5 0x14057B7EF767814F 4array f \ Mwc256XXA64 boa
-    6 [ dup next-u64 drop ] times ;
-
-M: Mwc256XXA64 random-32*
-    dup [ [ next-u64 d>w/w ] cache ] change-rem drop ;
diff --git a/extra/random/pcg-mwc-vec/tags.txt b/extra/random/pcg-mwc-vec/tags.txt
deleted file mode 100644 (file)
index fb5bea3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-rng
diff --git a/extra/random/pcg-mwc/authors.txt b/extra/random/pcg-mwc/authors.txt
deleted file mode 100644 (file)
index 8e1955f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Alexander Ilin
diff --git a/extra/random/pcg-mwc/pcg-mwc.factor b/extra/random/pcg-mwc/pcg-mwc.factor
deleted file mode 100644 (file)
index f3992b6..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-! Copyright (C) 2022 Alexander Ilin.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types classes.struct kernel locals math
-math.bitwise random ;
-IN: random.pcg-mwc
-
-! https://github.com/tkaitchuck/Mwc256XXA64/blob/main/impl/src/gen64.rs
-! https://www.pcg-random.org/
-
-! Since we are only returning 32 bits per step of this 64-bit PRNG, the rest are
-! saved in the rem field.
-TUPLE: Mwc256XXA64 x1 x2 x3 c rem ;
-
-<PRIVATE
-
-CONSTANT: MULTIPLIER 0xfeb3_4465_7c0a_f413
-
-: big>d/d ( n -- low high )
-    dup -64 shift [ 64 bits ] bi@ ; inline
-
-: multiply ( n -- low high )
-    MULTIPLIER * big>d/d ; inline
-
-: permute ( high x1 x2 x3 -- n )
-    [ bitxor ] 2bi@ W+ ; inline
-
-:: rot-state ( obj x1 c -- struct' )
-    obj
-        obj x2>> >>x3
-        obj x1>> >>x2
-        x1 >>x1
-        c >>c ; inline
-
-: update-state ( obj low high -- )
-    [ over c>> + big>d/d ] dip W+ rot-state drop ; inline
-
-: next-u64 ( obj -- n )
-    dup x3>> multiply [ pick [ x1>> ] [ x2>> ] [ x3>> ] tri permute ] keep
-    swap [ update-state ] dip ; inline
-
-! If cache is f, use quot to produce a new pair of values from obj: one to be
-! cached, and one to be used. Otherwise return cache as value and cache' = f.
-: cache ( obj cache/f quot: ( obj -- n1 n2 ) -- value cache' )
-    [ nip f ] swap if* ; inline
-
-PRIVATE>
-
-: <Mwc256XXA64> ( key1 key2 -- obj )
-    0xcafef00dd15ea5e5 0x14057B7EF767814F f Mwc256XXA64 boa
-    6 [ dup next-u64 drop ] times ;
-
-M: Mwc256XXA64 random-32*
-    dup [ [ next-u64 d>w/w ] cache ] change-rem drop ;
-
-! USING: random random.pcg-mwc random.pcg-mwc-vec ;
-! gc 0 0 random.pcg-mwc:<Mwc256XXA64> [ 10,000,000 [ dup random-32* drop ] times ] time drop
-! gc 0 0 random.pcg-mwc-vec:<Mwc256XXA64> [ 10,000,000 [ dup random-32* drop ] times ] time drop
diff --git a/extra/random/pcg-mwc/tags.txt b/extra/random/pcg-mwc/tags.txt
deleted file mode 100644 (file)
index fb5bea3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-rng
diff --git a/extra/random/pcg-vec/authors.txt b/extra/random/pcg-vec/authors.txt
new file mode 100644 (file)
index 0000000..8e1955f
--- /dev/null
@@ -0,0 +1 @@
+Alexander Ilin
diff --git a/extra/random/pcg-vec/pcg-vec.factor b/extra/random/pcg-vec/pcg-vec.factor
new file mode 100644 (file)
index 0000000..e122c94
--- /dev/null
@@ -0,0 +1,50 @@
+! Copyright (C) 2022 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien.c-types arrays kernel math math.bitwise
+random sequences ;
+IN: random.pcg-vec
+
+! https://github.com/tkaitchuck/Mwc256XXA64/blob/main/impl/src/gen64.rs
+! https://www.pcg-random.org/
+
+! The state is an array of four u64 values in this order: x1, x2, x3, c.
+! Since we are only returning 32 bits per step of this 64-bit PRNG, the rest are
+! saved in the rem field.
+TUPLE: Mwc256XXA64 state rem ;
+
+<PRIVATE
+
+CONSTANT: MULTIPLIER 0xfeb3_4465_7c0a_f413
+
+: big>d/d ( n -- low high )
+    dup -64 shift [ 64 bits ] bi@ ; inline
+
+: multiply ( n -- low high )
+    MULTIPLIER * big>d/d ; inline
+
+: permute ( high x1 x2 x3 -- n )
+    [ bitxor ] 2bi@ W+ ; inline
+
+: rot-state ( obj x1 c -- obj' )
+    [ over state>> first2 ] dip 4array >>state ; inline
+
+: update-state ( obj low high -- )
+    [ over state>> last + big>d/d ] dip W+ rot-state drop ; inline
+
+: next-u64 ( obj -- n )
+    dup state>> third multiply [ pick state>> first3 permute ] keep
+    swap [ update-state ] dip ; inline
+
+! If cache is f, use quot to produce a new pair of values from obj: one to be
+! cached, and one to be used. Otherwise return cache as value and cache' = f.
+: cache ( obj cache/f quot: ( obj -- n1 n2 ) -- value cache' )
+    [ nip f ] swap if* ; inline
+
+PRIVATE>
+
+: <Mwc256XXA64> ( key1 key2 -- obj )
+    0xcafef00dd15ea5e5 0x14057B7EF767814F 4array f \ Mwc256XXA64 boa
+    6 [ dup next-u64 drop ] times ;
+
+M: Mwc256XXA64 random-32*
+    dup [ [ next-u64 d>w/w ] cache ] change-rem drop ;
diff --git a/extra/random/pcg-vec/tags.txt b/extra/random/pcg-vec/tags.txt
new file mode 100644 (file)
index 0000000..fb5bea3
--- /dev/null
@@ -0,0 +1 @@
+rng
diff --git a/extra/random/pcg/authors.txt b/extra/random/pcg/authors.txt
new file mode 100644 (file)
index 0000000..8e1955f
--- /dev/null
@@ -0,0 +1 @@
+Alexander Ilin
diff --git a/extra/random/pcg/pcg.factor b/extra/random/pcg/pcg.factor
new file mode 100644 (file)
index 0000000..2f9669e
--- /dev/null
@@ -0,0 +1,57 @@
+! Copyright (C) 2022 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien.c-types classes.struct kernel locals math
+math.bitwise random ;
+IN: random.pcg
+
+! https://github.com/tkaitchuck/Mwc256XXA64/blob/main/impl/src/gen64.rs
+! https://www.pcg-random.org/
+
+! Since we are only returning 32 bits per step of this 64-bit PRNG, the rest are
+! saved in the rem field.
+TUPLE: Mwc256XXA64 x1 x2 x3 c rem ;
+
+<PRIVATE
+
+CONSTANT: MULTIPLIER 0xfeb3_4465_7c0a_f413
+
+: big>d/d ( n -- low high )
+    dup -64 shift [ 64 bits ] bi@ ; inline
+
+: multiply ( n -- low high )
+    MULTIPLIER * big>d/d ; inline
+
+: permute ( high x1 x2 x3 -- n )
+    [ bitxor ] 2bi@ W+ ; inline
+
+:: rot-state ( obj x1 c -- struct' )
+    obj
+        obj x2>> >>x3
+        obj x1>> >>x2
+        x1 >>x1
+        c >>c ; inline
+
+: update-state ( obj low high -- )
+    [ over c>> + big>d/d ] dip W+ rot-state drop ; inline
+
+: next-u64 ( obj -- n )
+    dup x3>> multiply [ pick [ x1>> ] [ x2>> ] [ x3>> ] tri permute ] keep
+    swap [ update-state ] dip ; inline
+
+! If cache is f, use quot to produce a new pair of values from obj: one to be
+! cached, and one to be used. Otherwise return cache as value and cache' = f.
+: cache ( obj cache/f quot: ( obj -- n1 n2 ) -- value cache' )
+    [ nip f ] swap if* ; inline
+
+PRIVATE>
+
+: <Mwc256XXA64> ( key1 key2 -- obj )
+    0xcafef00dd15ea5e5 0x14057B7EF767814F f Mwc256XXA64 boa
+    6 [ dup next-u64 drop ] times ;
+
+M: Mwc256XXA64 random-32*
+    dup [ [ next-u64 d>w/w ] cache ] change-rem drop ;
+
+! USING: random random.pcg random.pcg-vec ;
+! gc 0 0 random.pcg:<Mwc256XXA64> [ 10,000,000 [ dup random-32* drop ] times ] time drop
+! gc 0 0 random.pcg-vec:<Mwc256XXA64> [ 10,000,000 [ dup random-32* drop ] times ] time drop
diff --git a/extra/random/pcg/tags.txt b/extra/random/pcg/tags.txt
new file mode 100644 (file)
index 0000000..fb5bea3
--- /dev/null
@@ -0,0 +1 @@
+rng