Skip to content

Commit 3e57d57

Browse files
fix: add external dependencies and remove internal dependencies
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent c75eeb3 commit 3e57d57

File tree

3 files changed

+13
-146
lines changed

3 files changed

+13
-146
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var dnansumpw = require( './dnansumpw.js' );
23+
var dnannsumpw = require( '@stdlib/blas/ext/base/dnannsumpw' ).ndarray;
2424

2525

2626
// VARIABLES //
@@ -81,7 +81,7 @@ function dnanvariancepn( N, correction, x, strideX, offsetX ) {
8181
// Compute an estimate for the mean...
8282
WORKSPACE[ 0 ] = 0.0;
8383
WORKSPACE[ 1 ] = 0;
84-
dnansumpw( N, WORKSPACE, x, strideX, offsetX );
84+
dnannsumpw( N, x, strideX, offsetX, WORKSPACE, 1, 0 );
8585
n = WORKSPACE[ 1 ];
8686
nc = n - correction;
8787
if ( nc <= 0.0 ) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@stdlib/napi/argv",
4545
"@stdlib/napi/argv-int64",
4646
"@stdlib/napi/argv-double",
47+
"@stdlib/blas/ext/base/dnannsumpw",
4748
"@stdlib/napi/argv-strided-float64array",
4849
"@stdlib/napi/create-double"
4950
]
@@ -61,6 +62,7 @@
6162
"libpath": [],
6263
"dependencies": [
6364
"@stdlib/blas/base/shared",
65+
"@stdlib/blas/ext/base/dnannsumpw",
6466
"@stdlib/strided/base/stride2offset"
6567
]
6668
},
@@ -77,6 +79,7 @@
7779
"libpath": [],
7880
"dependencies": [
7981
"@stdlib/blas/base/shared",
82+
"@stdlib/blas/ext/base/dnannsumpw",
8083
"@stdlib/strided/base/stride2offset"
8184
]
8285
},
@@ -93,6 +96,7 @@
9396
"libpath": [],
9497
"dependencies": [
9598
"@stdlib/blas/base/shared",
99+
"@stdlib/blas/ext/base/dnannsumpw",
96100
"@stdlib/strided/base/stride2offset"
97101
]
98102
}

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

Lines changed: 7 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -17,146 +17,10 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dnanvariancepn.h"
20+
#include "stdlib/blas/ext/base/dnannsumpw.h"
2021
#include "stdlib/blas/base/shared.h"
2122
#include "stdlib/strided/base/stride2offset.h"
2223

23-
/**
24-
* Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation.
25-
*
26-
* ## Method
27-
*
28-
* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.
29-
*
30-
* ## References
31-
*
32-
* - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).
33-
*
34-
* @param N number of indexed elements
35-
* @param W two-element output array
36-
* @param X input array
37-
* @param stridex stride length
38-
* @return output value
39-
*/
40-
static void API_SUFFIX(dnansumpw)( const CBLAS_INT N, double *W, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
41-
CBLAS_INT ix;
42-
CBLAS_INT M;
43-
CBLAS_INT n;
44-
CBLAS_INT i;
45-
double sum;
46-
double s0;
47-
double s1;
48-
double s2;
49-
double s3;
50-
double s4;
51-
double s5;
52-
double s6;
53-
double s7;
54-
double v;
55-
56-
ix = offsetX;
57-
if ( N < 8 ) {
58-
// Use simple summation...
59-
sum = 0.0;
60-
n = 0;
61-
for ( i = 0; i < N; i++ ) {
62-
v = X[ ix ];
63-
if ( v == v ) {
64-
sum += X[ ix ];
65-
n += 1;
66-
}
67-
ix += strideX;
68-
}
69-
W[ 0 ] += sum;
70-
W[ 1 ] += n;
71-
return;
72-
}
73-
// Blocksize for pairwise summation: 128 (NOTE: decreasing the blocksize decreases rounding error as more pairs are summed, but also decreases performance. Because the inner loop is unrolled eight times, the blocksize is effectively `16`.)
74-
if ( N <= 128 ) {
75-
// Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...
76-
s0 = 0.0;
77-
s1 = 0.0;
78-
s2 = 0.0;
79-
s3 = 0.0;
80-
s4 = 0.0;
81-
s5 = 0.0;
82-
s6 = 0.0;
83-
s7 = 0.0;
84-
n = 0;
85-
86-
M = N % 8;
87-
for ( i = 0; i < N-M; i += 8 ) {
88-
v = X[ ix ];
89-
if ( v == v ) {
90-
s0 += v;
91-
n += 1;
92-
}
93-
ix += strideX;
94-
v = X[ ix ];
95-
if ( v == v ) {
96-
s1 += v;
97-
n += 1;
98-
}
99-
ix += strideX;
100-
v = X[ ix ];
101-
if ( v == v ) {
102-
s2 += v;
103-
n += 1;
104-
}
105-
ix += strideX;
106-
v = X[ ix ];
107-
if ( v == v ) {
108-
s3 += v;
109-
n += 1;
110-
}
111-
ix += strideX;
112-
v = X[ ix ];
113-
if ( v == v ) {
114-
s4 += v;
115-
n += 1;
116-
}
117-
ix += strideX;
118-
v = X[ ix ];
119-
if ( v == v ) {
120-
s5 += v;
121-
n += 1;
122-
}
123-
ix += strideX;
124-
v = X[ ix ];
125-
if ( v == v ) {
126-
s6 += v;
127-
n += 1;
128-
}
129-
ix += strideX;
130-
v = X[ ix ];
131-
if ( v == v ) {
132-
s7 += v;
133-
n += 1;
134-
}
135-
ix += strideX;
136-
}
137-
// Pairwise sum the accumulators:
138-
sum = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));
139-
140-
// Clean-up loop...
141-
for (; i < N; i++ ) {
142-
v = X[ ix ];
143-
if ( v == v ) {
144-
sum += X[ ix ];
145-
n += 1;
146-
}
147-
ix += strideX;
148-
}
149-
W[ 0 ] += sum;
150-
W[ 1 ] += n;
151-
return;
152-
}
153-
// Recurse by dividing by two, but avoiding non-multiples of unroll factor...
154-
n = N / 2;
155-
n -= n % 8;
156-
API_SUFFIX(dnansumpw)( n, W, X, strideX, ix );
157-
API_SUFFIX(dnansumpw)( N-n, W, X, strideX, ix+(n*strideX) );
158-
}
159-
16024
/**
16125
* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm.
16226
*
@@ -191,14 +55,14 @@ double API_SUFFIX(stdlib_strided_dnanvariancepn)( const CBLAS_INT N, const doubl
19155
* @return output value
19256
*/
19357
double API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
194-
double W[] = { 0.0, 0.0 };
19558
CBLAS_INT ix;
19659
CBLAS_INT i;
60+
CBLAS_INT n;
61+
double sum;
19762
double mu;
19863
double M2;
19964
double nc;
20065
double M;
201-
double n;
20266
double d;
20367
double v;
20468

@@ -213,14 +77,13 @@ double API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( const CBLAS_INT N, con
21377
return 0.0 / 0.0; // NaN
21478
}
21579
// Compute an estimate for the mean...
216-
API_SUFFIX(dnansumpw)( N, W, X, strideX, offsetX );
217-
n = W[ 1 ];
218-
nc = n - correction;
80+
sum = API_SUFFIX(stdlib_strided_dnannsumpw_ndarray)( N, X, strideX, offsetX, &n );
81+
nc =(double)n - correction;
21982
if ( nc <= 0.0 ) {
22083
return 0.0 / 0.0; // NaN
22184
}
22285
ix = offsetX;
223-
mu = W[ 0 ] / n;
86+
mu = sum / (double)n;
22487

22588
// Compute the variance...
22689
M2 = 0.0;
@@ -234,5 +97,5 @@ double API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( const CBLAS_INT N, con
23497
}
23598
ix += strideX;
23699
}
237-
return (M2/nc) - ((M/n)*(M/nc));
100+
return (M2/nc) - ((M/(double)n)*(M/nc));
238101
}

0 commit comments

Comments
 (0)