Skip to content

Commit 6448072

Browse files
chore: minor clean up
1 parent dce8133 commit 6448072

File tree

13 files changed

+84
-39
lines changed

13 files changed

+84
-39
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ The `N` and stride parameters determine which elements in the stride array are a
7474

7575
```javascript
7676
var Float64Array = require( '@stdlib/array/float64' );
77-
var floor = require( '@stdlib/math/base/special/floor' );
7877

7978
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
8079

81-
var v = dnanmeanwd( 5, x, 2 );
80+
var v = dnanmeanwd( 4, x, 2 );
8281
// returns 1.25
8382
```
8483

@@ -88,10 +87,12 @@ Note that indexing is relative to the first index. To introduce an offset, use [
8887

8988
```javascript
9089
var Float64Array = require( '@stdlib/array/float64' );
91-
var floor = require( '@stdlib/math/base/special/floor' );
9290

9391
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
9492
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
93+
94+
var v = dnanmeanwd( 4, x1, 2 );
95+
// returns 1.25
9596
```
9697

9798
#### dnanmeanwd.ndarray( N, x, strideX, offsetX )
@@ -117,6 +118,9 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
117118
var Float64Array = require( '@stdlib/array/float64' );
118119

119120
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
121+
122+
var v = dnanmeanwd( 4, x, 2, 1 );
123+
// returns 1.25
120124
```
121125

122126
</section>
@@ -195,13 +199,13 @@ console.log( v );
195199

196200
#### stdlib_strided_dnanmeanwd( N, \*X, strideX )
197201

198-
Computes the mean value of a double-precision floating-point strided array `x`, ignoring `NaN` values.
202+
Computes the arithmetic mean of a double-precision floating-point strided array `x`, using Welford's algorithm and ignoring `NaN` values.
199203

200204
```c
201-
const double x[] = { 1.0, 0.0/0.0, 3.0, -4.0 };
205+
const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
202206

203-
double v = stdlib_strided_dnanmeanwd( 5, x, 1 );
204-
// returns 0.3333
207+
double v = stdlib_strided_dnanmeanwd( 6, x, 2 );
208+
// returns 1.25
205209
```
206210
207211
The function accepts the following arguments:
@@ -216,13 +220,13 @@ double stdlib_strided_dnanmeanwd( const CBLAS_INT N, const double *X, const CBLA
216220

217221
#### stdlib_strided_dnanmeanwd_ndarray( N, \*X, strideX, offsetX )
218222

219-
Computes the mean value of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
223+
Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics.
220224

221225
```c
222-
const double x[] = { 1.0, 0.0/0.0, 3.0, -4.0 };
226+
const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
223227

224-
double v = stdlib_strided_dnanmeanwd_ndarray( 5, x, 1, 0 );
225-
// returns 7.0
228+
double v = stdlib_strided_dnanmeanwd_ndarray( 6, x, 2, 0 );
229+
// returns 1.25
226230
```
227231
228232
The function accepts the following arguments:

lib/node_modules/@stdlib/stats/base/dnanmeanwd/docs/repl.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Computes the arithmetic mean of a double-precision floating-point strided
44
array, using Welford's algorithm and ignoring `NaN` values.
55

6-
The `N` and stride parameters determine which elements in `x` are accessed
7-
at runtime.
6+
The `N` and stride parameters determine which elements in the strided array
7+
are accessed at runtime.
88

99
Indexing is relative to the first index. To introduce an offset, use a typed
1010
array view.
@@ -22,7 +22,7 @@
2222
Input array.
2323

2424
strideX: integer
25-
Stride Length.
25+
Stride length.
2626

2727
Returns
2828
-------
@@ -54,7 +54,7 @@
5454
indexing semantics.
5555

5656
While typed array views mandate a view offset based on the underlying
57-
buffer, the `offset` parameter supports indexing semantics based on a
57+
buffer, the offset parameter supports indexing semantics based on a
5858
starting index.
5959

6060
Parameters
@@ -66,7 +66,7 @@
6666
Input array.
6767

6868
strideX: integer
69-
Stride Length.
69+
Stride length.
7070

7171
offsetX: integer
7272
Starting index.

lib/node_modules/@stdlib/stats/base/dnanmeanwd/include/stdlib/stats/base/dnanmeanwd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
double API_SUFFIX(stdlib_strided_dnanmeanwd)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
3535

3636
/**
37-
* Computes the maximum absolute value of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics .
37+
* Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics.
3838
*/
3939
double API_SUFFIX(stdlib_strided_dnanmeanwd_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
4040

lib/node_modules/@stdlib/stats/base/dnanmeanwd/lib/dnanmeanwd.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ var ndarray = require( './ndarray.js' );
5454
* var Float64Array = require( '@stdlib/array/float64' );
5555
*
5656
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
57-
* var N = x.length;
5857
*
5958
* var v = dnanmeanwd( x.length, x, 1 );
6059
* // returns ~0.3333

lib/node_modules/@stdlib/stats/base/dnanmeanwd/lib/dnanmeanwd.native.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ var addon = require( './../src/addon.node' );
3737
* var Float64Array = require( '@stdlib/array/float64' );
3838
*
3939
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
40-
* var N = x.length;
4140
*
4241
* var v = dnanmeanwd( x.length, x, 1 );
4342
* // returns ~0.3333

lib/node_modules/@stdlib/stats/base/dnanmeanwd/lib/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
* var dnanmeanwd = require( '@stdlib/stats/base/dnanmeanwd' );
2929
*
3030
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
31-
* var N = 3;
3231
*
33-
* var v = dnanmeanwd( 5, x, 1 );
32+
* var v = dnanmeanwd( x.length, x, 1 );
3433
* // returns ~0.3333
3534
*
3635
* @example
@@ -39,7 +38,7 @@
3938
*
4039
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
4140
*
42-
* var v = dnanmeanwd.ndarray( 5, x, 2, 1 );
41+
* var v = dnanmeanwd.ndarray( 4, x, 2, 1 );
4342
* // returns 1.25
4443
*/
4544

lib/node_modules/@stdlib/stats/base/dnanmeanwd/lib/ndarray.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
*
5353
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
5454
*
55+
* var v = dnanmeanwd( 4, x, 2, 1 );
56+
* // returns 1.25
5557
*/
5658
function dnanmeanwd( N, x, strideX, offsetX ) {
5759
var mu;

lib/node_modules/@stdlib/stats/base/dnanmeanwd/lib/ndarray.native.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ var addon = require( './../src/addon.node' );
3939
*
4040
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
4141
*
42+
* var v = dnanmeanwd( 4, x, 2, 1 );
43+
* // returns 1.25
4244
*/
4345
function dnanmeanwd( N, x, strideX, offsetX ) {
4446
return addon.ndarray( N, x, strideX, offsetX );

lib/node_modules/@stdlib/stats/base/dnanmeanwd/src/main.c

Lines changed: 7 additions & 11 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.
@@ -42,18 +42,18 @@
4242
* - Welford, B. P. 1962. "Note on a Method for Calculating Corrected Sums of Squares and Products." _Technometrics_ 4 (3). Taylor & Francis: 419–20. doi:[10.1080/00401706.1962.10490022](https://doi.org/10.1080/00401706.1962.10490022).
4343
* - van Reeken, A. J. 1968. "Letters to the Editor: Dealing with Neely's Algorithms." _Communications of the ACM_ 11 (3): 149–50. doi:[10.1145/362929.362961](https://doi.org/10.1145/362929.362961).
4444
*
45-
* @param N number of indexed elements
46-
* @param X input array
45+
* @param N number of indexed elements
46+
* @param X input array
4747
* @param strideX stride length
48-
* @return output value
48+
* @return output value
4949
*/
5050
double API_SUFFIX(stdlib_strided_dnanmeanwd)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) {
5151
const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
5252
return API_SUFFIX(stdlib_strided_dnanmeanwd_ndarray)( N, X, strideX, ox );
5353
}
5454

5555
/**
56-
* Computes the maximum absolute value of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
56+
* Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics.
5757
*
5858
* @param N number of indexed elements
5959
* @param X input array
@@ -72,13 +72,9 @@ double API_SUFFIX(stdlib_strided_dnanmeanwd_ndarray)( const CBLAS_INT N, const d
7272
return 0.0 / 0.0; // NaN
7373
}
7474
if ( N == 1 || strideX == 0 ) {
75-
return X[ 0 ];
76-
}
77-
if ( strideX < 0 ) {
78-
ix = (1-N) * strideX;
79-
} else {
80-
ix = 0;
75+
return X[ offsetX ];
8176
}
77+
ix = offsetX;
8278
mu = 0.0;
8379
n = 0;
8480
for ( i = 0; i < N; i++ ) {

lib/node_modules/@stdlib/stats/base/dnanmeanwd/test/test.dnanmeanwd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
104104
NaN // 4
105105
]);
106106

107-
v = dnanmeanwd( 5, x, 2 );
107+
v = dnanmeanwd( 4, x, 2 );
108108

109109
t.strictEqual( v, 1.25, 'returns expected value' );
110110
t.end();
@@ -126,7 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
126126
NaN // 0
127127
]);
128128

129-
v = dnanmeanwd( 5, x, -2 );
129+
v = dnanmeanwd( 4, x, -2 );
130130

131131
t.strictEqual( v, 1.25, 'returns expected value' );
132132
t.end();

0 commit comments

Comments
 (0)