@stdlib/blas-ext-base-dsnansumors 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
@@ -59,7 +59,7 @@ npm install @stdlib/blas-ext-base-dsnansumors
59
59
  var dsnansumors = require( '@stdlib/blas-ext-base-dsnansumors' );
60
60
  ```
61
61
 
62
- #### dsnansumors( N, x, stride )
62
+ #### dsnansumors( N, x, strideX )
63
63
 
64
64
  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.
65
65
 
@@ -67,9 +67,8 @@ Computes the sum of single-precision floating-point strided array elements, igno
67
67
  var Float32Array = require( '@stdlib/array-float32' );
68
68
 
69
69
  var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
70
- var N = x.length;
71
70
 
72
- var v = dsnansumors( N, x, 1 );
71
+ var v = dsnansumors( x.length, x, 1 );
73
72
  // returns 1.0
74
73
  ```
75
74
 
@@ -77,9 +76,9 @@ The function has the following parameters:
77
76
 
78
77
  - **N**: number of indexed elements.
79
78
  - **x**: input [`Float32Array`][@stdlib/array/float32].
80
- - **stride**: index increment for `x`.
79
+ - **stride**: stride length for `x`.
81
80
 
82
- The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in `x`,
81
+ The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element:
83
82
 
84
83
  ```javascript
85
84
  var Float32Array = require( '@stdlib/array-float32' );
@@ -104,7 +103,7 @@ var v = dsnansumors( 4, x1, 2 );
104
103
  // returns 5.0
105
104
  ```
106
105
 
107
- #### dsnansumors.ndarray( N, x, stride, offset )
106
+ #### dsnansumors.ndarray( N, x, strideX, offsetX )
108
107
 
109
108
  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.
110
109
 
@@ -113,15 +112,15 @@ var Float32Array = require( '@stdlib/array-float32' );
113
112
 
114
113
  var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
115
114
 
116
- var v = dsnansumors.ndarray( 4, x, 1, 0 );
115
+ var v = dsnansumors.ndarray( x.length, x, 1, 0 );
117
116
  // returns 1.0
118
117
  ```
119
118
 
120
119
  The function has the following additional parameters:
121
120
 
122
- - **offset**: starting index for `x`.
121
+ - **offsetX**: starting index for `x`.
123
122
 
124
- 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
123
+ 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 element starting from the second element:
125
124
 
126
125
  ```javascript
127
126
  var Float32Array = require( '@stdlib/array-float32' );
@@ -177,6 +176,124 @@ console.log( v );
177
176
 
178
177
  <!-- /.examples -->
179
178
 
179
+ <!-- C interface documentation. -->
180
+
181
+ * * *
182
+
183
+ <section class="c">
184
+
185
+ ## C APIs
186
+
187
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
188
+
189
+ <section class="intro">
190
+
191
+ </section>
192
+
193
+ <!-- /.intro -->
194
+
195
+ <!-- C usage documentation. -->
196
+
197
+ <section class="usage">
198
+
199
+ ### Usage
200
+
201
+ ```c
202
+ #include "stdlib/blas/ext/base/dsnansumors.h"
203
+ ```
204
+
205
+ #### stdlib_strided_dsnansumors( N, \*X, strideX )
206
+
207
+ 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.
208
+
209
+ ```c
210
+ const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
211
+
212
+ double v = stdlib_strided_dsnansumors( 4, x, 1 );
213
+ // returns 1.0
214
+ ```
215
+
216
+ The function accepts the following arguments:
217
+
218
+ - **N**: `[in] CBLAS_INT` number of indexed elements.
219
+ - **X**: `[in] float*` input array.
220
+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
221
+
222
+ ```c
223
+ double stdlib_strided_dsnansumors( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
224
+ ```
225
+
226
+ #### stdlib_strided_dsnansumors_ndarray( N, \*X, strideX, offsetX )
227
+
228
+ 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, and returning an extended precision result.
229
+
230
+ ```c
231
+ const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
232
+
233
+ double v = stdlib_strided_dsnansumors_ndarray( 4, x, 1, 0 );
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
+ - **offsetX**: `[in] CBLAS_INT` starting index for `X`.
243
+
244
+ ```c
245
+ double stdlib_strided_dsnansumors_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
246
+ ```
247
+
248
+ </section>
249
+
250
+ <!-- /.usage -->
251
+
252
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
253
+
254
+ <section class="notes">
255
+
256
+ </section>
257
+
258
+ <!-- /.notes -->
259
+
260
+ <!-- C API usage examples. -->
261
+
262
+ <section class="examples">
263
+
264
+ ### Examples
265
+
266
+ ```c
267
+ #include "stdlib/blas/ext/base/dsnansumors.h"
268
+ #include "stdlib/blas/base/shared.h"
269
+ #include <stdio.h>
270
+
271
+ int main( void ) {
272
+ // Create a strided array:
273
+ 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 };
274
+
275
+ // Specify the number of elements:
276
+ const int N = 5;
277
+
278
+ // Specify the stride length:
279
+ const int strideX = 2;
280
+
281
+ // Compute the sum:
282
+ double v = stdlib_strided_dsnansumors( N, x, strideX );
283
+
284
+ // Print the result:
285
+ printf( "sum: %lf\n", v );
286
+ }
287
+ ```
288
+
289
+ </section>
290
+
291
+ <!-- /.examples -->
292
+
293
+ </section>
294
+
295
+ <!-- /.c -->
296
+
180
297
  <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
181
298
 
182
299
  <section class="related">
@@ -185,7 +302,7 @@ console.log( v );
185
302
 
186
303
  ## See Also
187
304
 
188
- - <span class="package-name">[`@stdlib/stats-base/dsnanmeanors`][@stdlib/stats/base/dsnanmeanors]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array, ignoring NaN values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.</span>
305
+ - <span class="package-name">[`@stdlib/stats-strided/dsnanmeanors`][@stdlib/stats/strided/dsnanmeanors]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array, ignoring NaN values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.</span>
189
306
  - <span class="package-name">[`@stdlib/blas-ext/base/dssum`][@stdlib/blas/ext/base/dssum]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements using extended accumulation and returning an extended precision result.</span>
190
307
  - <span class="package-name">[`@stdlib/blas-ext/base/dssumors`][@stdlib/blas/ext/base/dssumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements using ordinary recursive summation with extended accumulation and returning an extended precision result.</span>
191
308
  - <span class="package-name">[`@stdlib/blas-ext/base/snansumors`][@stdlib/blas/ext/base/snansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
@@ -220,7 +337,7 @@ See [LICENSE][stdlib-license].
220
337
 
221
338
  ## Copyright
222
339
 
223
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
340
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
224
341
 
225
342
  </section>
226
343
 
@@ -233,8 +350,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
233
350
  [npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsnansumors.svg
234
351
  [npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsnansumors
235
352
 
236
- [test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansumors/actions/workflows/test.yml/badge.svg?branch=v0.2.2
237
- [test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansumors/actions/workflows/test.yml?query=branch:v0.2.2
353
+ [test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansumors/actions/workflows/test.yml/badge.svg?branch=v0.3.0
354
+ [test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansumors/actions/workflows/test.yml?query=branch:v0.3.0
238
355
 
239
356
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsnansumors/main.svg
240
357
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsnansumors?branch=main
@@ -246,8 +363,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
246
363
 
247
364
  -->
248
365
 
249
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
250
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
366
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
367
+ [chat-url]: https://stdlib.zulipchat.com
251
368
 
252
369
  [stdlib]: https://github.com/stdlib-js/stdlib
253
370
 
@@ -272,7 +389,7 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
272
389
 
273
390
  <!-- <related-links> -->
274
391
 
275
- [@stdlib/stats/base/dsnanmeanors]: https://www.npmjs.com/package/@stdlib/stats-base-dsnanmeanors
392
+ [@stdlib/stats/strided/dsnanmeanors]: https://www.npmjs.com/package/@stdlib/stats-strided-dsnanmeanors
276
393
 
277
394
  [@stdlib/blas/ext/base/dssum]: https://www.npmjs.com/package/@stdlib/blas-ext-base-dssum
278
395
 
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var t=function(i,r){return function(){return r||i((r={exports:{}}).exports,r),r.exports}};var q=t(function(x,f){
2
- var o=require('@stdlib/math-base-assert-is-nan/dist');function R(i,r,u){var a,e,n;if(a=0,i<=0)return a;if(i===1||u===0)return o(r[0])?a:r[0];for(u<0?e=(1-i)*u:e=0,n=0;n<i;n++)o(r[e])===!1&&(a+=r[e]),e+=u;return a}f.exports=R
3
- });var l=t(function(z,c){
4
- var m=require('@stdlib/math-base-assert-is-nan/dist');function _(i,r,u,a){var e,n,s;if(e=0,i<=0)return e;if(i===1||u===0)return m(r[a])?e:r[a];for(n=a,s=0;s<i;s++)m(r[n])===!1&&(e+=r[n]),n+=u;return e}c.exports=_
5
- });var y=t(function(A,d){
6
- var E=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),p=q(),O=l();E(p,"ndarray",O);d.exports=p
7
- });var b=require("path").join,g=require('@stdlib/utils-try-require/dist'),h=require('@stdlib/assert-is-error/dist'),k=y(),v,j=g(b(__dirname,"./native.js"));h(j)?v=k:v=j;module.exports=v;
1
+ "use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var o=t(function(A,q){
2
+ var v=require('@stdlib/math-base-assert-is-nan/dist');function R(e,r,i,j){var n,a,u,s;if(e<=0)return 0;if(a=j,i===0)return v(r[a])?0:e*r[a];for(s=0;s<e&&(u=r[a],v(u)!==!1);s++)a+=i;if(s===e)return 0;for(n=u,a+=i,s+=1;s<e;s++)v(r[a])===!1&&(n+=r[a]),a+=i;return n}q.exports=R
3
+ });var c=t(function(B,m){
4
+ var _=require('@stdlib/strided-base-stride2offset/dist'),b=o();function k(e,r,i){return b(e,r,i,_(e,i))}m.exports=k
5
+ });var y=t(function(C,p){
6
+ var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),d=c(),E=o();x(d,"ndarray",E);p.exports=d
7
+ });var O=require("path").join,g=require('@stdlib/utils-try-require/dist'),h=require('@stdlib/assert-is-error/dist'),w=y(),f,l=g(O(__dirname,"./native.js"));h(l)?f=w:f=l;module.exports=f;
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/dsnansumors.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} stride - stride length\n* @returns {number} sum\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n* var N = x.length;\n*\n* var v = dsnansumors( N, x, 1 );\n* // returns 1.0\n*/\nfunction dsnansumors( N, x, stride ) {\n\tvar sum;\n\tvar ix;\n\tvar i;\n\n\tsum = 0.0;\n\tif ( N <= 0 ) {\n\t\treturn sum;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnan( x[ 0 ] ) ) {\n\t\t\treturn sum;\n\t\t}\n\t\treturn x[ 0 ];\n\t}\n\tif ( stride < 0 ) {\n\t\tix = (1-N) * stride;\n\t} else {\n\t\tix = 0;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\tsum += x[ ix ];\n\t\t}\n\t\tix += stride;\n\t}\n\treturn sum;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\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} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @returns {number} sum\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\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*\n* var v = dsnansumors( 5, x, 2, 1 );\n* // returns 5.0\n*/\nfunction dsnansumors( N, x, stride, offset ) {\n\tvar sum;\n\tvar ix;\n\tvar i;\n\n\tsum = 0.0;\n\tif ( N <= 0 ) {\n\t\treturn sum;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnan( x[ offset ] ) ) {\n\t\t\treturn sum;\n\t\t}\n\t\treturn x[ offset ];\n\t}\n\tix = offset;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\tsum += x[ ix ];\n\t\t}\n\t\tix += stride;\n\t}\n\treturn sum;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\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 dsnansumors = require( './dsnansumors.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsnansumors, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\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-dsnansumors\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansumors = require( '@stdlib/blas-ext-base-dsnansumors' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n* var N = x.length;\n*\n* var v = dsnansumors( N, x, 1 );\n* // returns 1.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansumors = require( '@stdlib/blas-ext-base-dsnansumors' );\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*\n* var v = dsnansumors.ndarray( 5, x, 2, 1 );\n* // returns 5.0\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 dsnansumors;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsnansumors = main;\n} else {\n\tdsnansumors = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\n\n// exports: { \"ndarray\": \"dsnansumors.ndarray\" }\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EAsBvD,SAASC,EAAaC,EAAGC,EAAGC,EAAS,CACpC,IAAIC,EACAC,EACAC,EAGJ,GADAF,EAAM,EACDH,GAAK,EACT,OAAOG,EAER,GAAKH,IAAM,GAAKE,IAAW,EAC1B,OAAKJ,EAAOG,EAAG,CAAE,CAAE,EACXE,EAEDF,EAAG,CAAE,EAOb,IALKC,EAAS,EACbE,GAAM,EAAEJ,GAAKE,EAEbE,EAAK,EAEAC,EAAI,EAAGA,EAAIL,EAAGK,IACdP,EAAOG,EAAGG,CAAG,CAAE,IAAM,KACzBD,GAAOF,EAAGG,CAAG,GAEdA,GAAMF,EAEP,OAAOC,CACR,CAKAN,EAAO,QAAUE,IC5EjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EAsBvD,SAASC,EAAaC,EAAGC,EAAGC,EAAQC,EAAS,CAC5C,IAAIC,EACAC,EACAC,EAGJ,GADAF,EAAM,EACDJ,GAAK,EACT,OAAOI,EAER,GAAKJ,IAAM,GAAKE,IAAW,EAC1B,OAAKJ,EAAOG,EAAGE,CAAO,CAAE,EAChBC,EAEDH,EAAGE,CAAO,EAGlB,IADAE,EAAKF,EACCG,EAAI,EAAGA,EAAIN,EAAGM,IACdR,EAAOG,EAAGI,CAAG,CAAE,IAAM,KACzBD,GAAOH,EAAGI,CAAG,GAEdA,GAAMH,EAEP,OAAOE,CACR,CAKAP,EAAO,QAAUE,ICxEjB,IAAAQ,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAc,IACdC,EAAU,IAKdF,EAAaC,EAAa,UAAWC,CAAQ,EAK7CH,EAAO,QAAUE,ICajB,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,EAAcD,EAEdC,EAAcC,EAMf,OAAO,QAAUD",
6
- "names": ["require_dsnansumors", "__commonJSMin", "exports", "module", "isnan", "dsnansumors", "N", "x", "stride", "sum", "ix", "i", "require_ndarray", "__commonJSMin", "exports", "module", "isnan", "dsnansumors", "N", "x", "stride", "offset", "sum", "ix", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsnansumors", "ndarray", "join", "tryRequire", "isError", "main", "dsnansumors", "tmp"]
3
+ "sources": ["../lib/ndarray.js", "../lib/dsnansumors.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 - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {number} sum\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\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*\n* var v = dsnansumors( 5, x, 2, 1 );\n* // returns 5.0\n*/\nfunction dsnansumors( N, x, strideX, offsetX ) {\n\tvar sum;\n\tvar ix;\n\tvar v;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn 0.0;\n\t}\n\tix = offsetX;\n\tif ( strideX === 0 ) {\n\t\tif ( isnan( x[ ix ] ) ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn N * x[ ix ];\n\t}\n\t// Find the first non-NaN element...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv = x[ ix ];\n\t\tif ( isnan( v ) === false ) {\n\t\t\tbreak;\n\t\t}\n\t\tix += strideX;\n\t}\n\tif ( i === N ) {\n\t\treturn 0.0;\n\t}\n\tsum = v;\n\tix += strideX;\n\ti += 1;\n\tfor ( ; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\tsum += x[ ix ];\n\t\t}\n\t\tix += strideX;\n\t}\n\treturn sum;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\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 - stride length\n* @returns {number} sum\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n*\n* var v = dsnansumors( x.length, x, 1 );\n* // returns 1.0\n*/\nfunction dsnansumors( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\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 dsnansumors = require( './dsnansumors.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsnansumors, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\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-dsnansumors\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansumors = require( '@stdlib/blas-ext-base-dsnansumors' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n*\n* var v = dsnansumors( x.length, x, 1 );\n* // returns 1.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansumors = require( '@stdlib/blas-ext-base-dsnansumors' );\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*\n* var v = dsnansumors.ndarray( 5, x, 2, 1 );\n* // returns 5.0\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 dsnansumors;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsnansumors = main;\n} else {\n\tdsnansumors = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumors;\n\n// exports: { \"ndarray\": \"dsnansumors.ndarray\" }\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EAsBvD,SAASC,EAAaC,EAAGC,EAAGC,EAASC,EAAU,CAC9C,IAAIC,EACAC,EACAC,EACAC,EAEJ,GAAKP,GAAK,EACT,MAAO,GAGR,GADAK,EAAKF,EACAD,IAAY,EAChB,OAAKJ,EAAOG,EAAGI,CAAG,CAAE,EACZ,EAEDL,EAAIC,EAAGI,CAAG,EAGlB,IAAME,EAAI,EAAGA,EAAIP,IAChBM,EAAIL,EAAGI,CAAG,EACLP,EAAOQ,CAAE,IAAM,IAFDC,IAKnBF,GAAMH,EAEP,GAAKK,IAAMP,EACV,MAAO,GAKR,IAHAI,EAAME,EACND,GAAMH,EACNK,GAAK,EACGA,EAAIP,EAAGO,IACTT,EAAOG,EAAGI,CAAG,CAAE,IAAM,KACzBD,GAAOH,EAAGI,CAAG,GAEdA,GAAMH,EAEP,OAAOE,CACR,CAKAP,EAAO,QAAUE,ICtFjB,IAAAS,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAqBd,SAASC,EAAaC,EAAGC,EAAGC,EAAU,CACrC,OAAOJ,EAASE,EAAGC,EAAGC,EAASL,EAAeG,EAAGE,CAAQ,CAAE,CAC5D,CAKAN,EAAO,QAAUG,ICnDjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAc,IACdC,EAAU,IAKdF,EAAaC,EAAa,UAAWC,CAAQ,EAK7CH,EAAO,QAAUE,ICYjB,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,EAAcD,EAEdC,EAAcC,EAMf,OAAO,QAAUD",
6
+ "names": ["require_ndarray", "__commonJSMin", "exports", "module", "isnan", "dsnansumors", "N", "x", "strideX", "offsetX", "sum", "ix", "v", "i", "require_dsnansumors", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "dsnansumors", "N", "x", "strideX", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsnansumors", "ndarray", "join", "tryRequire", "isError", "main", "dsnansumors", "tmp"]
7
7
  }
@@ -27,7 +27,7 @@ interface Routine {
27
27
  *
28
28
  * @param N - number of indexed elements
29
29
  * @param x - input array
30
- * @param stride - stride length
30
+ * @param strideX - stride length
31
31
  * @returns sum
32
32
  *
33
33
  * @example
@@ -38,15 +38,15 @@ interface Routine {
38
38
  * var v = dsnansumors( x.length, x, 1 );
39
39
  * // returns 1.0
40
40
  */
41
- ( N: number, x: Float32Array, stride: number ): number;
41
+ ( N: number, x: Float32Array, strideX: number ): number;
42
42
 
43
43
  /**
44
- * 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.
44
+ * 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, and returning an extended precision result.
45
45
  *
46
46
  * @param N - number of indexed elements
47
47
  * @param x - input array
48
- * @param stride - stride length
49
- * @param offset - starting index
48
+ * @param strideX - stride length
49
+ * @param offsetX - starting index
50
50
  * @returns sum
51
51
  *
52
52
  * @example
@@ -57,7 +57,7 @@ interface Routine {
57
57
  * var v = dsnansumors.ndarray( x.length, x, 1, 0 );
58
58
  * // returns 1.0
59
59
  */
60
- ndarray( N: number, x: Float32Array, stride: number, offset: number ): number;
60
+ ndarray( N: number, x: Float32Array, strideX: number, offsetX: number ): number;
61
61
  }
62
62
 
63
63
  /**
@@ -65,7 +65,7 @@ interface Routine {
65
65
  *
66
66
  * @param N - number of indexed elements
67
67
  * @param x - input array
68
- * @param stride - stride length
68
+ * @param strideX - stride length
69
69
  * @returns sum
70
70
  *
71
71
  * @example
@@ -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_DSNANSUMORS_H
23
20
  #define STDLIB_BLAS_EXT_BASE_DSNANSUMORS_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_dsnansumors( const int64_t N, const float *X, const int64_t stride );
34
+ double API_SUFFIX(stdlib_strided_dsnansumors)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
35
+
36
+ /**
37
+ * 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, and returning an extended precision result.
38
+ */
39
+ double API_SUFFIX(stdlib_strided_dsnansumors_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
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 //
@@ -30,45 +31,19 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
30
31
  *
31
32
  * @param {PositiveInteger} N - number of indexed elements
32
33
  * @param {Float32Array} x - input array
33
- * @param {integer} stride - stride length
34
+ * @param {integer} strideX - stride length
34
35
  * @returns {number} sum
35
36
  *
36
37
  * @example
37
38
  * var Float32Array = require( '@stdlib/array-float32' );
38
39
  *
39
40
  * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
40
- * var N = x.length;
41
41
  *
42
- * var v = dsnansumors( N, x, 1 );
42
+ * var v = dsnansumors( x.length, x, 1 );
43
43
  * // returns 1.0
44
44
  */
45
- function dsnansumors( N, x, stride ) {
46
- var sum;
47
- var ix;
48
- var i;
49
-
50
- sum = 0.0;
51
- if ( N <= 0 ) {
52
- return sum;
53
- }
54
- if ( N === 1 || stride === 0 ) {
55
- if ( isnan( x[ 0 ] ) ) {
56
- return sum;
57
- }
58
- return x[ 0 ];
59
- }
60
- if ( stride < 0 ) {
61
- ix = (1-N) * stride;
62
- } else {
63
- ix = 0;
64
- }
65
- for ( i = 0; i < N; i++ ) {
66
- if ( isnan( x[ ix ] ) === false ) {
67
- sum += x[ ix ];
68
- }
69
- ix += stride;
70
- }
71
- return sum;
45
+ function dsnansumors( N, x, strideX ) {
46
+ return ndarray( N, x, strideX, stride2offset( N, strideX ) );
72
47
  }
73
48
 
74
49
 
@@ -30,20 +30,19 @@ var addon = require( './../src/addon.node' );
30
30
  *
31
31
  * @param {PositiveInteger} N - number of indexed elements
32
32
  * @param {Float32Array} x - input array
33
- * @param {integer} stride - stride length
33
+ * @param {integer} strideX - stride length
34
34
  * @returns {number} sum
35
35
  *
36
36
  * @example
37
37
  * var Float32Array = require( '@stdlib/array-float32' );
38
38
  *
39
39
  * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
40
- * var N = x.length;
41
40
  *
42
- * var v = dsnansumors( N, x, 1 );
41
+ * var v = dsnansumors( x.length, x, 1 );
43
42
  * // returns 1.0
44
43
  */
45
- function dsnansumors( N, x, stride ) {
46
- return addon( N, x, stride );
44
+ function dsnansumors( N, x, strideX ) {
45
+ return addon( N, x, strideX );
47
46
  }
48
47
 
49
48
 
package/lib/index.js CHANGED
@@ -28,9 +28,8 @@
28
28
  * var dsnansumors = require( '@stdlib/blas-ext-base-dsnansumors' );
29
29
  *
30
30
  * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
31
- * var N = x.length;
32
31
  *
33
- * var v = dsnansumors( N, x, 1 );
32
+ * var v = dsnansumors( x.length, x, 1 );
34
33
  * // returns 1.0
35
34
  *
36
35
  * @example
package/lib/ndarray.js CHANGED
@@ -30,8 +30,8 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
30
30
  *
31
31
  * @param {PositiveInteger} N - number of indexed elements
32
32
  * @param {Float32Array} x - input array
33
- * @param {integer} stride - stride length
34
- * @param {NonNegativeInteger} offset - starting index
33
+ * @param {integer} strideX - stride length
34
+ * @param {NonNegativeInteger} offsetX - starting index
35
35
  * @returns {number} sum
36
36
  *
37
37
  * @example
@@ -42,27 +42,41 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
42
42
  * var v = dsnansumors( 5, x, 2, 1 );
43
43
  * // returns 5.0
44
44
  */
45
- function dsnansumors( N, x, stride, offset ) {
45
+ function dsnansumors( N, x, strideX, offsetX ) {
46
46
  var sum;
47
47
  var ix;
48
+ var v;
48
49
  var i;
49
50
 
50
- sum = 0.0;
51
51
  if ( N <= 0 ) {
52
- return sum;
52
+ return 0.0;
53
53
  }
54
- if ( N === 1 || stride === 0 ) {
55
- if ( isnan( x[ offset ] ) ) {
56
- return sum;
54
+ ix = offsetX;
55
+ if ( strideX === 0 ) {
56
+ if ( isnan( x[ ix ] ) ) {
57
+ return 0.0;
57
58
  }
58
- return x[ offset ];
59
+ return N * x[ ix ];
59
60
  }
60
- ix = offset;
61
+ // Find the first non-NaN element...
61
62
  for ( i = 0; i < N; i++ ) {
63
+ v = x[ ix ];
64
+ if ( isnan( v ) === false ) {
65
+ break;
66
+ }
67
+ ix += strideX;
68
+ }
69
+ if ( i === N ) {
70
+ return 0.0;
71
+ }
72
+ sum = v;
73
+ ix += strideX;
74
+ i += 1;
75
+ for ( ; i < N; i++ ) {
62
76
  if ( isnan( x[ ix ] ) === false ) {
63
77
  sum += x[ ix ];
64
78
  }
65
- ix += stride;
79
+ ix += strideX;
66
80
  }
67
81
  return sum;
68
82
  }
@@ -20,9 +20,7 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var minViewBufferIndex = require( '@stdlib/strided-base-min-view-buffer-index' );
24
- var offsetView = require( '@stdlib/strided-base-offset-view' );
25
- var addon = require( './dsnansumors.native.js' );
23
+ var addon = require( './../src/addon.node' );
26
24
 
27
25
 
28
26
  // MAIN //
@@ -32,8 +30,8 @@ var addon = require( './dsnansumors.native.js' );
32
30
  *
33
31
  * @param {PositiveInteger} N - number of indexed elements
34
32
  * @param {Float32Array} x - input array
35
- * @param {integer} stride - stride length
36
- * @param {NonNegativeInteger} offset - starting index
33
+ * @param {integer} strideX - stride length
34
+ * @param {NonNegativeInteger} offsetX - starting index
37
35
  * @returns {number} sum
38
36
  *
39
37
  * @example
@@ -44,11 +42,8 @@ var addon = require( './dsnansumors.native.js' );
44
42
  * var v = dsnansumors( 5, x, 2, 1 );
45
43
  * // returns 5.0
46
44
  */
47
- function dsnansumors( N, x, stride, offset ) {
48
- var view;
49
- offset = minViewBufferIndex( N, stride, offset );
50
- view = offsetView( x, offset );
51
- return addon( N, view, stride );
45
+ function dsnansumors( N, x, strideX, offsetX ) {
46
+ return addon.ndarray( N, x, strideX, offsetX );
52
47
  }
53
48
 
54
49
 
package/manifest.json CHANGED
@@ -3,78 +3,79 @@
3
3
  "task": "build"
4
4
  },
5
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
- }
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
26
  ],
27
27
  "confs": [
28
28
  {
29
29
  "task": "build",
30
30
  "src": [
31
- "./src/dsnansumors.c"
31
+ "./src/main.c"
32
32
  ],
33
33
  "include": [
34
34
  "./include"
35
35
  ],
36
- "libraries": [
37
- "-lm"
38
- ],
36
+ "libraries": [],
39
37
  "libpath": [],
40
38
  "dependencies": [
41
39
  "@stdlib/napi-export",
42
40
  "@stdlib/napi-argv",
43
41
  "@stdlib/napi-argv-int64",
44
42
  "@stdlib/napi-argv-strided-float32array",
45
- "@stdlib/math-base-assert-is-nanf"
43
+ "@stdlib/math-base-assert-is-nanf",
44
+ "@stdlib/blas-base-shared",
45
+ "@stdlib/strided-base-stride2offset",
46
+ "@stdlib/napi-create-double"
46
47
  ]
47
48
  },
48
49
  {
49
50
  "task": "benchmark",
50
51
  "src": [
51
- "./src/dsnansumors.c"
52
+ "./src/main.c"
52
53
  ],
53
54
  "include": [
54
55
  "./include"
55
56
  ],
56
- "libraries": [
57
- "-lm"
58
- ],
57
+ "libraries": [],
59
58
  "libpath": [],
60
59
  "dependencies": [
61
- "@stdlib/math-base-assert-is-nanf"
60
+ "@stdlib/math-base-assert-is-nanf",
61
+ "@stdlib/blas-base-shared",
62
+ "@stdlib/strided-base-stride2offset"
62
63
  ]
63
64
  },
64
65
  {
65
66
  "task": "examples",
66
67
  "src": [
67
- "./src/dsnansumors.c"
68
+ "./src/main.c"
68
69
  ],
69
70
  "include": [
70
71
  "./include"
71
72
  ],
72
- "libraries": [
73
- "-lm"
74
- ],
73
+ "libraries": [],
75
74
  "libpath": [],
76
75
  "dependencies": [
77
- "@stdlib/math-base-assert-is-nanf"
76
+ "@stdlib/math-base-assert-is-nanf",
77
+ "@stdlib/blas-base-shared",
78
+ "@stdlib/strided-base-stride2offset"
78
79
  ]
79
80
  }
80
81
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-dsnansumors",
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,14 +35,17 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@stdlib/assert-is-error": "^0.2.2",
38
+ "@stdlib/blas-base-shared": "^0.1.0",
38
39
  "@stdlib/math-base-assert-is-nan": "^0.2.2",
39
40
  "@stdlib/math-base-assert-is-nanf": "^0.2.2",
40
41
  "@stdlib/napi-argv": "^0.2.2",
41
42
  "@stdlib/napi-argv-int64": "^0.2.2",
42
- "@stdlib/napi-argv-strided-float32array": "^0.2.1",
43
- "@stdlib/napi-export": "^0.2.2",
43
+ "@stdlib/napi-argv-strided-float32array": "^0.2.2",
44
+ "@stdlib/napi-create-double": "^0.0.2",
45
+ "@stdlib/napi-export": "^0.3.0",
46
+ "@stdlib/strided-base-stride2offset": "^0.1.0",
44
47
  "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
45
- "@stdlib/utils-library-manifest": "^0.2.2",
48
+ "@stdlib/utils-library-manifest": "^0.2.3",
46
49
  "@stdlib/utils-try-require": "^0.2.2"
47
50
  },
48
51
  "devDependencies": {},
@@ -83,7 +86,6 @@
83
86
  "single",
84
87
  "float32array"
85
88
  ],
86
- "__stdlib__": {},
87
89
  "funding": {
88
90
  "type": "opencollective",
89
91
  "url": "https://opencollective.com/stdlib"
package/src/addon.c CHANGED
@@ -17,12 +17,13 @@
17
17
  */
18
18
 
19
19
  #include "stdlib/blas/ext/base/dsnansumors.h"
20
+ #include "stdlib/blas/base/shared.h"
20
21
  #include "stdlib/napi/export.h"
21
22
  #include "stdlib/napi/argv.h"
22
23
  #include "stdlib/napi/argv_int64.h"
23
24
  #include "stdlib/napi/argv_strided_float32array.h"
25
+ #include "stdlib/napi/create_double.h"
24
26
  #include <node_api.h>
25
- #include <assert.h>
26
27
 
27
28
  /**
28
29
  * Receives JavaScript callback invocation data.
@@ -36,12 +37,25 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
36
37
  STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
37
38
  STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
38
39
  STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
40
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dsnansumors)( N, X, strideX ), v );
41
+ return v;
42
+ }
39
43
 
40
- napi_value v;
41
- napi_status status = napi_create_double( env, stdlib_strided_dsnansumors( N, X, strideX ), &v );
42
- assert( status == napi_ok );
43
-
44
+ /**
45
+ * Receives JavaScript callback invocation data.
46
+ *
47
+ * @param env environment under which the function is invoked
48
+ * @param info callback data
49
+ * @return Node-API value
50
+ */
51
+ static napi_value addon_method( napi_env env, napi_callback_info info ) {
52
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
53
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
54
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
55
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
56
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
57
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dsnansumors_ndarray)( N, X, strideX, offsetX ), v );
44
58
  return v;
45
59
  }
46
60
 
47
- STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
61
+ STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
package/src/main.c ADDED
@@ -0,0 +1,83 @@
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/dsnansumors.h"
20
+ #include "stdlib/math/base/assert/is_nanf.h"
21
+ #include "stdlib/blas/base/shared.h"
22
+ #include "stdlib/strided/base/stride2offset.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
+ * @return output value
31
+ */
32
+ double API_SUFFIX(stdlib_strided_dsnansumors)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) {
33
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
34
+ return API_SUFFIX(stdlib_strided_dsnansumors_ndarray)( N, X, strideX, ox );
35
+ }
36
+
37
+ /**
38
+ * 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, and returning an extended precision result.
39
+ *
40
+ * @param N number of indexed elements
41
+ * @param X input array
42
+ * @param strideX stride length
43
+ * @param offsetX starting index
44
+ * @return output value
45
+ */
46
+ double API_SUFFIX(stdlib_strided_dsnansumors_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
47
+ CBLAS_INT ix;
48
+ CBLAS_INT i;
49
+ double sum;
50
+ double v;
51
+
52
+ if ( N <= 0 ) {
53
+ return 0.0;
54
+ }
55
+ ix = offsetX;
56
+ if ( strideX == 0 ) {
57
+ if ( stdlib_base_is_nanf( X[ ix ] ) ) {
58
+ return 0.0;
59
+ }
60
+ return N * X[ ix ];
61
+ }
62
+ // Find the first non-NaN element...
63
+ for ( i = 0; i < N; i++ ) {
64
+ v = X[ ix ];
65
+ if ( !stdlib_base_is_nanf( v ) ) {
66
+ break;
67
+ }
68
+ ix += strideX;
69
+ }
70
+ if ( i == N ) {
71
+ return 0.0;
72
+ }
73
+ sum = (double)v;
74
+ ix += strideX;
75
+ i += 1;
76
+ for ( ; i < N; i++ ) {
77
+ if ( !stdlib_base_is_nanf( X[ ix ] ) ) {
78
+ sum += (double)X[ ix ];
79
+ }
80
+ ix += strideX;
81
+ }
82
+ return sum;
83
+ }
package/src/dsnansumors.c DELETED
@@ -1,58 +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/dsnansumors.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
- * @return output value
30
- */
31
- double stdlib_strided_dsnansumors( const int64_t N, const float *X, const int64_t stride ) {
32
- double sum;
33
- int64_t ix;
34
- int64_t i;
35
-
36
- sum = 0.0;
37
- if ( N <= 0 ) {
38
- return sum;
39
- }
40
- if ( N == 1 || stride == 0 ) {
41
- if ( stdlib_base_is_nanf( X[ 0 ] ) ) {
42
- return sum;
43
- }
44
- return X[ 0 ];
45
- }
46
- if ( stride < 0 ) {
47
- ix = (1-N) * stride;
48
- } else {
49
- ix = 0;
50
- }
51
- for ( i = 0; i < N; i++ ) {
52
- if ( !stdlib_base_is_nanf( X[ ix ] ) ) {
53
- sum += (double)X[ ix ];
54
- }
55
- ix += stride;
56
- }
57
- return sum;
58
- }