Skip to content

Commit d27dd9a

Browse files
fix: stuff from code review
1 parent d3c674c commit d27dd9a

File tree

7 files changed

+30
-41
lines changed

7 files changed

+30
-41
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The function has the following parameters:
6868

6969
- **N**: number of indexed elements.
7070
- **x**: input [`Float32Array`][@stdlib/array/float32].
71-
- **strideX**: Stride Length for `x`.
71+
- **strideX**: stride Length for `x`.
7272

7373
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`,
7474

@@ -179,12 +179,12 @@ console.log( v );
179179

180180
#### stdlib_strided_dsmeanwd( N, \*X, strideX )
181181

182-
Calculate the mean value of a single-precision floating-point strided array, ignoring `NaN` values.
182+
Computes the arithmetic mean of a single-precision floating-point strided array `x` using Welford's algorithm with extended accumulation and returning an extended precision result.
183183

184184
```c
185185
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
186186

187-
float v = stdlib_strided_dsmeanwd( 4, x, 2 );
187+
double v = stdlib_strided_dsmeanwd( 4, x, 2 );
188188
// returns 1.25
189189
```
190190
@@ -200,12 +200,12 @@ double stdlib_strided_dsmeanwd( const CBLAS_INT N, const float *X, const CBLAS_I
200200

201201
#### stdlib_strided_dsmeanwd_ndarray( N, \*X, strideX, offsetX )
202202

203-
Computes the mean value of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
203+
Computes the arithmetic mean of a single-precision floating-point strided array `x` using Welford's algorithm with extended accumulation and alternative indexing semantics and returning an extended precision result.
204204

205205
```c
206206
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
207207

208-
float v = stdlib_strided_dsmeanwd_ndarray( 4, x, 2, 0 );
208+
double v = stdlib_strided_dsmeanwd_ndarray( 4, x, 2, 0 );
209209
// returns 1.25
210210
```
211211
@@ -253,7 +253,7 @@ int main( void ) {
253253
const int strideX = 2;
254254

255255
// Compute the arithmetic mean:
256-
float v = stdlib_strided_dsmeanwd( N, x, strideX );
256+
double v = stdlib_strided_dsmeanwd( N, x, strideX );
257257

258258
// Print the result:
259259
printf( "mean: %lf\n", v );

lib/node_modules/@stdlib/stats/base/dsmeanwd/benchmark/c/benchmark.length.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ static float rand_float( void ) {
9797
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
9999
float x[ len ];
100-
float v;
100+
double v;
101101
double t;
102102
int i;
103103

104104
for ( i = 0; i < len; i++ ) {
105105
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
106106
}
107-
v = 0.0f;
107+
v = 0.0;
108108
t = tic();
109109
for ( i = 0; i < iterations; i++ ) {
110110
// cppcheck-suppress uninitvar
@@ -131,14 +131,14 @@ static double benchmark1( int iterations, int len ) {
131131
static double benchmark2( int iterations, int len ) {
132132
double elapsed;
133133
float x[ len ];
134-
float v;
134+
double v;
135135
double t;
136136
int i;
137137

138138
for ( i = 0; i < len; i++ ) {
139139
x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
140140
}
141-
v = 0.0f;
141+
v = 0.0;
142142
t = tic();
143143
for ( i = 0; i < iterations; i++ ) {
144144
// cppcheck-suppress uninitvar

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
array using Welford's algorithm with extended accumulation and returning an
55
extended precision result.
66

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

1011
Indexing is relative to the first index. To introduce an offset, use a typed
@@ -21,7 +22,7 @@
2122
Input array.
2223

2324
strideX: integer
24-
Stride Length.
25+
Stride length.
2526

2627
Returns
2728
-------
@@ -37,14 +38,14 @@
3738

3839
// Using `N` and stride parameters:
3940
> x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] );
40-
> {{alias}}( 4, x, 2 )
41-
NaN
41+
> {{alias}}( 3, x, 2 )
42+
~0.3333
4243

4344
// Using view offsets:
4445
> var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
4546
> var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
46-
> {{alias}}( 4, x1, 2 )
47-
NaN
47+
> {{alias}}( 3, x1, 2 )
48+
~-0.3333
4849

4950

5051
{{alias}}.ndarray( N, x, strideX, offsetX )
@@ -84,8 +85,8 @@
8485

8586
// Using offset parameter:
8687
> var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
87-
> {{alias}}.ndarray( 4, x, 2, 1 )
88-
NaN
88+
> {{alias}}.ndarray( 3, x, 2, 1 )
89+
~-0.3333
8990

9091
See Also
9192
--------

lib/node_modules/@stdlib/stats/base/dsmeanwd/examples/c/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int main( void ) {
3030
const int strideX = 2;
3131

3232
// Compute the arithmetic mean:
33-
float v = stdlib_strided_dsmeanwd( N, x, strideX );
33+
double v = stdlib_strided_dsmeanwd( N, x, strideX );
3434

3535
// Print the result:
3636
printf( "mean: %lf\n", v );

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ extern "C" {
2828
#endif
2929

3030
/**
31-
* Computes the arithmetic mean of a single-precision floating-point strided array using Welford's algorithm with extended accumulation and returning an extended precision result.
31+
* Computes the arithmetic mean of a single-precision floating-point strided array `x ` using Welford's algorithm with extended accumulation and returning an extended precision result.
3232
*/
3333
double API_SUFFIX(stdlib_strided_dsmeanwd)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
3434

3535
/**
36-
* Computes the mean absolute value of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics .
36+
* Computes the arithmetic mean of a single-precision floating-point strided array `x` using Welford's algorithm with extended accumulation and alternative indexing semantics and returning an extended precision result.
3737
*/
3838
double API_SUFFIX(stdlib_strided_dsmeanwd_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
3939

lib/node_modules/@stdlib/stats/base/dsmeanwd/manifest.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
"dependencies": [
4141
"@stdlib/blas/base/shared",
4242
"@stdlib/strided/base/stride2offset",
43-
"@stdlib/math/base/assert/is-positive-zero",
44-
"@stdlib/math/base/assert/is-nan",
4543
"@stdlib/napi/export",
4644
"@stdlib/napi/argv",
4745
"@stdlib/napi/argv-int64",
@@ -62,9 +60,7 @@
6260
"libpath": [],
6361
"dependencies": [
6462
"@stdlib/blas/base/shared",
65-
"@stdlib/strided/base/stride2offset",
66-
"@stdlib/math/base/assert/is-nan",
67-
"@stdlib/math/base/assert/is-positive-zero"
63+
"@stdlib/strided/base/stride2offset"
6864
]
6965
},
7066
{
@@ -80,9 +76,7 @@
8076
"libpath": [],
8177
"dependencies": [
8278
"@stdlib/blas/base/shared",
83-
"@stdlib/strided/base/stride2offset",
84-
"@stdlib/math/base/assert/is-nan",
85-
"@stdlib/math/base/assert/is-positive-zero"
79+
"@stdlib/strided/base/stride2offset"
8680
]
8781
},
8882
{
@@ -98,9 +92,7 @@
9892
"libpath": [],
9993
"dependencies": [
10094
"@stdlib/blas/base/shared",
101-
"@stdlib/strided/base/stride2offset",
102-
"@stdlib/math/base/assert/is-nan",
103-
"@stdlib/math/base/assert/is-positive-zero"
95+
"@stdlib/strided/base/stride2offset"
10496
]
10597
}
10698
]

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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_dsmeanwd)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) {
5151
const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
5252
return API_SUFFIX(stdlib_strided_dsmeanwd_ndarray)( N, X, strideX, ox );
5353
}
5454

5555
/**
56-
* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
56+
* Computes the arithmetic mean of a single-precision floating-point strided array using Welford's algorithm with extended accumulation and alternative indexing semantics and returning an extended precision result.
5757
*
5858
* @param N number of indexed elements
5959
* @param X input array
@@ -73,11 +73,7 @@ double API_SUFFIX(stdlib_strided_dsmeanwd_ndarray)( const CBLAS_INT N, const flo
7373
if ( N == 1 || strideX == 0 ) {
7474
return X[ 0 ];
7575
}
76-
if ( strideX < 0 ) {
77-
ix = (1-N) * strideX;
78-
} else {
79-
ix = 0;
80-
}
76+
ix = offsetX;
8177
mu = 0.0;
8278
n = 0;
8379
for ( i = 0; i < N; i++ ) {

0 commit comments

Comments
 (0)