Skip to content
Snippets Groups Projects
Commit ee095256 authored by dtc's avatar dtc
Browse files

Initialise the random state index to mt19937-n to force the sequence

to start with numbers generated by the MT19937 algorithm rather than
the initial seed values; from Pierre R. Mai.
parent ff06743d
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
;;; placed in the Public domain, and is provided 'as is'. ;;; placed in the Public domain, and is provided 'as is'.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/rand-mt19937.lisp,v 1.8 1999/01/20 12:01:38 dtc Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/rand-mt19937.lisp,v 1.9 1999/08/14 15:40:41 dtc Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -36,8 +36,10 @@ ...@@ -36,8 +36,10 @@
;;; 2: Index k. ;;; 2: Index k.
;;; 3-626: State. ;;; 3-626: State.
;;; Generate and initialise a new random-state array. Index is ;;; Generate and initialise a new random-state array. The states are
;;; initialised to 1 and the states to 32bit integers excluding zero. ;;; initialised to 32bit integers excluding zero, and the index is
;;; initialised to mt19937-n forcing an update when the first number
;;; is generated.
;;; ;;;
;;; Seed - A 32bit number, not zero. ;;; Seed - A 32bit number, not zero.
;;; ;;;
...@@ -49,7 +51,7 @@ ...@@ -49,7 +51,7 @@
(let ((state (or state (make-array 627 :element-type '(unsigned-byte 32))))) (let ((state (or state (make-array 627 :element-type '(unsigned-byte 32)))))
(declare (type (simple-array (unsigned-byte 32) (627)) state)) (declare (type (simple-array (unsigned-byte 32) (627)) state))
(setf (aref state 1) #x9908b0df) (setf (aref state 1) #x9908b0df)
(setf (aref state 2) 1) (setf (aref state 2) mt19937-n)
(setf (aref state 3) seed) (setf (aref state 3) seed)
(do ((k 1 (1+ k))) (do ((k 1 (1+ k)))
((>= k 624)) ((>= k 624))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment