Skip to content

Commit a953eae

Browse files
committed
refactor: apply code review suggestions
--- 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: na - 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 53e56e7 commit a953eae

File tree

1 file changed

+42
-22
lines changed
  • lib/node_modules/@stdlib/blas/ext/base/gnansumpw/lib

1 file changed

+42
-22
lines changed

lib/node_modules/@stdlib/blas/ext/base/gnansumpw/lib/accessors.js

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function gnansumpw( N, x, strideX, offsetX ) {
7676
var M;
7777
var s;
7878
var n;
79+
var v;
7980
var i;
8081

8182
// Cache reference to array data:
@@ -86,67 +87,86 @@ function gnansumpw( N, x, strideX, offsetX ) {
8687

8788
ix = offsetX;
8889
if ( strideX === 0 ) {
89-
if ( isnan( xget( xbuf, ix ) ) ) {
90+
v = xget( xbuf, ix );
91+
if ( isnan( v ) ) {
9092
return 0.0;
9193
}
92-
return N * xget( xbuf, ix );
94+
return N * v;
9395
}
9496
if ( N < 8 ) {
9597
// Use simple summation...
9698
s = 0.0;
9799
for ( i = 0; i < N; i++ ) {
98-
if ( isnan( xget( xbuf, ix ) ) === false ) {
99-
s += xget( xbuf, ix );
100+
v = xget( xbuf, ix );
101+
if ( isnan( v ) === false ) {
102+
s += v;
100103
}
101104
ix += strideX;
102105
}
103106
return s;
104107
}
105108
if ( N <= BLOCKSIZE ) {
106109
// Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...
107-
s0 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
110+
v = xget( xbuf, ix );
111+
s0 = ( isnan( v ) ) ? 0.0 : v;
108112
ix += strideX;
109-
s1 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
113+
v = xget( xbuf, ix );
114+
s1 = ( isnan( v ) ) ? 0.0 : v;
110115
ix += strideX;
111-
s2 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
116+
v = xget( xbuf, ix );
117+
s2 = ( isnan( v ) ) ? 0.0 : v;
112118
ix += strideX;
113-
s3 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
119+
v = xget( xbuf, ix );
120+
s3 = ( isnan( v ) ) ? 0.0 : v;
114121
ix += strideX;
115-
s4 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
122+
v = xget( xbuf, ix );
123+
s4 = ( isnan( v ) ) ? 0.0 : v;
116124
ix += strideX;
117-
s5 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
125+
v = xget( xbuf, ix );
126+
s5 = ( isnan( v ) ) ? 0.0 : v;
118127
ix += strideX;
119-
s6 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
128+
v = xget( xbuf, ix );
129+
s6 = ( isnan( v ) ) ? 0.0 : v;
120130
ix += strideX;
121-
s7 = ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
131+
v = xget( xbuf, ix );
132+
s7 = ( isnan( v ) ) ? 0.0 : v;
122133
ix += strideX;
123134

124135
M = N % 8;
125136
for ( i = 8; i < N-M; i += 8 ) {
126-
s0 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
137+
v = xget( xbuf, ix );
138+
s0 += ( isnan( v ) ) ? 0.0 : v;
127139
ix += strideX;
128-
s1 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
140+
v = xget( xbuf, ix );
141+
s1 += ( isnan( v ) ) ? 0.0 : v;
129142
ix += strideX;
130-
s2 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
143+
v = xget( xbuf, ix );
144+
s2 += ( isnan( v ) ) ? 0.0 : v;
131145
ix += strideX;
132-
s3 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
146+
v = xget( xbuf, ix );
147+
s3 += ( isnan( v ) ) ? 0.0 : v;
133148
ix += strideX;
134-
s4 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
149+
v = xget( xbuf, ix );
150+
s4 += ( isnan( v ) ) ? 0.0 : v;
135151
ix += strideX;
136-
s5 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
152+
v = xget( xbuf, ix );
153+
s5 += ( isnan( v ) ) ? 0.0 : v;
137154
ix += strideX;
138-
s6 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
155+
v = xget( xbuf, ix );
156+
s6 += ( isnan( v ) ) ? 0.0 : v;
139157
ix += strideX;
140-
s7 += ( isnan( xget( xbuf, ix ) ) ) ? 0.0 : xget( xbuf, ix );
158+
v = xget( xbuf, ix );
159+
s7 += ( isnan( v ) ) ? 0.0 : v;
141160
ix += strideX;
142161
}
143162
// Pairwise sum the accumulators:
144163
s = ( (s0+s1) + (s2+s3) ) + ( (s4+s5) + (s6+s7) );
145164

146165
// Clean-up loop...
147166
for ( i; i < N; i++ ) {
148-
if ( isnan( xget( xbuf, ix ) ) === false ) {
149-
s += xget( xbuf, ix );
167+
v = xget( xbuf, ix );
168+
if ( isnan( v ) === false ) {
169+
s += v;
150170
}
151171
ix += strideX;
152172
}

0 commit comments

Comments
 (0)