Skip to content

Commit 4096cc8

Browse files
chore: changes from code review
1 parent 063c6e2 commit 4096cc8

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Computes arithmetic mean of a double-precision floating-point strided array `x`,
189189
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 };
190190

191191
double v = stdlib_strided_dnanmeanpn( 6, x, 2 );
192-
// returns 1.25
192+
// returns 4.66
193193
```
194194
195195
The function accepts the following arguments:
@@ -210,7 +210,7 @@ Computes the aithmetic mean of a double-precision floating-point strided array,
210210
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 };
211211

212212
double v = stdlib_strided_dnanmeanpn( 6, x, 2, 0 );
213-
// returns 1.25
213+
// returns 4.66
214214
```
215215
216216
The function accepts the following arguments:

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "stdlib/stats/base/dnanmeanpn.h"
2020
#include "stdlib/blas/base/shared.h"
2121
#include "stdlib/strided/base/stride2offset.h"
22-
#include <stdint.h>
2322

2423
/**
2524
* Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm.
@@ -66,14 +65,9 @@ double API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( const CBLAS_INT N, const d
6665
return 0.0 / 0.0; // NaN
6766
}
6867
if ( N == 1 || strideX == 0 ) {
69-
return X[ 0 ];
68+
return X[ offsetX ];
7069
}
71-
if ( strideX < 0 ) {
72-
ix = (1-N) * strideX;
73-
} else {
74-
ix = 0;
75-
}
76-
o = ix;
70+
ix = offsetX;
7771

7872
// Compute an estimate for the mean...
7973
s = 0.0;
@@ -93,8 +87,8 @@ double API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( const CBLAS_INT N, const d
9387
s /= dn;
9488

9589
// Compute an error term...
90+
ix = offsetX;
9691
t = 0.0;
97-
ix = o;
9892
for ( i = 0; i < N; i++ ) {
9993
v = X[ ix ];
10094
if ( v == v ) {

lib/node_modules/@stdlib/stats/base/dnanmeanpn/test/test.dnanmeanpn.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 = dnanmeanpn( 4, x, 2 );
107+
v = dnanmeanpn( 5, 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 = dnanmeanpn( 4, x, -2 );
129+
v = dnanmeanpn( 5, x, -2 );
130130

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

lib/node_modules/@stdlib/stats/base/dnanmeanpn/test/test.dnanmeanpn.native.js

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

198-
v = dnanmeanpn( 4, x, 2 );
198+
v = dnanmeanpn( 5, x, 2 );
199199

200200
t.strictEqual( v, 1.25, 'returns expected value' );
201201
t.end();
@@ -217,7 +217,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
217217
NaN // 0
218218
]);
219219

220-
v = dnanmeanpn( 4, x, -2 );
220+
v = dnanmeanpn( 5, x, -2 );
221221

222222
t.strictEqual( v, 1.25, 'returns expected value' );
223223
t.end();

lib/node_modules/@stdlib/stats/base/dnanmeanpn/test/test.ndarray.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 = dnanmeanpn( 4, x, 2, 0 );
107+
v = dnanmeanpn( 5, x, 2, 0 );
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 = dnanmeanpn( 4, x, -2, 6 );
129+
v = dnanmeanpn( 5, x, -2, 8 );
130130

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

lib/node_modules/@stdlib/stats/base/dnanmeanpn/test/test.ndarray.native.js

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

116-
v = dnanmeanpn( 4, x, 2, 0 );
116+
v = dnanmeanpn( 5, x, 2, 0 );
117117

118118
t.strictEqual( v, 1.25, 'returns expected value' );
119119
t.end();
@@ -135,7 +135,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
135135
NaN // 0
136136
]);
137137

138-
v = dnanmeanpn( 4, x, -2, 6 );
138+
v = dnanmeanpn( 5, x, -2, 8 );
139139

140140
t.strictEqual( v, 1.25, 'returns expected value' );
141141
t.end();

0 commit comments

Comments
 (0)