@stdlib/blas-ext-base-dsnannsumors 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -78,22 +78,20 @@ The function has the following parameters:
78
78
 
79
79
  - **N**: number of indexed elements.
80
80
  - **x**: input [`Float32Array`][@stdlib/array/float32].
81
- - **strideX**: index increment for `x`.
81
+ - **strideX**: stride length for `x`.
82
82
  - **out**: output [`Float64Array`][@stdlib/array/float64] whose first element is the sum and whose second element is the number of non-NaN elements.
83
- - **strideOut**: index increment for `out`.
83
+ - **strideOut**: stride length for `out`.
84
84
 
85
- The `N` and `stride` parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element in `x`,
85
+ The `N` and stride parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element:
86
86
 
87
87
  ```javascript
88
88
  var Float32Array = require( '@stdlib/array-float32' );
89
89
  var Float64Array = require( '@stdlib/array-float64' );
90
- var floor = require( '@stdlib/math-base-special-floor' );
91
90
 
92
91
  var x = new Float32Array( [ 1.0, 2.0, NaN, -7.0, NaN, 3.0, 4.0, 2.0 ] );
93
92
  var out = new Float64Array( 2 );
94
- var N = floor( x.length / 2 );
95
93
 
96
- var v = dsnannsumors( N, x, 2, out, 1 );
94
+ var v = dsnannsumors( 4, x, 2, out, 1 );
97
95
  // returns <Float64Array>[ 5.0, 2 ]
98
96
  ```
99
97
 
@@ -104,7 +102,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [
104
102
  ```javascript
105
103
  var Float32Array = require( '@stdlib/array-float32' );
106
104
  var Float64Array = require( '@stdlib/array-float64' );
107
- var floor = require( '@stdlib/math-base-special-floor' );
108
105
 
109
106
  var x0 = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
110
107
  var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
@@ -112,15 +109,13 @@ var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd
112
109
  var out0 = new Float64Array( 4 );
113
110
  var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at 3rd element
114
111
 
115
- var N = floor( x0.length / 2 );
116
-
117
- var v = dsnannsumors( N, x1, 2, out1, 1 );
112
+ var v = dsnannsumors( 4, x1, 2, out1, 1 );
118
113
  // returns <Float64Array>[ 5.0, 4 ]
119
114
  ```
120
115
 
121
116
  #### dsnannsumors.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut )
122
117
 
123
- Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics.
118
+ Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
124
119
 
125
120
  ```javascript
126
121
  var Float32Array = require( '@stdlib/array-float32' );
@@ -138,18 +133,16 @@ The function has the following additional parameters:
138
133
  - **offsetX**: starting index for `x`.
139
134
  - **offsetOut**: starting index for `out`.
140
135
 
141
- While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the sum of every other value in `x` starting from the second value
136
+ While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to calculate the sum of every other element starting from the second element:
142
137
 
143
138
  ```javascript
144
139
  var Float32Array = require( '@stdlib/array-float32' );
145
140
  var Float64Array = require( '@stdlib/array-float64' );
146
- var floor = require( '@stdlib/math-base-special-floor' );
147
141
 
148
142
  var x = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
149
143
  var out = new Float64Array( 4 );
150
- var N = floor( x.length / 2 );
151
144
 
152
- var v = dsnannsumors.ndarray( N, x, 2, 1, out, 2, 1 );
145
+ var v = dsnannsumors.ndarray( 4, x, 2, 1, out, 2, 1 );
153
146
  // returns <Float64Array>[ 0.0, 5.0, 0.0, 4 ]
154
147
  ```
155
148
 
@@ -175,23 +168,21 @@ var v = dsnannsumors.ndarray( N, x, 2, 1, out, 2, 1 );
175
168
  <!-- eslint no-undef: "error" -->
176
169
 
177
170
  ```javascript
178
- var randu = require( '@stdlib/random-base-randu' );
179
- var round = require( '@stdlib/math-base-special-round' );
171
+ var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
172
+ var bernoulli = require( '@stdlib/random-base-bernoulli' );
173
+ var filledarrayBy = require( '@stdlib/array-filled-by' );
180
174
  var Float32Array = require( '@stdlib/array-float32' );
181
175
  var Float64Array = require( '@stdlib/array-float64' );
182
176
  var dsnannsumors = require( '@stdlib/blas-ext-base-dsnannsumors' );
183
177
 
184
- var x;
185
- var i;
186
-
187
- x = new Float32Array( 10 );
188
- for ( i = 0; i < x.length; i++ ) {
189
- if ( randu() < 0.2 ) {
190
- x[ i ] = NaN;
191
- } else {
192
- x[ i ] = round( randu()*100.0 );
178
+ function rand() {
179
+ if ( bernoulli( 0.5 ) < 0.2 ) {
180
+ return NaN;
193
181
  }
182
+ return discreteUniform( 0, 100 );
194
183
  }
184
+
185
+ var x = filledarrayBy( 10, 'float32', rand );
195
186
  console.log( x );
196
187
 
197
188
  var out = new Float64Array( 2 );
@@ -203,6 +194,136 @@ console.log( out );
203
194
 
204
195
  <!-- /.examples -->
205
196
 
197
+ <!-- C interface documentation. -->
198
+
199
+ * * *
200
+
201
+ <section class="c">
202
+
203
+ ## C APIs
204
+
205
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
206
+
207
+ <section class="intro">
208
+
209
+ </section>
210
+
211
+ <!-- /.intro -->
212
+
213
+ <!-- C usage documentation. -->
214
+
215
+ <section class="usage">
216
+
217
+ ### Usage
218
+
219
+ ```c
220
+ #include "stdlib/blas/ext/base/dsnannsumors.h"
221
+ ```
222
+
223
+ #### stdlib_strided_dsnannsumors( N, \*X, strideX, \*n )
224
+
225
+ Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.
226
+
227
+ ```c
228
+ #include "stdlib/blas/base/shared.h"
229
+
230
+ const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
231
+ CBLAS_INT n = 0;
232
+
233
+ double v = stdlib_strided_dsnannsumors( 4, x, 1, &n );
234
+ // returns 1.0
235
+ ```
236
+
237
+ The function accepts the following arguments:
238
+
239
+ - **N**: `[in] CBLAS_INT` number of indexed elements.
240
+ - **X**: `[in] float*` input array.
241
+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
242
+ - **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
243
+
244
+ ```c
245
+ double stdlib_strided_dsnannsumors( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, CBLAS_INT *n );
246
+ ```
247
+
248
+ #### stdlib_strided_dsnannsumors_ndarray( N, \*X, strideX, offsetX, \*n )
249
+
250
+ Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
251
+
252
+ ```c
253
+ #include "stdlib/blas/base/shared.h"
254
+
255
+ const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
256
+ CBLAS_INT n = 0;
257
+
258
+ double v = stdlib_strided_dsnannsumors_ndarray( 4, x, 1, 0, &n );
259
+ // returns 1.0
260
+ ```
261
+
262
+ The function accepts the following arguments:
263
+
264
+ - **N**: `[in] CBLAS_INT` number of indexed elements.
265
+ - **X**: `[in] float*` input array.
266
+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
267
+ - **offsetX**: `[in] CBLAS_INT` starting index for `X`.
268
+ - **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
269
+
270
+ ```c
271
+ double stdlib_strided_dsnannsumors_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n );
272
+ ```
273
+
274
+ </section>
275
+
276
+ <!-- /.usage -->
277
+
278
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
279
+
280
+ <section class="notes">
281
+
282
+ </section>
283
+
284
+ <!-- /.notes -->
285
+
286
+ <!-- C API usage examples. -->
287
+
288
+ <section class="examples">
289
+
290
+ ### Examples
291
+
292
+ ```c
293
+ #include "stdlib/blas/ext/base/dsnannsumors.h"
294
+ #include "stdlib/blas/base/shared.h"
295
+ #include <stdio.h>
296
+
297
+ int main( void ) {
298
+ // Create a strided array:
299
+ const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 0.0f/0.0f, 0.0f/0.0f };
300
+
301
+ // Specify the number of elements:
302
+ const int N = 5;
303
+
304
+ // Specify the stride length:
305
+ const int strideX = 2;
306
+
307
+ // Initialize a variable for storing the number of non-NaN elements:
308
+ CBLAS_INT n = 0;
309
+
310
+ // Compute the sum:
311
+ double v = stdlib_strided_dsnannsumors( N, x, strideX, &n );
312
+
313
+ // Print the result:
314
+ printf( "sum: %lf\n", v );
315
+ printf( "n: %"CBLAS_IFMT"\n", n );
316
+ }
317
+ ```
318
+
319
+ </section>
320
+
321
+ <!-- /.examples -->
322
+
323
+ </section>
324
+
325
+ <!-- /.c -->
326
+
206
327
  <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
207
328
 
208
329
  <section class="related">
@@ -245,7 +366,7 @@ See [LICENSE][stdlib-license].
245
366
 
246
367
  ## Copyright
247
368
 
248
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
369
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
249
370
 
250
371
  </section>
251
372
 
@@ -258,8 +379,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
258
379
  [npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsnannsumors.svg
259
380
  [npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsnannsumors
260
381
 
261
- [test-image]: https://github.com/stdlib-js/blas-ext-base-dsnannsumors/actions/workflows/test.yml/badge.svg?branch=v0.2.2
262
- [test-url]: https://github.com/stdlib-js/blas-ext-base-dsnannsumors/actions/workflows/test.yml?query=branch:v0.2.2
382
+ [test-image]: https://github.com/stdlib-js/blas-ext-base-dsnannsumors/actions/workflows/test.yml/badge.svg?branch=v0.3.0
383
+ [test-url]: https://github.com/stdlib-js/blas-ext-base-dsnannsumors/actions/workflows/test.yml?query=branch:v0.3.0
263
384
 
264
385
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsnannsumors/main.svg
265
386
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsnannsumors?branch=main
@@ -271,8 +392,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
271
392
 
272
393
  -->
273
394
 
274
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
275
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
395
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
396
+ [chat-url]: https://stdlib.zulipchat.com
276
397
 
277
398
  [stdlib]: https://github.com/stdlib-js/stdlib
278
399
 
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var p=function(s,a){return function(){return a||s((a={exports:{}}).exports,a),a.exports}};var _=p(function(I,R){
2
- var j=require('@stdlib/math-base-assert-is-nan/dist');function x(s,a,m,e,r){var v,q,n,f,i;if(m<0?q=(1-s)*m:q=0,r<0?n=-r:n=0,v=0,s<=0)return e[n]=v,e[n+r]=0,e;if(s===1||m===0)return j(a[q])?(e[n]=v,e[n+r]=0,e):(e[n]=a[q],e[n+r]=1,e);for(f=0,i=0;i<s;i++)j(a[q])===!1&&(v+=a[q],f+=1),q+=m;return e[n]=v,e[n+r]=f,e}R.exports=x
3
- });var g=p(function(J,b){
4
- var E=require('@stdlib/math-base-assert-is-nan/dist');function z(s,a,m,e,r,v,q){var n,f,i,c,l;if(f=e,i=q,n=0,s<=0)return r[i]=n,r[i+v]=0,r;if(s===1||m===0)return E(a[f])?(r[i]=n,r[i+v]=0,r):(r[i]=a[f],r[i+v]=1,r);for(c=0,l=0;l<s;l++)E(a[f])===!1&&(n+=a[f],c+=1),f+=m;return r[i]=n,r[i+v]=c,r}b.exports=z
5
- });var u=p(function(K,k){
6
- var A=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),h=_(),B=g();A(h,"ndarray",B);k.exports=h
7
- });var C=require("path").join,D=require('@stdlib/utils-try-require/dist'),F=require('@stdlib/assert-is-error/dist'),G=u(),y,w=D(C(__dirname,"./native.js"));F(w)?y=G:y=w;module.exports=y;
1
+ "use strict";var u=function(e,a){return function(){return a||e((a={exports:{}}).exports,a),a.exports}};var y=u(function(I,l){
2
+ var j=require('@stdlib/math-base-assert-is-nan/dist');function k(e,a,v,m,r,i,n){var q,s,c,p;if(q=0,e<=0)return r[n]=q,r[n+i]=0,r;if(s=m,v===0)return j(a[s])?(r[n]=q,r[n+i]=0,r):(r[n]=a[s]*e,r[n+i]=e,r);for(c=0,p=0;p<e;p++)j(a[s])===!1&&(q+=a[s],c+=1),s+=v;return r[n]=q,r[n+i]=c,r}l.exports=k
3
+ });var _=u(function(J,R){
4
+ var x=require('@stdlib/strided-base-stride2offset/dist'),w=y();function z(e,a,v,m,r){var i,n;return i=x(e,v),n=x(2,r),w(e,a,v,i,m,r,n)}R.exports=z
5
+ });var g=u(function(K,b){
6
+ var A=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),E=_(),B=y();A(E,"ndarray",B);b.exports=E
7
+ });var C=require("path").join,D=require('@stdlib/utils-try-require/dist'),F=require('@stdlib/assert-is-error/dist'),G=g(),d,h=D(C(__dirname,"./native.js"));F(h)?d=G:d=h;module.exports=d;
8
8
  /** @license Apache-2.0 */
9
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../lib/dsnannsumors.js", "../lib/ndarray.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float32Array} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {Float64Array} out - output array\n* @param {integer} strideOut - `out` stride length\n* @returns {Float64Array} output array\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n* var out = new Float64Array( 2 );\n*\n* var v = dsnannsumors( x.length, x, 1, out, 1 );\n* // returns <Float64Array>[ 1.0, 3 ]\n*/\nfunction dsnannsumors( N, x, strideX, out, strideOut ) {\n\tvar sum;\n\tvar ix;\n\tvar io;\n\tvar n;\n\tvar i;\n\n\tif ( strideX < 0 ) {\n\t\tix = (1-N) * strideX;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( strideOut < 0 ) {\n\t\tio = -strideOut;\n\t} else {\n\t\tio = 0;\n\t}\n\tsum = 0.0;\n\tif ( N <= 0 ) {\n\t\tout[ io ] = sum;\n\t\tout[ io+strideOut ] = 0;\n\t\treturn out;\n\t}\n\tif ( N === 1 || strideX === 0 ) {\n\t\tif ( isnan( x[ ix ] ) ) {\n\t\t\tout[ io ] = sum;\n\t\t\tout[ io+strideOut ] = 0;\n\t\t\treturn out;\n\t\t}\n\t\tout[ io ] = x[ ix ];\n\t\tout[ io+strideOut ] = 1;\n\t\treturn out;\n\t}\n\tn = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\tsum += x[ ix ];\n\t\t\tn += 1;\n\t\t}\n\t\tix += strideX;\n\t}\n\tout[ io ] = sum;\n\tout[ io+strideOut ] = n;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float32Array} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - `x` starting index\n* @param {Float64Array} out - output array\n* @param {integer} strideOut - `out` stride length\n* @param {NonNegativeInteger} offsetOut - `out` starting index\n* @returns {Float64Array} output array\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var floor = require( '@stdlib/math-base-special-floor' );\n*\n* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );\n* var out = new Float64Array( 2 );\n*\n* var N = floor( x.length / 2 );\n*\n* var v = dsnannsumors( N, x, 2, 1, out, 1, 0 );\n* // returns <Float64Array>[ 5.0, 4 ]\n*/\nfunction dsnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) {\n\tvar sum;\n\tvar ix;\n\tvar io;\n\tvar n;\n\tvar i;\n\n\tix = offsetX;\n\tio = offsetOut;\n\n\tsum = 0.0;\n\tif ( N <= 0 ) {\n\t\tout[ io ] = sum;\n\t\tout[ io+strideOut ] = 0;\n\t\treturn out;\n\t}\n\tif ( N === 1 || strideX === 0 ) {\n\t\tif ( isnan( x[ ix ] ) ) {\n\t\t\tout[ io ] = sum;\n\t\t\tout[ io+strideOut ] = 0;\n\t\t\treturn out;\n\t\t}\n\t\tout[ io ] = x[ ix ];\n\t\tout[ io+strideOut ] = 1;\n\t\treturn out;\n\t}\n\tn = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\tsum += x[ ix ];\n\t\t\tn += 1;\n\t\t}\n\t\tix += strideX;\n\t}\n\tout[ io ] = sum;\n\tout[ io+strideOut ] = n;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dsnannsumors = require( './dsnannsumors.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsnannsumors, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Compute the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.\n*\n* @module @stdlib/blas-ext-base-dsnannsumors\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsnannsumors = require( '@stdlib/blas-ext-base-dsnannsumors' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n* var out = new Float64Array( 2 );\n*\n* var v = dsnannsumors( x.length, x, 1, out, 1 );\n* // returns <Float64Array>[ 1.0, 3 ]\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var dsnannsumors = require( '@stdlib/blas-ext-base-dsnannsumors' );\n*\n* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );\n* var out = new Float64Array( 2 );\n*\n* var N = floor( x.length / 2 );\n*\n* var v = dsnannsumors.ndarray( N, x, 2, 1, out, 1, 0 );\n* // returns <Float64Array>[ 5.0, 4 ]\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dsnannsumors;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsnannsumors = main;\n} else {\n\tdsnannsumors = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n\n// exports: { \"ndarray\": \"dsnannsumors.ndarray\" }\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EAyBvD,SAASC,EAAcC,EAAGC,EAAGC,EAASC,EAAKC,EAAY,CACtD,IAAIC,EACAC,EACAC,EACAC,EACA,EAaJ,GAXKN,EAAU,EACdI,GAAM,EAAEN,GAAKE,EAEbI,EAAK,EAEDF,EAAY,EAChBG,EAAK,CAACH,EAENG,EAAK,EAENF,EAAM,EACDL,GAAK,EACT,OAAAG,EAAKI,CAAG,EAAIF,EACZF,EAAKI,EAAGH,CAAU,EAAI,EACfD,EAER,GAAKH,IAAM,GAAKE,IAAY,EAC3B,OAAKJ,EAAOG,EAAGK,CAAG,CAAE,GACnBH,EAAKI,CAAG,EAAIF,EACZF,EAAKI,EAAGH,CAAU,EAAI,EACfD,IAERA,EAAKI,CAAG,EAAIN,EAAGK,CAAG,EAClBH,EAAKI,EAAGH,CAAU,EAAI,EACfD,GAGR,IADAK,EAAI,EACE,EAAI,EAAG,EAAIR,EAAG,IACdF,EAAOG,EAAGK,CAAG,CAAE,IAAM,KACzBD,GAAOJ,EAAGK,CAAG,EACbE,GAAK,GAENF,GAAMJ,EAEP,OAAAC,EAAKI,CAAG,EAAIF,EACZF,EAAKI,EAAGH,CAAU,EAAII,EACfL,CACR,CAKAN,EAAO,QAAUE,IChGjB,IAAAU,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EA8BvD,SAASC,EAAcC,EAAGC,EAAGC,EAASC,EAASC,EAAKC,EAAWC,EAAY,CAC1E,IAAIC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAH,EAAKL,EACLM,EAAKH,EAELC,EAAM,EACDP,GAAK,EACT,OAAAI,EAAKK,CAAG,EAAIF,EACZH,EAAKK,EAAGJ,CAAU,EAAI,EACfD,EAER,GAAKJ,IAAM,GAAKE,IAAY,EAC3B,OAAKJ,EAAOG,EAAGO,CAAG,CAAE,GACnBJ,EAAKK,CAAG,EAAIF,EACZH,EAAKK,EAAGJ,CAAU,EAAI,EACfD,IAERA,EAAKK,CAAG,EAAIR,EAAGO,CAAG,EAClBJ,EAAKK,EAAGJ,CAAU,EAAI,EACfD,GAGR,IADAM,EAAI,EACEC,EAAI,EAAGA,EAAIX,EAAGW,IACdb,EAAOG,EAAGO,CAAG,CAAE,IAAM,KACzBD,GAAON,EAAGO,CAAG,EACbE,GAAK,GAENF,GAAMN,EAEP,OAAAE,EAAKK,CAAG,EAAIF,EACZH,EAAKK,EAAGJ,CAAU,EAAIK,EACfN,CACR,CAKAP,EAAO,QAAUE,IC9FjB,IAAAa,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAe,IACfC,EAAU,IAKdF,EAAaC,EAAc,UAAWC,CAAQ,EAK9CH,EAAO,QAAUE,ICmBjB,IAAIE,EAAO,QAAS,MAAO,EAAE,KACzBC,EAAa,QAAS,2BAA4B,EAClDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAO,IAKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAeD,EAEfC,EAAeC,EAMhB,OAAO,QAAUD",
6
- "names": ["require_dsnannsumors", "__commonJSMin", "exports", "module", "isnan", "dsnannsumors", "N", "x", "strideX", "out", "strideOut", "sum", "ix", "io", "n", "require_ndarray", "__commonJSMin", "exports", "module", "isnan", "dsnannsumors", "N", "x", "strideX", "offsetX", "out", "strideOut", "offsetOut", "sum", "ix", "io", "n", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsnannsumors", "ndarray", "join", "tryRequire", "isError", "main", "dsnannsumors", "tmp"]
3
+ "sources": ["../lib/ndarray.js", "../lib/dsnannsumors.js", "../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float32Array} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - `x` starting index\n* @param {Float64Array} out - output array\n* @param {integer} strideOut - `out` stride length\n* @param {NonNegativeInteger} offsetOut - `out` starting index\n* @returns {Float64Array} output array\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );\n* var out = new Float64Array( 2 );\n*\n* var v = dsnannsumors( 5, x, 2, 1, out, 1, 0 );\n* // returns <Float64Array>[ 5.0, 4 ]\n*/\nfunction dsnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) {\n\tvar sum;\n\tvar ix;\n\tvar n;\n\tvar i;\n\n\tsum = 0.0;\n\tif ( N <= 0 ) {\n\t\tout[ offsetOut ] = sum;\n\t\tout[ offsetOut+strideOut ] = 0;\n\t\treturn out;\n\t}\n\tix = offsetX;\n\tif ( strideX === 0 ) {\n\t\tif ( isnan( x[ ix ] ) ) {\n\t\t\tout[ offsetOut ] = sum;\n\t\t\tout[ offsetOut+strideOut ] = 0;\n\t\t\treturn out;\n\t\t}\n\t\tout[ offsetOut ] = x[ ix ] * N;\n\t\tout[ offsetOut+strideOut ] = N;\n\t\treturn out;\n\t}\n\tn = 0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\tsum += x[ ix ];\n\t\t\tn += 1;\n\t\t}\n\t\tix += strideX;\n\t}\n\tout[ offsetOut ] = sum;\n\tout[ offsetOut+strideOut ] = n;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float32Array} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {Float64Array} out - output array\n* @param {integer} strideOut - `out` stride length\n* @returns {Float64Array} output array\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n* var out = new Float64Array( 2 );\n*\n* var v = dsnannsumors( x.length, x, 1, out, 1 );\n* // returns <Float64Array>[ 1.0, 3 ]\n*/\nfunction dsnannsumors( N, x, strideX, out, strideOut ) {\n\tvar ix;\n\tvar io;\n\n\tix = stride2offset( N, strideX );\n\tio = stride2offset( 2, strideOut );\n\treturn ndarray( N, x, strideX, ix, out, strideOut, io );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dsnannsumors = require( './dsnannsumors.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsnannsumors, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Compute the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.\n*\n* @module @stdlib/blas-ext-base-dsnannsumors\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsnannsumors = require( '@stdlib/blas-ext-base-dsnannsumors' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n* var out = new Float64Array( 2 );\n*\n* var v = dsnannsumors( x.length, x, 1, out, 1 );\n* // returns <Float64Array>[ 1.0, 3 ]\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsnannsumors = require( '@stdlib/blas-ext-base-dsnannsumors' );\n*\n* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );\n* var out = new Float64Array( 2 );\n*\n* var v = dsnannsumors.ndarray( 5, x, 2, 1, out, 1, 0 );\n* // returns <Float64Array>[ 5.0, 4 ]\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dsnannsumors;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsnannsumors = main;\n} else {\n\tdsnannsumors = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnannsumors;\n\n// exports: { \"ndarray\": \"dsnannsumors.ndarray\" }\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EA2BvD,SAASC,EAAcC,EAAGC,EAAGC,EAASC,EAASC,EAAKC,EAAWC,EAAY,CAC1E,IAAIC,EACAC,EACAC,EACAC,EAGJ,GADAH,EAAM,EACDP,GAAK,EACT,OAAAI,EAAKE,CAAU,EAAIC,EACnBH,EAAKE,EAAUD,CAAU,EAAI,EACtBD,EAGR,GADAI,EAAKL,EACAD,IAAY,EAChB,OAAKJ,EAAOG,EAAGO,CAAG,CAAE,GACnBJ,EAAKE,CAAU,EAAIC,EACnBH,EAAKE,EAAUD,CAAU,EAAI,EACtBD,IAERA,EAAKE,CAAU,EAAIL,EAAGO,CAAG,EAAIR,EAC7BI,EAAKE,EAAUD,CAAU,EAAIL,EACtBI,GAGR,IADAK,EAAI,EACEC,EAAI,EAAGA,EAAIV,EAAGU,IACdZ,EAAOG,EAAGO,CAAG,CAAE,IAAM,KACzBD,GAAON,EAAGO,CAAG,EACbC,GAAK,GAEND,GAAMN,EAEP,OAAAE,EAAKE,CAAU,EAAIC,EACnBH,EAAKE,EAAUD,CAAU,EAAII,EACtBL,CACR,CAKAP,EAAO,QAAUE,ICxFjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAyBd,SAASC,EAAcC,EAAGC,EAAGC,EAASC,EAAKC,EAAY,CACtD,IAAIC,EACAC,EAEJ,OAAAD,EAAKR,EAAeG,EAAGE,CAAQ,EAC/BI,EAAKT,EAAe,EAAGO,CAAU,EAC1BN,EAASE,EAAGC,EAAGC,EAASG,EAAIF,EAAKC,EAAWE,CAAG,CACvD,CAKAV,EAAO,QAAUG,IC5DjB,IAAAQ,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAe,IACfC,EAAU,IAKdF,EAAaC,EAAc,UAAWC,CAAQ,EAK9CH,EAAO,QAAUE,ICgBjB,IAAIE,EAAO,QAAS,MAAO,EAAE,KACzBC,EAAa,QAAS,2BAA4B,EAClDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAO,IAKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAeD,EAEfC,EAAeC,EAMhB,OAAO,QAAUD",
6
+ "names": ["require_ndarray", "__commonJSMin", "exports", "module", "isnan", "dsnannsumors", "N", "x", "strideX", "offsetX", "out", "strideOut", "offsetOut", "sum", "ix", "n", "i", "require_dsnannsumors", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "dsnannsumors", "N", "x", "strideX", "out", "strideOut", "ix", "io", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsnannsumors", "ndarray", "join", "tryRequire", "isError", "main", "dsnannsumors", "tmp"]
7
7
  }
@@ -63,7 +63,7 @@ interface Routine {
63
63
  * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
64
64
  * var out = new Float64Array( 2 );
65
65
  *
66
- * var v = dsnannsumors( x.length, x, 1, 0, out, 1, 0 );
66
+ * var v = dsnannsumors.ndarray( x.length, x, 1, 0, out, 1, 0 );
67
67
  * // returns <Float64Array>[ 1.0, 3 ]
68
68
  */
69
69
  ndarray( N: number, x: Float32Array, strideX: number, offsetX: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array;
@@ -96,7 +96,7 @@ interface Routine {
96
96
  * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
97
97
  * var out = new Float64Array( 2 );
98
98
  *
99
- * var v = dsnannsumors( x.length, x, 1, 0, out, 1, 0 );
99
+ * var v = dsnannsumors.ndarray( x.length, x, 1, 0, out, 1, 0 );
100
100
  * // returns <Float64Array>[ 1.0, 3 ]
101
101
  */
102
102
  declare var dsnannsumors: Routine;
@@ -16,13 +16,10 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- /**
20
- * Header file containing function declarations.
21
- */
22
19
  #ifndef STDLIB_BLAS_EXT_BASE_DSNANNSUMORS_H
23
20
  #define STDLIB_BLAS_EXT_BASE_DSNANNSUMORS_H
24
21
 
25
- #include <stdint.h>
22
+ #include "stdlib/blas/base/shared.h"
26
23
 
27
24
  /*
28
25
  * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
@@ -34,7 +31,12 @@ extern "C" {
34
31
  /**
35
32
  * Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.
36
33
  */
37
- double stdlib_strided_dsnannsumors( const int64_t N, const float *X, const int64_t stride, int64_t *n );
34
+ double API_SUFFIX(stdlib_strided_dsnannsumors)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, CBLAS_INT *n );
35
+
36
+ /**
37
+ * Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
38
+ */
39
+ double API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n );
38
40
 
39
41
  #ifdef __cplusplus
40
42
  }
@@ -20,7 +20,8 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var isnan = require( '@stdlib/math-base-assert-is-nan' );
23
+ var stride2offset = require( '@stdlib/strided-base-stride2offset' );
24
+ var ndarray = require( './ndarray.js' );
24
25
 
25
26
 
26
27
  // MAIN //
@@ -46,49 +47,12 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
46
47
  * // returns <Float64Array>[ 1.0, 3 ]
47
48
  */
48
49
  function dsnannsumors( N, x, strideX, out, strideOut ) {
49
- var sum;
50
50
  var ix;
51
51
  var io;
52
- var n;
53
- var i;
54
52
 
55
- if ( strideX < 0 ) {
56
- ix = (1-N) * strideX;
57
- } else {
58
- ix = 0;
59
- }
60
- if ( strideOut < 0 ) {
61
- io = -strideOut;
62
- } else {
63
- io = 0;
64
- }
65
- sum = 0.0;
66
- if ( N <= 0 ) {
67
- out[ io ] = sum;
68
- out[ io+strideOut ] = 0;
69
- return out;
70
- }
71
- if ( N === 1 || strideX === 0 ) {
72
- if ( isnan( x[ ix ] ) ) {
73
- out[ io ] = sum;
74
- out[ io+strideOut ] = 0;
75
- return out;
76
- }
77
- out[ io ] = x[ ix ];
78
- out[ io+strideOut ] = 1;
79
- return out;
80
- }
81
- n = 0;
82
- for ( i = 0; i < N; i++ ) {
83
- if ( isnan( x[ ix ] ) === false ) {
84
- sum += x[ ix ];
85
- n += 1;
86
- }
87
- ix += strideX;
88
- }
89
- out[ io ] = sum;
90
- out[ io+strideOut ] = n;
91
- return out;
53
+ ix = stride2offset( N, strideX );
54
+ io = stride2offset( 2, strideOut );
55
+ return ndarray( N, x, strideX, ix, out, strideOut, io );
92
56
  }
93
57
 
94
58
 
package/lib/index.js CHANGED
@@ -37,15 +37,12 @@
37
37
  * @example
38
38
  * var Float32Array = require( '@stdlib/array-float32' );
39
39
  * var Float64Array = require( '@stdlib/array-float64' );
40
- * var floor = require( '@stdlib/math-base-special-floor' );
41
40
  * var dsnannsumors = require( '@stdlib/blas-ext-base-dsnannsumors' );
42
41
  *
43
42
  * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
44
43
  * var out = new Float64Array( 2 );
45
44
  *
46
- * var N = floor( x.length / 2 );
47
- *
48
- * var v = dsnannsumors.ndarray( N, x, 2, 1, out, 1, 0 );
45
+ * var v = dsnannsumors.ndarray( 5, x, 2, 1, out, 1, 0 );
49
46
  * // returns <Float64Array>[ 5.0, 4 ]
50
47
  */
51
48
 
package/lib/ndarray.js CHANGED
@@ -40,40 +40,34 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
40
40
  * @example
41
41
  * var Float32Array = require( '@stdlib/array-float32' );
42
42
  * var Float64Array = require( '@stdlib/array-float64' );
43
- * var floor = require( '@stdlib/math-base-special-floor' );
44
43
  *
45
44
  * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
46
45
  * var out = new Float64Array( 2 );
47
46
  *
48
- * var N = floor( x.length / 2 );
49
- *
50
- * var v = dsnannsumors( N, x, 2, 1, out, 1, 0 );
47
+ * var v = dsnannsumors( 5, x, 2, 1, out, 1, 0 );
51
48
  * // returns <Float64Array>[ 5.0, 4 ]
52
49
  */
53
50
  function dsnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
54
51
  var sum;
55
52
  var ix;
56
- var io;
57
53
  var n;
58
54
  var i;
59
55
 
60
- ix = offsetX;
61
- io = offsetOut;
62
-
63
56
  sum = 0.0;
64
57
  if ( N <= 0 ) {
65
- out[ io ] = sum;
66
- out[ io+strideOut ] = 0;
58
+ out[ offsetOut ] = sum;
59
+ out[ offsetOut+strideOut ] = 0;
67
60
  return out;
68
61
  }
69
- if ( N === 1 || strideX === 0 ) {
62
+ ix = offsetX;
63
+ if ( strideX === 0 ) {
70
64
  if ( isnan( x[ ix ] ) ) {
71
- out[ io ] = sum;
72
- out[ io+strideOut ] = 0;
65
+ out[ offsetOut ] = sum;
66
+ out[ offsetOut+strideOut ] = 0;
73
67
  return out;
74
68
  }
75
- out[ io ] = x[ ix ];
76
- out[ io+strideOut ] = 1;
69
+ out[ offsetOut ] = x[ ix ] * N;
70
+ out[ offsetOut+strideOut ] = N;
77
71
  return out;
78
72
  }
79
73
  n = 0;
@@ -84,8 +78,8 @@ function dsnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
84
78
  }
85
79
  ix += strideX;
86
80
  }
87
- out[ io ] = sum;
88
- out[ io+strideOut ] = n;
81
+ out[ offsetOut ] = sum;
82
+ out[ offsetOut+strideOut ] = n;
89
83
  return out;
90
84
  }
91
85
 
@@ -20,9 +20,7 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var Float32Array = require( '@stdlib/array-float32' );
24
- var Float64Array = require( '@stdlib/array-float64' );
25
- var addon = require( './dsnannsumors.native.js' );
23
+ var addon = require( './../src/addon.node' );
26
24
 
27
25
 
28
26
  // MAIN //
@@ -42,28 +40,15 @@ var addon = require( './dsnannsumors.native.js' );
42
40
  * @example
43
41
  * var Float32Array = require( '@stdlib/array-float32' );
44
42
  * var Float64Array = require( '@stdlib/array-float64' );
45
- * var floor = require( '@stdlib/math-base-special-floor' );
46
43
  *
47
44
  * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
48
45
  * var out = new Float64Array( 2 );
49
46
  *
50
- * var N = floor( x.length / 2 );
51
- *
52
- * var v = dsnannsumors( N, x, 2, 1, out, 1, 0 );
47
+ * var v = dsnannsumors( 5, x, 2, 1, out, 1, 0 );
53
48
  * // returns <Float64Array>[ 5.0, 4 ]
54
49
  */
55
50
  function dsnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
56
- var viewOut;
57
- var viewX;
58
- if ( strideX < 0 ) {
59
- offsetX += (N-1) * strideX;
60
- }
61
- if ( strideOut < 0 ) {
62
- offsetOut += strideOut;
63
- }
64
- viewX = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len
65
- viewOut = new Float64Array( out.buffer, out.byteOffset+(out.BYTES_PER_ELEMENT*offsetOut), out.length-offsetOut ); // eslint-disable-line max-len
66
- addon( N, viewX, strideX, viewOut, strideOut );
51
+ addon.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut );
67
52
  return out;
68
53
  }
69
54
 
package/manifest.json CHANGED
@@ -1,42 +1,82 @@
1
1
  {
2
- "options": {},
3
- "fields": [
4
- {
5
- "field": "src",
6
- "resolve": true,
7
- "relative": true
8
- },
9
- {
10
- "field": "include",
11
- "resolve": true,
12
- "relative": true
13
- },
14
- {
15
- "field": "libraries",
16
- "resolve": false,
17
- "relative": false
18
- },
19
- {
20
- "field": "libpath",
21
- "resolve": true,
22
- "relative": false
23
- }
24
- ],
25
- "confs": [
26
- {
27
- "src": [
28
- "./src/dsnannsumors.c"
29
- ],
30
- "include": [
31
- "./include"
32
- ],
33
- "libraries": [
34
- "-lm"
35
- ],
36
- "libpath": [],
37
- "dependencies": [
38
- "@stdlib/math-base-assert-is-nanf"
39
- ]
40
- }
41
- ]
2
+ "options": {
3
+ "task": "build"
4
+ },
5
+ "fields": [
6
+ {
7
+ "field": "src",
8
+ "resolve": true,
9
+ "relative": true
10
+ },
11
+ {
12
+ "field": "include",
13
+ "resolve": true,
14
+ "relative": true
15
+ },
16
+ {
17
+ "field": "libraries",
18
+ "resolve": false,
19
+ "relative": false
20
+ },
21
+ {
22
+ "field": "libpath",
23
+ "resolve": true,
24
+ "relative": false
25
+ }
26
+ ],
27
+ "confs": [
28
+ {
29
+ "task": "build",
30
+ "src": [
31
+ "./src/main.c"
32
+ ],
33
+ "include": [
34
+ "./include"
35
+ ],
36
+ "libraries": [],
37
+ "libpath": [],
38
+ "dependencies": [
39
+ "@stdlib/napi-export",
40
+ "@stdlib/napi-argv",
41
+ "@stdlib/napi-argv-int64",
42
+ "@stdlib/napi-argv-strided-float32array",
43
+ "@stdlib/napi-argv-strided-float64array",
44
+ "@stdlib/math-base-assert-is-nanf",
45
+ "@stdlib/blas-base-shared",
46
+ "@stdlib/strided-base-stride2offset"
47
+ ]
48
+ },
49
+ {
50
+ "task": "benchmark",
51
+ "src": [
52
+ "./src/main.c"
53
+ ],
54
+ "include": [
55
+ "./include"
56
+ ],
57
+ "libraries": [],
58
+ "libpath": [],
59
+ "dependencies": [
60
+ "@stdlib/math-base-assert-is-nanf",
61
+ "@stdlib/blas-base-shared",
62
+ "@stdlib/strided-base-stride2offset"
63
+ ]
64
+ },
65
+ {
66
+ "task": "examples",
67
+ "src": [
68
+ "./src/main.c"
69
+ ],
70
+ "include": [
71
+ "./include"
72
+ ],
73
+ "libraries": [],
74
+ "libpath": [],
75
+ "dependencies": [
76
+ "@stdlib/math-base-assert-is-nanf",
77
+ "@stdlib/blas-base-shared",
78
+ "@stdlib/strided-base-stride2offset"
79
+ ]
80
+ }
81
+ ]
42
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-dsnannsumors",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Calculate the sum of single-precision floating-point strided array elements, ignoring NaN values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -35,10 +35,17 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@stdlib/assert-is-error": "^0.2.2",
38
- "@stdlib/math-base-assert-is-nan": "^0.2.1",
38
+ "@stdlib/blas-base-shared": "^0.1.0",
39
+ "@stdlib/math-base-assert-is-nan": "^0.2.2",
39
40
  "@stdlib/math-base-assert-is-nanf": "^0.2.2",
41
+ "@stdlib/napi-argv": "^0.2.2",
42
+ "@stdlib/napi-argv-int64": "^0.2.2",
43
+ "@stdlib/napi-argv-strided-float32array": "^0.2.2",
44
+ "@stdlib/napi-argv-strided-float64array": "^0.2.2",
45
+ "@stdlib/napi-export": "^0.3.0",
46
+ "@stdlib/strided-base-stride2offset": "^0.1.0",
40
47
  "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
41
- "@stdlib/utils-library-manifest": "^0.2.1",
48
+ "@stdlib/utils-library-manifest": "^0.2.3",
42
49
  "@stdlib/utils-try-require": "^0.2.2"
43
50
  },
44
51
  "devDependencies": {},
@@ -79,7 +86,6 @@
79
86
  "single",
80
87
  "float32array"
81
88
  ],
82
- "__stdlib__": {},
83
89
  "funding": {
84
90
  "type": "opencollective",
85
91
  "url": "https://opencollective.com/stdlib"
package/src/addon.c ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "stdlib/blas/ext/base/dsnannsumors.h"
20
+ #include "stdlib/blas/base/shared.h"
21
+ #include "stdlib/napi/export.h"
22
+ #include "stdlib/napi/argv.h"
23
+ #include "stdlib/napi/argv_int64.h"
24
+ #include "stdlib/napi/argv_strided_float32array.h"
25
+ #include "stdlib/napi/argv_strided_float64array.h"
26
+ #include "stdlib/strided/base/stride2offset.h"
27
+ #include <stdint.h>
28
+ #include <node_api.h>
29
+
30
+ /**
31
+ * Receives JavaScript callback invocation data.
32
+ *
33
+ * @private
34
+ * @param env environment under which the function is invoked
35
+ * @param info callback data
36
+ * @return Node-API value
37
+ */
38
+ static napi_value addon( napi_env env, napi_callback_info info ) {
39
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 5 );
40
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
41
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
42
+ STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 4 );
43
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
44
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 3 );
45
+
46
+ int64_t io = stdlib_strided_stride2offset( 2, strideOut );
47
+ CBLAS_INT n;
48
+ Out[ io ] = API_SUFFIX(stdlib_strided_dsnannsumors)( N, X, strideX, &n );
49
+ Out[ io + strideOut ] = (double)n;
50
+
51
+ return NULL;
52
+ }
53
+
54
+ /**
55
+ * Receives JavaScript callback invocation data.
56
+ *
57
+ * @private
58
+ * @param env environment under which the function is invoked
59
+ * @param info callback data
60
+ * @return Node-API value
61
+ */
62
+ static napi_value addon_method( napi_env env, napi_callback_info info ) {
63
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 7 );
64
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
65
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
66
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
67
+ STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 5 );
68
+ STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 6 );
69
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
70
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 4 );
71
+
72
+ CBLAS_INT n;
73
+ Out[ offsetOut ] = API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( N, X, strideX, offsetX, &n );
74
+ Out[ offsetOut + strideOut ] = (double)n;
75
+
76
+ return NULL;
77
+ }
78
+
79
+ STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
package/src/main.c ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2020 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "stdlib/blas/ext/base/dsnannsumors.h"
20
+ #include "stdlib/strided/base/stride2offset.h"
21
+ #include "stdlib/math/base/assert/is_nanf.h"
22
+ #include "stdlib/blas/base/shared.h"
23
+
24
+ /**
25
+ * Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.
26
+ *
27
+ * @param N number of indexed elements
28
+ * @param X input array
29
+ * @param strideX stride length
30
+ * @param n pointer for storing the number of non-NaN elements
31
+ * @return output value
32
+ */
33
+ double API_SUFFIX(stdlib_strided_dsnannsumors)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, CBLAS_INT *n ) {
34
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
35
+ return API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( N, X, strideX, ox, n );
36
+ }
37
+
38
+ /**
39
+ * Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
40
+ *
41
+ * @param N number of indexed elements
42
+ * @param X input array
43
+ * @param strideX stride length
44
+ * @param offsetX starting index
45
+ * @param n pointer for storing the number of non-NaN elements
46
+ * @return output value
47
+ */
48
+ double API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n ) {
49
+ CBLAS_INT ix;
50
+ CBLAS_INT i;
51
+ double sum;
52
+
53
+ sum = 0.0;
54
+ *n = 0;
55
+ if ( N <= 0 ) {
56
+ return sum;
57
+ }
58
+ ix = offsetX;
59
+ if ( strideX == 0 ) {
60
+ if ( stdlib_base_is_nanf( X[ ix ] ) ) {
61
+ return sum;
62
+ }
63
+ *n += N;
64
+ return X[ ix ] * N;
65
+ }
66
+ for ( i = 0; i < N; i++ ) {
67
+ if ( !stdlib_base_is_nanf( X[ ix ] ) ) {
68
+ sum += (double)X[ ix ];
69
+ *n += 1;
70
+ }
71
+ ix += strideX;
72
+ }
73
+ return sum;
74
+ }
package/src/addon.cpp DELETED
@@ -1,162 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- #include "stdlib/blas/ext/base/dsnannsumors.h"
20
- #include <node_api.h>
21
- #include <stdint.h>
22
- #include <stdlib.h>
23
- #include <stdbool.h>
24
- #include <assert.h>
25
-
26
- /**
27
- * Add-on namespace.
28
- */
29
- namespace stdlib_blas_ext_base_dsnannsumors {
30
-
31
- /**
32
- * Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.
33
- *
34
- * ## Notes
35
- *
36
- * - When called from JavaScript, the function expects five arguments:
37
- *
38
- * - `N`: number of indexed elements
39
- * - `X`: input array
40
- * - `strideX`: `X` stride length
41
- * - `Out`: output array
42
- * - `strideOut`: `Out` stride length
43
- */
44
- napi_value node_dsnannsumors( napi_env env, napi_callback_info info ) {
45
- napi_status status;
46
-
47
- size_t argc = 5;
48
- napi_value argv[ 5 ];
49
- status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
50
- assert( status == napi_ok );
51
-
52
- if ( argc < 5 ) {
53
- napi_throw_error( env, nullptr, "invalid invocation. Must provide 5 arguments." );
54
- return nullptr;
55
- }
56
-
57
- napi_valuetype vtype0;
58
- status = napi_typeof( env, argv[ 0 ], &vtype0 );
59
- assert( status == napi_ok );
60
- if ( vtype0 != napi_number ) {
61
- napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
62
- return nullptr;
63
- }
64
-
65
- bool res1;
66
- status = napi_is_typedarray( env, argv[ 1 ], &res1 );
67
- assert( status == napi_ok );
68
- if ( res1 == false ) {
69
- napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
70
- return nullptr;
71
- }
72
-
73
- napi_valuetype vtype2;
74
- status = napi_typeof( env, argv[ 2 ], &vtype2 );
75
- assert( status == napi_ok );
76
- if ( vtype2 != napi_number ) {
77
- napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." );
78
- return nullptr;
79
- }
80
-
81
- bool res3;
82
- status = napi_is_typedarray( env, argv[ 3 ], &res3 );
83
- assert( status == napi_ok );
84
- if ( res3 == false ) {
85
- napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float64Array." );
86
- return nullptr;
87
- }
88
-
89
- napi_valuetype vtype4;
90
- status = napi_typeof( env, argv[ 4 ], &vtype4 );
91
- assert( status == napi_ok );
92
- if ( vtype4 != napi_number ) {
93
- napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a number." );
94
- return nullptr;
95
- }
96
-
97
- int64_t N;
98
- status = napi_get_value_int64( env, argv[ 0 ], &N );
99
- assert( status == napi_ok );
100
-
101
- int64_t strideX;
102
- status = napi_get_value_int64( env, argv[ 2 ], &strideX );
103
- assert( status == napi_ok );
104
-
105
- int64_t strideOut;
106
- status = napi_get_value_int64( env, argv[ 4 ], &strideOut );
107
- assert( status == napi_ok );
108
-
109
- napi_typedarray_type vtype1;
110
- size_t xlen;
111
- void *X;
112
- status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr );
113
- assert( status == napi_ok );
114
- if ( vtype1 != napi_float32_array ) {
115
- napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
116
- return nullptr;
117
- }
118
- if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) {
119
- napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." );
120
- return nullptr;
121
- }
122
-
123
- napi_typedarray_type vtype3;
124
- size_t olen;
125
- void *Out;
126
- status = napi_get_typedarray_info( env, argv[ 3 ], &vtype3, &olen, &Out, nullptr, nullptr );
127
- assert( status == napi_ok );
128
- if ( vtype3 != napi_float64_array ) {
129
- napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float64Array." );
130
- return nullptr;
131
- }
132
- if ( llabs(strideOut) > (int64_t)olen ) {
133
- napi_throw_range_error( env, nullptr, "invalid argument. Fourth argument has insufficient elements based on the associated stride and the required number of output elements." );
134
- return nullptr;
135
- }
136
-
137
- int64_t io;
138
- if ( strideOut < 0 ) {
139
- io = -strideOut;
140
- } else {
141
- io = 0;
142
- }
143
-
144
- double *out = (double *)Out;
145
- int64_t n;
146
- out[ io ] = stdlib_strided_dsnannsumors( N, (float *)X, strideX, &n );
147
- out[ io+strideOut ] = (double)n;
148
-
149
- return nullptr;
150
-
151
- }
152
-
153
- napi_value Init( napi_env env, napi_value exports ) {
154
- napi_status status;
155
- napi_value fcn;
156
- status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dsnannsumors, NULL, &fcn );
157
- assert( status == napi_ok );
158
- return fcn;
159
- }
160
-
161
- NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
162
- } // end namespace stdlib_blas_ext_base_dsnannsumors
@@ -1,62 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- #include "stdlib/blas/ext/base/dsnannsumors.h"
20
- #include "stdlib/math/base/assert/is_nanf.h"
21
- #include <stdint.h>
22
-
23
- /**
24
- * Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.
25
- *
26
- * @param N number of indexed elements
27
- * @param X input array
28
- * @param stride stride length
29
- * @param n pointer for storing the number of non-NaN elements
30
- * @return output value
31
- */
32
- double stdlib_strided_dsnannsumors( const int64_t N, const float *X, const int64_t stride, int64_t *n ) {
33
- double sum;
34
- int64_t ix;
35
- int64_t i;
36
-
37
- sum = 0.0;
38
- *n = 0;
39
- if ( N <= 0 ) {
40
- return sum;
41
- }
42
- if ( N == 1 || stride == 0 ) {
43
- if ( stdlib_base_is_nanf( X[ 0 ] ) ) {
44
- return sum;
45
- }
46
- *n += 1;
47
- return X[ 0 ];
48
- }
49
- if ( stride < 0 ) {
50
- ix = (1-N) * stride;
51
- } else {
52
- ix = 0;
53
- }
54
- for ( i = 0; i < N; i++ ) {
55
- if ( !stdlib_base_is_nanf( X[ ix ] ) ) {
56
- sum += (double)X[ ix ];
57
- *n += 1;
58
- }
59
- ix += stride;
60
- }
61
- return sum;
62
- }