Skip to content

Commit 215d663

Browse files
committed
feat(lint): corrected linting for c files for the new package tinymt32
1 parent 8552387 commit 215d663

File tree

18 files changed

+428
-431
lines changed

18 files changed

+428
-431
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ var o = tinymt32.toJSON();
234234

235235
## Notes
236236

237-
- [TinyMT32][tiny-mersenne-twister] is **not** a cryptographically secure PRNG, as the PRNG is based on a linear recursion. Any pseudorandom number sequence generated by a linear recursion is **insecure**, due to the fact that one can predict future generated outputs by observing a sufficiently long subsequence of generated values.
237+
- [TinyMT32][tiny-mersenne-twister] is _not_ a cryptographically secure PRNG, as the PRNG is based on a linear recursion. Any pseudorandom number sequence generated by a linear recursion is _insecure_, due to the fact that one can predict future generated outputs by observing a sufficiently long subsequence of generated values.
238238
- Compared to other PRNGs, [TinyMT32][tiny-mersenne-twister] has a small state size (`16 bytes`), making it suitable for memory-constrained environments. However, this comes at the cost of a shorter period length compared to the original Mersenne Twister.
239-
- A seed array of length `1` is considered **equivalent** to an integer seed equal to the lone seed array element and vice versa.
240-
- If PRNG state is "shared" (meaning a state array was provided during PRNG creation and **not** copied) and one sets the generator state to a state array having a different length, the PRNG does **not** update the existing shared state and, instead, points to the newly provided state array. In order to synchronize PRNG output according to the new shared state array, the state array for **each** relevant PRNG must be **explicitly** set.
239+
- A seed array of length `1` is considered _equivalent_ to an integer seed equal to the lone seed array element and vice versa.
240+
- If PRNG state is "shared" (meaning a state array was provided during PRNG creation and _not_ copied) and one sets the generator state to a state array having a different length, the PRNG does _not_ update the existing shared state and, instead, points to the newly provided state array. In order to synchronize PRNG output according to the new shared state array, the state array for _each_ relevant PRNG must be _explicitly_ set.
241241
- 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).
242242

243243
</section>
@@ -279,7 +279,7 @@ console.log( bool );
279279

280280
## References
281281

282-
- Saito, Makoto, and Mutsuo Saito. 2008. "SIMD-Oriented Fast Mersenne Twister: A 128-bit Pseudorandom Number Generator." In *Monte Carlo and Quasi-Monte Carlo Methods 2006*, edited by Alexander Keller, Stefan Heinrich, and Harald Niederreiter, 607–22. Berlin, Heidelberg: Springer Berlin Heidelberg. doi:[10.1007/978-3-540-74496-2_36][saito-2008].
282+
- Saito, Makoto, and Mutsuo Saito. 2008. "SIMD-Oriented Fast Mersenne Twister: A 128-bit Pseudorandom Number Generator." In _Monte Carlo and Quasi-Monte Carlo Methods 2006_, edited by Alexander Keller, Stefan Heinrich, and Harald Niederreiter, 607–22. Berlin, Heidelberg: Springer Berlin Heidelberg. doi:[10.1007/978-3-540-74496-2_36][saito-2008].
283283

284284
</section>
285285

@@ -307,8 +307,10 @@ console.log( bool );
307307

308308
[tiny-mersenne-twister]: https://github.com/MersenneTwister-Lab/TinyMT
309309
[saito-2008]: https://doi.org/10.1007/978-3-540-74496-2_36
310-
311-
[@stdlib/array/uint32]: https://github.com/stdlib-js/stdlib
310+
[@stdlib/array/uint32]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint32
311+
[@stdlib/random/base/mt19937]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/base/mt19937
312+
[@stdlib/random/base/minstd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/base/minstd
313+
[@stdlib/random/base/randu]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/base/randu
312314

313315
</section>
314316

lib/node_modules/@stdlib/random/base/tinymt32/benchmark/benchmark.factory.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**
2-
* @license Apache-2.0
3-
*
4-
* Copyright (c) 2025 The Stdlib Authors.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
1818

1919
'use strict';
2020

lib/node_modules/@stdlib/random/base/tinymt32/benchmark/benchmark.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**
2-
* @license Apache-2.0
3-
*
4-
* Copyright (c) 2025 The Stdlib Authors.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
1818

1919
'use strict';
2020

lib/node_modules/@stdlib/random/base/tinymt32/benchmark/c/benchmark.c

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Prints the TAP version.
4040
*/
4141
void print_version() {
42-
printf( "TAP version 13\n" );
42+
printf( "TAP version 13\n" );
4343
}
4444

4545
/**
@@ -49,12 +49,12 @@ void print_version() {
4949
* @param passing total number of passing tests
5050
*/
5151
void print_summary( int total, int passing ) {
52-
printf( "#\n" );
53-
printf( "1..%d\n", total ); // TAP plan
54-
printf( "# total %d\n", total );
55-
printf( "# pass %d\n", passing );
56-
printf( "#\n" );
57-
printf( "# ok\n" );
52+
printf( "#\n" );
53+
printf( "1..%d\n", total ); // TAP plan
54+
printf( "# total %d\n", total );
55+
printf( "# pass %d\n", passing );
56+
printf( "#\n" );
57+
printf( "# ok\n" );
5858
}
5959

6060
/**
@@ -63,13 +63,13 @@ void print_summary( int total, int passing ) {
6363
* @return current time in microseconds
6464
*/
6565
double tic() {
66-
struct timeval t;
67-
int ret = gettimeofday( &t, NULL );
68-
if ( ret != 0 ) {
69-
fprintf( stderr, "Error: Failed to get time.\n" );
70-
exit( 1 );
71-
}
72-
return (double)t.tv_sec + (double)t.tv_usec*1.0e-6;
66+
struct timeval t;
67+
int ret = gettimeofday( &t, NULL );
68+
if ( ret != 0 ) {
69+
fprintf( stderr, "Error: Failed to get time.\n" );
70+
exit( 1 );
71+
}
72+
return (double)t.tv_sec + (double)t.tv_usec*1.0e-6;
7373
}
7474

7575
/**
@@ -79,36 +79,36 @@ double tic() {
7979
* @return random unsigned 32-bit integer
8080
*/
8181
uint32_t next( uint32_t *state ) {
82-
uint32_t y;
83-
uint32_t x;
84-
85-
// Mix state
86-
y = state[3];
87-
x = (state[0] & 0x7FFFFFFF) ^ state[1] ^ state[2];
88-
x ^= (x << 1);
89-
y ^= (y >> 1) ^ x;
90-
state[0] = state[1];
91-
state[1] = state[2];
92-
state[2] = x ^ (y << 10);
93-
state[3] = y;
94-
95-
// Tempering
96-
if (y & 1) {
97-
state[1] ^= MAT1;
98-
state[2] ^= MAT2;
99-
}
100-
101-
y = state[0] + (state[2] >> 8);
102-
return (y ^ TMAT);
82+
uint32_t y;
83+
uint32_t x;
84+
85+
// Mix state
86+
y = state[3];
87+
x = (state[0] & 0x7FFFFFFF) ^ state[1] ^ state[2];
88+
x ^= (x << 1);
89+
y ^= (y >> 1) ^ x;
90+
state[0] = state[1];
91+
state[1] = state[2];
92+
state[2] = x ^ (y << 10);
93+
state[3] = y;
94+
95+
// Tempering
96+
if (y & 1) {
97+
state[1] ^= MAT1;
98+
state[2] ^= MAT2;
99+
}
100+
101+
y = state[0] + (state[2] >> 8);
102+
return (y ^ TMAT);
103103
}
104104

105105
/**
106106
* Returns a normalized pseudorandom number on the interval [0,1).
107107
*
108108
* @return double normalized pseudorandom number
109109
*/
110-
double tinymt32_normalized( tinymt32_t *ctx ) {
111-
return (double)tinymt32_generate_uint32( ctx ) / (double)(UINT32_MAX + 1);
110+
double tinymt32_normalized( uint32_t *state ) {
111+
return (double)next( state ) / (double)(UINT32_MAX + 1);
112112
}
113113

114114
/**
@@ -117,48 +117,48 @@ double tinymt32_normalized( tinymt32_t *ctx ) {
117117
* @return elapsed time in seconds
118118
*/
119119
double benchmark() {
120-
double elapsed;
121-
double t;
122-
uint32_t state[4];
123-
uint32_t v;
124-
int i;
125-
126-
// Initialize state
127-
state[0] = 12345;
128-
state[1] = MAT1;
129-
state[2] = MAT2;
130-
state[3] = TMAT;
131-
132-
t = tic();
133-
for ( i = 0; i < ITERATIONS; i++ ) {
134-
v = tinymt32_normalized( &ctx );
135-
if ( v < 0.0 || v >= 1.0 ) {
136-
printf( "unexpected value: %f\n", v );
137-
exit( 1 );
138-
}
139-
}
140-
elapsed = tic() - t;
141-
if ( v < 0.0 || v >= 1.0 ) {
142-
printf( "Warning: Unexpected value: %f\n", v );
143-
}
144-
return elapsed;
120+
double elapsed;
121+
double t;
122+
uint32_t state[4];
123+
uint32_t v;
124+
int i;
125+
126+
// Initialize state
127+
state[0] = 12345;
128+
state[1] = MAT1;
129+
state[2] = MAT2;
130+
state[3] = TMAT;
131+
132+
t = tic();
133+
for ( i = 0; i < ITERATIONS; i++ ) {
134+
v = tinymt32_normalized( state );
135+
if ( v < 0.0 || v >= 1.0 ) {
136+
printf( "unexpected value: %f\n", v );
137+
exit( 1 );
138+
}
139+
}
140+
elapsed = tic() - t;
141+
if ( v < 0.0 || v >= 1.0 ) {
142+
printf( "Warning: Unexpected value: %f\n", v );
143+
}
144+
return elapsed;
145145
}
146146

147147
/**
148148
* Main execution sequence.
149149
*/
150150
int main( void ) {
151-
double elapsed;
152-
int i;
151+
double elapsed;
152+
int i;
153153

154-
print_version();
154+
print_version();
155155

156-
for ( i = 0; i < REPEATS; i++ ) {
157-
printf( "# c::%s\n", NAME );
158-
elapsed = benchmark();
159-
printf( "ok %d benchmark finished in %0.9fs\n", i+1, elapsed );
160-
}
161-
print_summary( REPEATS, REPEATS );
156+
for ( i = 0; i < REPEATS; i++ ) {
157+
printf( "# c::%s\n", NAME );
158+
elapsed = benchmark();
159+
printf( "ok %d benchmark finished in %0.9fs\n", i+1, elapsed );
160+
}
161+
print_summary( REPEATS, REPEATS );
162162

163-
return 0;
163+
return 0;
164164
}

0 commit comments

Comments
 (0)