Handbook
Glossary
sfmt
Vocabulary
random
.
sfmt
.
private
Definition
USING:
classes.struct
math.vectors.simd
specialized-arrays.instances.alien.c-types.uint
specialized-arrays.instances.math.vectors.simd.uint-4
;
IN:
random.sfmt.private
TUPLE:
sfmt
{
state
sfmt-state
initial:
S{
sfmt-state
{
seed 0
}
{
n 0
}
{
m 0
}
{
index 0
}
{
mask
uint-4{
0 0 0 0
}
}
{
parity
uint-4{
0 0 0 0
}
}
{
r1
uint-4{
0 0 0 0
}
}
{
r2
uint-4{
0 0 0 0
}
}
}
}
{
uint-array
uint-array
initial:
uint-array{
}
}
{
uint-4-array
uint-4-array
initial:
uint-4-array{
}
}
;
Methods
USING:
accessors
math
random.sfmt.private
sequences
sequences.private
;
M::
sfmt
generate
( sfmt -- )
sfmt
state>>
:>
state sfmt
uint-4-array>>
:>
array state
n>>
2
-
array
nth
state
r1<<
state
n>>
1
-
array
nth
state
r2<<
state
m>>
:>
m state
n>>
:>
n state
mask>>
:>
mask n m
-
>fixnum
<iota>
[|
i |
i array
nth-unsafe
i m
+
array
nth-unsafe
mask state
r1>>
state
r2>>
formula
:>
r r i array
set-nth-unsafe
state
r2>>
state
r1<<
r state
r2<<
]
each
m 1
-
<iota>
[
n m
-
1
+
+
>fixnum
:>
i i array
nth-unsafe
m n
-
i
+
array
nth-unsafe
mask state
r1>>
state
r2>>
formula
:>
r r i array
set-nth-unsafe
state
r2>>
state
r1<<
r state
r2<<
]
each
0 state
index<<
;
USING:
kernel
random
random.sfmt.private
;
M:
sfmt
random-32*
dup
refill-sfmt?
[
dup
generate
]
when
next
;
inline
USING:
accessors
kernel
random
random.sfmt.private
;
M:
sfmt
seed-random
[
[
state>>
]
dip
>>seed
drop
]
[
drop
init-sfmt
]
2bi
;