You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param {boolean} FLG - flag indicating whether the state array was provided as an option (true) or an argument (false)
72
71
* @returns {(Error|null)} an error or `null`
73
72
*/
@@ -108,13 +107,13 @@ function verifyState( state, FLG ) {
108
107
* Returns a linear congruential pseudorandom number generator (LCG) based on Park and Miller.
109
108
*
110
109
* @param {Options} [options] - options
111
-
* @param {PRNGSeedMINSTD} [options.seed] - pseudorandom number generator seed
112
-
* @param {PRNGStateMINSTD} [options.state] - pseudorandom number generator state
110
+
* @param {PRNGSeedXORSHIFT} [options.seed] - pseudorandom number generator seed
111
+
* @param {PRNGStateXORSHIFT} [options.state] - pseudorandom number generator state
113
112
* @param {boolean} [options.copy=true] - boolean indicating whether to copy a provided pseudorandom number generator state
114
113
* @throws {TypeError} options argument must be an object
115
114
* @throws {TypeError} a seed must be either a positive integer less than the maximum signed 32-bit integer or an array-like object containing integers less than the maximum signed 32-bit integer
116
115
* @throws {RangeError} a numeric seed must be a positive integer less than the maximum signed 32-bit integer
117
-
* @throws {TypeError} state must be an `Int32Array`
116
+
* @throws {TypeError} state must be an `Uint32Array`
118
117
* @throws {Error} must provide a valid state
119
118
* @throws {TypeError} `copy` option must be a boolean
120
119
* @returns {PRNG} LCG PRNG
@@ -132,7 +131,7 @@ function verifyState( state, FLG ) {
132
131
* });
133
132
*
134
133
* var v = xorshift();
135
-
* // returns 20739838
134
+
* // returns 332584831
136
135
*/
137
136
functionfactory(options){
138
137
varSTATE;
@@ -156,8 +155,8 @@ function factory( options ) {
156
155
if(hasOwnProp(options,'state')){
157
156
state=options.state;
158
157
opts.state=true;
159
-
if(!isInt32Array(state)){
160
-
thrownewTypeError(format('invalid option. `%s` option must be an Int32Array. Option: `%s`.','state',state));
158
+
if(!isUint32Array(state)){
159
+
thrownewTypeError(format('invalid option. `%s` option must be an Uint32Array. Option: `%s`.','state',state));
161
160
}
162
161
err=verifyState(state,true);
163
162
if(err){
@@ -166,14 +165,14 @@ function factory( options ) {
thrownewTypeError(format('invalid option. `%s` option must be either a positive integer less than the maximum signed 32-bit integer or an array-like object containing integer values less than the maximum signed 32-bit integer. Option: `%s`.','seed',seed));
211
210
}
212
211
}else{
213
-
seed=randint32()|0;// asm type annotation
212
+
seed=randint32()>>>0;// asm type annotation
214
213
}
215
214
}
216
215
}else{
217
-
seed=randint32()|0;// asm type annotation
216
+
seed=randint32()>>>0;// asm type annotation
218
217
}
219
218
if(state===void0){
220
-
STATE=newInt32Array(STATE_FIXED_LENGTH+1);
219
+
STATE=newUint32Array(STATE_FIXED_LENGTH+1);
221
220
222
221
// Initialize sections:
223
222
STATE[0]=STATE_ARRAY_VERSION;
@@ -227,10 +226,10 @@ function factory( options ) {
@@ -262,11 +261,11 @@ function factory( options ) {
262
261
* Returns the PRNG seed.
263
262
*
264
263
* @private
265
-
* @returns {PRNGSeedMINSTD} seed
264
+
* @returns {PRNGSeedXORSHIFT} seed
266
265
*/
267
266
functiongetSeed(){
268
267
varlen=STATE[SEED_SECTION_OFFSET];
269
-
returngcopy(len,seed,1,newInt32Array(len),1);
268
+
returngcopy(len,seed,1,newUint32Array(len),1);
270
269
}
271
270
272
271
/**
@@ -317,11 +316,11 @@ function factory( options ) {
317
316
* - The first element of each section following the preamble specifies the section length. The remaining section elements comprise the section contents.
318
317
*
319
318
* @private
320
-
* @returns {PRNGStateMINSTD} current state
319
+
* @returns {PRNGStateXORSHIFT} current state
321
320
*/
322
321
functiongetState(){
323
322
varlen=STATE.length;
324
-
returngcopy(len,STATE,1,newInt32Array(len),1);
323
+
returngcopy(len,STATE,1,newUint32Array(len),1);
325
324
}
326
325
327
326
/**
@@ -333,14 +332,14 @@ function factory( options ) {
333
332
* - If PRNG state is "shared" and one sets the generator state to a state array of the same length, the PRNG state is updated (along with the state of all other PRNGs sharing the PRNG's state array).
334
333
*
335
334
* @private
336
-
* @param {PRNGStateMINSTD} s - generator state
337
-
* @throws {TypeError} must provide an `Int32Array`
335
+
* @param {PRNGStateXORSHIFT} s - generator state
336
+
* @throws {TypeError} must provide an `Uint32Array`
338
337
* @throws {Error} must provide a valid state
339
338
*/
340
339
functionsetState(s){
341
340
varerr;
342
-
if(!isInt32Array(s)){
343
-
thrownewTypeError(format('invalid argument. Must provide an Int32Array. Value: `%s`.',s));
341
+
if(!isUint32Array(s)){
342
+
thrownewTypeError(format('invalid argument. Must provide an Uint32Array. Value: `%s`.',s));
344
343
}
345
344
err=verifyState(s,false);
346
345
if(err){
@@ -356,15 +355,15 @@ function factory( options ) {
0 commit comments