Skip to content

Commit deaf4bb

Browse files
committed
Add separate state length property
1 parent 4db1063 commit deaf4bb

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

lib/node_modules/@stdlib/random/base/mt19937/README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,18 @@ r = mt19937();
170170
// ...
171171
```
172172

173+
#### mt19937.STATE_LENGTH
174+
175+
Length of generator state.
176+
177+
```javascript
178+
var len = mt19937.STATE_LENGTH;
179+
// returns <number>
180+
```
181+
173182
#### mt19937.STATE_SIZE
174183

175-
Size of generator state.
184+
Size (in bytes) of generator state.
176185

177186
```javascript
178187
var sz = mt19937.STATE_SIZE;

lib/node_modules/@stdlib/random/base/mt19937/docs/repl.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,16 @@
129129
<number>
130130

131131

132+
{{alias}}.STATE_LENGTH
133+
Length of generator state.
134+
135+
Examples
136+
--------
137+
> var len = {{alias}}.STATE_LENGTH;
138+
139+
132140
{{alias}}.STATE_SIZE
133-
Size of generator state.
141+
Size (in bytes) of generator state.
134142

135143
Examples
136144
--------

lib/node_modules/@stdlib/random/base/mt19937/lib/factory.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ function factory( options ) {
415415
'get': getState,
416416
'set': setState
417417
});
418-
setReadOnly( mt19937, 'STATE_SIZE', N+1 );
418+
setReadOnly( mt19937, 'STATE_LENGTH', N+1 );
419+
setReadOnly( mt19937, 'STATE_SIZE', mt19937.STATE_LENGTH/4 ); // 4 bytes per uint32
419420

420421
setReadOnly( normalized, 'NAME', mt19937.NAME );
421422
defineProperty( normalized, 'SEED', {
@@ -431,6 +432,7 @@ function factory( options ) {
431432
'get': getState,
432433
'set': setState
433434
});
435+
setReadOnly( normalized, 'STATE_LENGTH', mt19937.STATE_LENGTH );
434436
setReadOnly( normalized, 'STATE_SIZE', mt19937.STATE_SIZE );
435437

436438
return mt19937;

lib/node_modules/@stdlib/random/base/mt19937/test/test.factory.js

+12
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ tape( 'attached to the returned function is the generator state', function test(
276276
t.end();
277277
});
278278

279+
tape( 'attached to the returned function is the generator state length', function test( t ) {
280+
var mt19937 = factory();
281+
t.equal( typeof mt19937.STATE_LENGTH, 'number', 'has `STATE_LENGTH` property' );
282+
t.end();
283+
});
284+
279285
tape( 'attached to the returned function is the generator state size', function test( t ) {
280286
var mt19937 = factory();
281287
t.equal( typeof mt19937.STATE_SIZE, 'number', 'has `STATE_SIZE` property' );
@@ -409,6 +415,12 @@ tape( 'attached to the `normalized` method is the generator state size', functio
409415
t.end();
410416
});
411417

418+
tape( 'attached to the `normalized` method is the generator state length', function test( t ) {
419+
var mt19937 = factory();
420+
t.equal( typeof mt19937.normalized.STATE_LENGTH, 'number', 'has `STATE_LENGTH` property' );
421+
t.end();
422+
});
423+
412424
tape( 'if the `STATE` property is set to a value other than a Uint32Array, an error is thrown (normalized)', function test( t ) {
413425
var mt19937;
414426
var values;

lib/node_modules/@stdlib/random/base/mt19937/test/test.js

+10
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ tape( 'attached to the main export is the generator state', function test( t ) {
7171
t.end();
7272
});
7373

74+
tape( 'attached to the main export is the generator state length', function test( t ) {
75+
t.equal( typeof mt19937.STATE_LENGTH, 'number', 'has `STATE_LENGTH` property' );
76+
t.end();
77+
});
78+
7479
tape( 'attached to the main export is the generator state size', function test( t ) {
7580
t.equal( typeof mt19937.STATE_SIZE, 'number', 'has `STATE_SIZE` property' );
7681
t.end();
@@ -124,6 +129,11 @@ tape( 'attached to the `normalized` method is the generator state', function tes
124129
t.end();
125130
});
126131

132+
tape( 'attached to the `normalized` method is the generator state length', function test( t ) {
133+
t.equal( typeof mt19937.normalized.STATE_LENGTH, 'number', 'has `STATE_LENGTH` property' );
134+
t.end();
135+
});
136+
127137
tape( 'attached to the `normalized` method is the generator state size', function test( t ) {
128138
t.equal( typeof mt19937.normalized.STATE_SIZE, 'number', 'has `STATE_SIZE` property' );
129139
t.end();

0 commit comments

Comments
 (0)