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
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/random/base/pcg32/lib/factory.js
+35-33Lines changed: 35 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -46,11 +46,11 @@ var randuint32 = require( './rand_uint32.js' );
46
46
varNORMALIZATION_CONSTANT=UINT32_MAX+1;
47
47
varMAX_SEED=UINT32_MAX>>>0;// asm type annotation
48
48
49
-
// LCG multiplier
50
-
varMULTIPLIER=[0x4C957F2D>>>0,0x5851F42D>>>0];// asm type annotation
49
+
// Define the LCG multiplier
50
+
varMULTIPLIER=[0x5851F42D>>>0,0x4C957F2D>>>0];// asm type annotation
51
51
52
-
// LCG increment, controls the stream. #TODO: Make user definable like seed
53
-
varINCREMENT=[0x0000DEAD>>>0,0xBEEF0000>>>0];// asm type annotation
52
+
// Define the LCG increment which controls the stream. #TODO: Make user definable like seed
53
+
varINCREMENT=[0xBEEF0000>>>0,0x0000DEAD>>>0];// asm type annotation
54
54
55
55
// Define the size of state as a multiple of 32-bits
56
56
varN=2;
@@ -216,10 +216,11 @@ function factory( options ) {
216
216
217
217
// Initialize the internal PRNG state:
218
218
pcg32();
219
-
state.set(addUint64(state,[
220
-
seed[0],
221
-
(slen>1) ? seed[1] : 0
222
-
]));
219
+
if(slen>1){
220
+
state.set(addUint64(state,[seed[0],seed[1]]));
221
+
}else{
222
+
state.set(addUint64(state,[0,seed[0]]));
223
+
}
223
224
pcg32();
224
225
}else{
225
226
thrownewTypeError(format('invalid option. `%s` option must be either a positive integer less than the maximum unsigned 32-bit integer or an array-like object containing integer values less than the maximum unsigned 32-bit integer. Option: `%s`.','seed',seed));
@@ -249,7 +250,7 @@ function factory( options ) {
249
250
250
251
// Initialize the internal PRNG state:
251
252
pcg32();
252
-
state.set(addUint64(state,[seed[0],0]));
253
+
state.set(addUint64(state,[0,seed[0]]));
253
254
pcg32();
254
255
}
255
256
@@ -417,56 +418,57 @@ function factory( options ) {
0 commit comments