Skip to content

Commit dc8d9a6

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 89c41ab + f0df313 commit dc8d9a6

File tree

15 files changed

+413
-168
lines changed

15 files changed

+413
-168
lines changed

docs/contributing/FAQ.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ limitations under the License.
3131
- [What should I do if JavaScript linting on my commits fails because my function exceeds the maximum permissible number of parameters?](#max-params)
3232
- [I have opened a pull request, where can I seek feedback?](#pr-feedback)
3333
- [I need to generate fixtures for my tests. How can I do that, and what are the best references for inspiration?](#generate-fixtures)
34-
- [I am facing a `Shadowed declaration` linting error in my C files, how can I fix it?](#shadowed-declaration)
3534
- [I am facing a `Uninitialized variable` linting error in my C files, how can I fix it?](#uninitialized-variable)
3635
- [I have the required packages in the expected paths, but I am still encountering an error like this while compiling the native add-on.](#compilation-error)
3736
- [When should I use decimals in examples, benchmarks, and documentation, and when should I avoid them?](#decimal-usage)
@@ -145,23 +144,6 @@ Consider joining our [Gitter channel][stdlib-gitter]! We are proud to have a ver
145144

146145
Tests are a crucial part of any standard library package. We take our goal of achieving 100% test coverage very seriously and expect your work to be backed by tests. Often, you may need to generate fixtures to validate your implementation against an existing reliable source. You can use Julia, R, Python, or other languages to generate fixtures. To see how we do this, refer to these example scripts: [Python fixture script][python-fixtures], [Julia fixture script][julia-fixtures].
147146

148-
<a name="shadowed-declaration"></a>
149-
150-
## I am facing a `Shadowed declaration` linting error in my C files, how can I fix it?
151-
152-
```bash
153-
STDLIB_MATH_BASE_NAPI_MODULE_FF_F( stdlib_base_gcdf ) ^
154-
/home/runner/work/stdlib/stdlib/lib/node_modules/@stdlib/math/base/special/gcdf/include/stdlib/math/base/special/gcdf.h:32:7:
155-
note: Shadowed declaration float stdlib_base_gcdf( const float a, const float b );
156-
```
157-
158-
You can suppress that warning by adding a `// cppcheck-suppress shadowFunction` comment above the function. For example:
159-
160-
```c
161-
// cppcheck-suppress shadowFunction
162-
STDLIB_MATH_BASE_NAPI_MODULE_FF_F( stdlib_base_gcdf )
163-
```
164-
165147
<a name="uninitialized-variable"></a>
166148

167149
## I am facing a `Uninitialized variable` linting error in my C files, how can I fix it?

lib/node_modules/@stdlib/math/base/special/negalucas/benchmark/benchmark.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bench( pkg, function benchmark( b ) {
4040
var y;
4141
var i;
4242

43-
x = discreteUniform( 100, -77, 0 );
43+
x = discreteUniform( 100, -76, 0 );
4444

4545
b.tic();
4646
for ( i = 0; i < b.iterations; i++ ) {
@@ -67,7 +67,7 @@ bench( pkg+'::analytic', function benchmark( b ) {
6767
return pow( -1.0, an ) * round( pow( PHI, an ) );
6868
}
6969

70-
x = discreteUniform( 100, -77, 0 );
70+
x = discreteUniform( 100, -76, 0 );
7171

7272
b.tic();
7373
for ( i = 0; i < b.iterations; i++ ) {
@@ -89,7 +89,7 @@ bench( pkg+'::table', function benchmark( b ) {
8989
var y;
9090
var i;
9191

92-
x = discreteUniform( 100, -77, 0 );
92+
x = discreteUniform( 100, -76, 0 );
9393

9494
b.tic();
9595
for ( i = 0; i < b.iterations; i++ ) {
@@ -197,7 +197,7 @@ bench( pkg+'::naive_iterative', function benchmark( b ) {
197197
return arr[ an ];
198198
}
199199

200-
x = discreteUniform( 100, -77, 0 );
200+
x = discreteUniform( 100, -76, 0 );
201201

202202
b.tic();
203203
for ( i = 0; i < b.iterations; i++ ) {
@@ -238,7 +238,7 @@ bench( pkg+'::iterative', function benchmark( b ) {
238238
return b;
239239
}
240240

241-
x = discreteUniform( 100, -77, 0 );
241+
x = discreteUniform( 100, -76, 0 );
242242

243243
b.tic();
244244
for ( i = 0; i < b.iterations; i++ ) {
@@ -281,7 +281,7 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) {
281281
return arr[ an ];
282282
}
283283

284-
x = discreteUniform( 100, -77, 0 );
284+
x = discreteUniform( 100, -76, 0 );
285285

286286
b.tic();
287287
for ( i = 0; i < b.iterations; i++ ) {
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
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+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var addon = require( './../src/addon.node' );
24+
25+
26+
// MAIN //
27+
28+
/**
29+
* Computes the nth negaLucas number.
30+
*
31+
* @private
32+
* @param {NonPositiveInteger} n - the negaLucas number to compute
33+
* @returns {integer} negaLucas number
34+
*
35+
* @example
36+
* var y = negalucas( 0 );
37+
* // returns 2
38+
*
39+
* @example
40+
* y = negalucas( -1 );
41+
* // returns -1
42+
*
43+
* @example
44+
* y = negalucas( -2 );
45+
* // returns 3
46+
*
47+
* @example
48+
* y = negalucas( -3 );
49+
* // returns -4
50+
*
51+
* @example
52+
* y = negalucas( -4 );
53+
* // returns 7
54+
*
55+
* @example
56+
* y = negalucas( -5 );
57+
* // returns -11
58+
*
59+
* @example
60+
* y = negalucas( -6 );
61+
* // returns 18
62+
*/
63+
function negalucas( n ) {
64+
return addon( n );
65+
}
66+
67+
68+
// EXPORTS //
69+
70+
module.exports = negalucas;

lib/node_modules/@stdlib/stats/base/meanpn/README.md

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2020 The Stdlib Authors.
5+
Copyright (c) 2025 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -51,33 +51,28 @@ The [arithmetic mean][arithmetic-mean] is defined as
5151
var meanpn = require( '@stdlib/stats/base/meanpn' );
5252
```
5353

54-
#### meanpn( N, x, stride )
54+
#### meanpn( N, x, strideX )
5555

56-
Computes the [arithmetic mean][arithmetic-mean] of a strided array `x` using a two-pass error correction algorithm.
56+
Computes the [arithmetic mean][arithmetic-mean] of a strided array using a two-pass error correction algorithm.
5757

5858
```javascript
5959
var x = [ 1.0, -2.0, 2.0 ];
60-
var N = x.length;
6160

62-
var v = meanpn( N, x, 1 );
61+
var v = meanpn( x.length, x, 1 );
6362
// returns ~0.3333
6463
```
6564

6665
The function has the following parameters:
6766

6867
- **N**: number of indexed elements.
6968
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
70-
- **stride**: index increment for `x`.
69+
- **strideX**: stride length for `x`.
7170

72-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
71+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in the input array
7372

7473
```javascript
75-
var floor = require( '@stdlib/math/base/special/floor' );
76-
7774
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
78-
var N = floor( x.length / 2 );
79-
80-
var v = meanpn( N, x, 2 );
75+
var v = meanpn( 4, x, 2 );
8176
// returns 1.25
8277
```
8378

@@ -87,42 +82,35 @@ Note that indexing is relative to the first index. To introduce an offset, use [
8782

8883
```javascript
8984
var Float64Array = require( '@stdlib/array/float64' );
90-
var floor = require( '@stdlib/math/base/special/floor' );
9185

9286
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
9387
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9488

95-
var N = floor( x0.length / 2 );
96-
97-
var v = meanpn( N, x1, 2 );
89+
var v = meanpn( 4, x1, 2 );
9890
// returns 1.25
9991
```
10092

101-
#### meanpn.ndarray( N, x, stride, offset )
93+
#### meanpn.ndarray( N, x, strideX, offsetX )
10294

10395
Computes the [arithmetic mean][arithmetic-mean] of a strided array using a two-pass error correction algorithm and alternative indexing semantics.
10496

10597
```javascript
10698
var x = [ 1.0, -2.0, 2.0 ];
107-
var N = x.length;
10899

109-
var v = meanpn.ndarray( N, x, 1, 0 );
100+
var v = meanpn.ndarray( x.length, x, 1, 0 );
110101
// returns ~0.33333
111102
```
112103

113104
The function has the following additional parameters:
114105

115-
- **offset**: starting index for `x`.
106+
- **offsetX**: starting index for `x`.
116107

117-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value
108+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other element in the strided array starting from the second element
118109

119110
```javascript
120-
var floor = require( '@stdlib/math/base/special/floor' );
121-
122111
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
123-
var N = floor( x.length / 2 );
124112

125-
var v = meanpn.ndarray( N, x, 2, 1 );
113+
var v = meanpn.ndarray( 4, x, 2, 1 );
126114
// returns 1.25
127115
```
128116

@@ -135,6 +123,7 @@ var v = meanpn.ndarray( N, x, 2, 1 );
135123
## Notes
136124

137125
- If `N <= 0`, both functions return `NaN`.
126+
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]).
138127
- Depending on the environment, the typed versions ([`dmeanpn`][@stdlib/stats/base/dmeanpn], [`smeanpn`][@stdlib/stats/base/smeanpn], etc.) are likely to be significantly more performant.
139128

140129
</section>
@@ -148,18 +137,12 @@ var v = meanpn.ndarray( N, x, 2, 1 );
148137
<!-- eslint no-undef: "error" -->
149138

150139
```javascript
151-
var randu = require( '@stdlib/random/base/randu' );
152-
var round = require( '@stdlib/math/base/special/round' );
153-
var Float64Array = require( '@stdlib/array/float64' );
140+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
154141
var meanpn = require( '@stdlib/stats/base/meanpn' );
155142

156-
var x;
157-
var i;
158-
159-
x = new Float64Array( 10 );
160-
for ( i = 0; i < x.length; i++ ) {
161-
x[ i ] = round( (randu()*100.0) - 50.0 );
162-
}
143+
var x = discreteUniform( 10, -50, 50, {
144+
'dtype': 'float64'
145+
});
163146
console.log( x );
164147

165148
var v = meanpn( x.length, x, 1 );
@@ -210,6 +193,8 @@ console.log( v );
210193

211194
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
212195

196+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
197+
213198
[@neely:1966a]: https://doi.org/10.1145/365719.365958
214199

215200
[@schubert:2018a]: https://doi.org/10.1145/3221269.3223036

lib/node_modules/@stdlib/stats/base/meanpn/benchmark/benchmark.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,11 +21,18 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pow = require( '@stdlib/math/base/special/pow' );
2727
var pkg = require( './../package.json' ).name;
28-
var meanpn = require( './../lib/meanpn.js' );
28+
var meanpn = require( './../lib/main.js' );
29+
30+
31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'generic'
35+
};
2936

3037

3138
// FUNCTIONS //
@@ -38,13 +45,7 @@ var meanpn = require( './../lib/meanpn.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = [];
45-
for ( i = 0; i < len; i++ ) {
46-
x.push( ( randu()*20.0 ) - 10.0 );
47-
}
48+
var x = uniform( len, -10, 10, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

0 commit comments

Comments
 (0)