Skip to content

Commit b101f5f

Browse files
authored
fix: remove unnecessary diff
1 parent f39f6ab commit b101f5f

File tree

1 file changed

+8
-6
lines changed
  • lib/node_modules/@stdlib/stats/base/svariancech/src

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ float API_SUFFIX(stdlib_strided_svariancech)( const CBLAS_INT N, const float cor
5858
float API_SUFFIX(stdlib_strided_svariancech_ndarray)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
5959
CBLAS_INT ix;
6060
CBLAS_INT i;
61-
float dN;
61+
double dN;
62+
double dM;
63+
double n;
6264
float mu;
6365
float M2;
6466
float M;
65-
float n;
6667
float d;
6768

68-
dN = (float)N;
69-
n = dN - correction;
69+
dN = (double)N;
70+
n = dN - (double)correction;
7071
if ( N <= 0 || n <= 0.0f ) {
7172
return 0.0f / 0.0f; // NaN
7273
}
@@ -78,7 +79,7 @@ float API_SUFFIX(stdlib_strided_svariancech_ndarray)( const CBLAS_INT N, const f
7879
mu = X[ ix ];
7980
ix += strideX;
8081

81-
// Compute the variance...
82+
// Compute the variance...
8283
M2 = 0.0f;
8384
M = 0.0f;
8485
for ( i = 1; i < N; i++ ) {
@@ -87,5 +88,6 @@ float API_SUFFIX(stdlib_strided_svariancech_ndarray)( const CBLAS_INT N, const f
8788
M += d;
8889
ix += strideX;
8990
}
90-
return (M2/n) - ((M/dN)*(M/n));
91+
dM = (double)M;
92+
return (float)((double)M2/n) - ( (float)(dM/dN) * (float)(dM/n) );
9193
}

0 commit comments

Comments
 (0)