... |
... |
@@ -120,32 +120,12 @@ |
120
|
120
|
|
121
|
121
|
;;;; Random entries:
|
122
|
122
|
|
123
|
|
-;;; Size of the chunks returned by xoroshiro-chunk.
|
124
|
|
-;;;
|
125
|
|
-;;(defconstant random-chunk-length 32)
|
126
|
|
-
|
127
|
|
-;;; xoroshiro-chunk -- Internal
|
128
|
|
-;;;
|
129
|
|
-;;; This function generaters a 32bit integer between 0 and #xffffffff
|
130
|
|
-;;; inclusive.
|
131
|
|
-;;;
|
132
|
|
-(declaim (inline xoroshiro-chunk))
|
133
|
|
-
|
134
|
|
-(defun xoroshiro-chunk (rng-state)
|
135
|
|
- (declare (type xoro-random-state rng-state)
|
136
|
|
- (optimize (speed 3) (safety 0)))
|
137
|
|
- (let ((cached (xoro-random-state-cached-p rng-state)))
|
138
|
|
- (cond (cached
|
139
|
|
- (setf (xoro-random-state-cached-p rng-state) nil)
|
140
|
|
- (xoro-random-state-rand rng-state))
|
141
|
|
- (t
|
142
|
|
- (let ((s (xoro-random-state-state rng-state)))
|
143
|
|
- (declare (type (simple-array double-float (2)) s))
|
144
|
|
- (multiple-value-bind (r1 r0)
|
145
|
|
- (xoroshiro-next s)
|
146
|
|
- (setf (xoro-random-state-rand rng-state) r0)
|
147
|
|
- (setf (xoro-random-state-cached-p rng-state) t)
|
148
|
|
- r1))))))
|
|
123
|
+#+x86
|
|
124
|
+(declaim (inline xoroshiro-next))
|
|
125
|
+#+x86
|
|
126
|
+(defun xoroshiro-next (state)
|
|
127
|
+ (declare (type (simple-array double-float (2)) state))
|
|
128
|
+ (vm::xoroshiro-next state))
|
149
|
129
|
|
150
|
130
|
#-x86
|
151
|
131
|
(defun xoroshiro-next (state)
|
... |
... |
@@ -225,6 +205,34 @@ |
225
|
205
|
(rotl-36 s1-1 s1-0)
|
226
|
206
|
(setf (aref state 0) (make-double s0-1 s0-0)
|
227
|
207
|
(aref state 1) (make-double r1 r0)))))))
|
|
208
|
+
|
|
209
|
+;;; Size of the chunks returned by xoroshiro-chunk.
|
|
210
|
+;;;
|
|
211
|
+;;(defconstant random-chunk-length 32)
|
|
212
|
+
|
|
213
|
+;;; xoroshiro-chunk -- Internal
|
|
214
|
+;;;
|
|
215
|
+;;; This function generaters a 32bit integer between 0 and #xffffffff
|
|
216
|
+;;; inclusive.
|
|
217
|
+;;;
|
|
218
|
+(declaim (inline xoroshiro-chunk))
|
|
219
|
+
|
|
220
|
+(defun xoroshiro-chunk (rng-state)
|
|
221
|
+ (declare (type xoro-random-state rng-state)
|
|
222
|
+ (optimize (speed 3) (safety 0)))
|
|
223
|
+ (let ((cached (xoro-random-state-cached-p rng-state)))
|
|
224
|
+ (cond (cached
|
|
225
|
+ (setf (xoro-random-state-cached-p rng-state) nil)
|
|
226
|
+ (xoro-random-state-rand rng-state))
|
|
227
|
+ (t
|
|
228
|
+ (let ((s (xoro-random-state-state rng-state)))
|
|
229
|
+ (declare (type (simple-array double-float (2)) s))
|
|
230
|
+ (multiple-value-bind (r1 r0)
|
|
231
|
+ (xoroshiro-next s)
|
|
232
|
+ (setf (xoro-random-state-rand rng-state) r0)
|
|
233
|
+ (setf (xoro-random-state-cached-p rng-state) t)
|
|
234
|
+ r1))))))
|
|
235
|
+
|
228
|
236
|
|
229
|
237
|
;;; %RANDOM-SINGLE-FLOAT, %RANDOM-DOUBLE-FLOAT -- Interface
|
230
|
238
|
;;;
|