Handbook
Glossary
lagged-fibonacci
Vocabulary
random
.
lagged-fibonacci
Definition
USING:
math
specialized-arrays.instances.alien.c-types.double
;
IN:
random.lagged-fibonacci
TUPLE:
lagged-fibonacci
{
u
double-array
initial:
double-array{
}
}
{
pt0
fixnum
initial:
0
}
{
pt1
fixnum
initial:
0
}
;
Methods
USING:
accessors
kernel
math
random.lagged-fibonacci
random.lagged-fibonacci.private
sequences.private
;
M::
lagged-fibonacci
random-float*
( lagged-fibonacci -- n )
lagged-fibonacci
[
pt0>>
]
[
u>>
]
bi
nth-unsafe
lagged-fibonacci
[
pt1>>
]
[
u>>
]
bi
nth-unsafe
-
dup
0.0
<
[
1.0
+
]
when
[
lagged-fibonacci
[
pt0>>
]
[
u>>
]
bi
set-nth-unsafe
lagged-fibonacci
[
adjust-ptr
]
change-pt0
drop
lagged-fibonacci
[
adjust-ptr
]
change-pt1
drop
]
keep
;
inline
USING:
accessors
kernel
math
random
random.lagged-fibonacci
random.lagged-fibonacci.private
sequences
;
M::
lagged-fibonacci
seed-random
( lagged-fibonacci seed -- rnd )
seed
normalize-seed
seed! seed 30082
/i
:>
ij seed 30082 ij
*
-
:>
kl ij 177
/i
177
mod
2
+
:>
i! ij 177
mod
2
+
:>
j! kl 169
/i
178
mod
1
+
:>
k! kl 169
mod
:>
l! lagged-fibonacci
u>>
[
drop
0.0
:>
s! 0.5
:>
t! 0.0
:>
m!
lagged-fibonacci-sig-bits
[
i j
*
179
mod
k
*
179
mod
m! j i! k j! m k! 53 l
*
1
+
169
mod
l! l m
*
64
mod
31
>
[
s t
+
s!
]
when
t 0.5
*
t!
]
times
s
]
map!
drop
lagged-fibonacci
p-r
>>pt0
q-r
>>pt1
;
inline