@stdlib/blas-ext-base-dsnansum 0.2.1 → 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 +1 -1
- package/README.md +145 -40
- package/dist/index.js +7 -7
- package/dist/index.js.map +4 -4
- package/docs/types/index.d.ts +7 -7
- package/include/stdlib/blas/ext/base/dsnansum.h +8 -6
- package/lib/dsnansum.js +7 -7
- package/lib/dsnansum.native.js +5 -6
- package/lib/index.js +2 -5
- package/lib/ndarray.js +5 -7
- package/lib/ndarray.native.js +6 -14
- package/manifest.json +80 -40
- package/package.json +13 -7
- package/src/addon.c +61 -0
- package/src/main.c +48 -0
- package/include.gypi +0 -53
- package/src/addon.cpp +0 -117
- package/src/dsnansum.c +0 -33
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ npm install @stdlib/blas-ext-base-dsnansum
|
|
|
59
59
|
var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
#### dsnansum( N, x,
|
|
62
|
+
#### dsnansum( N, x, strideX )
|
|
63
63
|
|
|
64
64
|
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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 = dsnansum(
|
|
71
|
+
var v = dsnansum( x.length, x, 1 );
|
|
73
72
|
// returns 1.0
|
|
74
73
|
```
|
|
75
74
|
|
|
@@ -77,18 +76,16 @@ The function has the following parameters:
|
|
|
77
76
|
|
|
78
77
|
- **N**: number of indexed elements.
|
|
79
78
|
- **x**: input [`Float32Array`][@stdlib/array/float32].
|
|
80
|
-
- **
|
|
79
|
+
- **strideX**: stride length for `x`.
|
|
81
80
|
|
|
82
|
-
The `N` and
|
|
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' );
|
|
86
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
87
85
|
|
|
88
86
|
var x = new Float32Array( [ 1.0, 2.0, NaN, -7.0, NaN, 3.0, 4.0, 2.0 ] );
|
|
89
|
-
var N = floor( x.length / 2 );
|
|
90
87
|
|
|
91
|
-
var v = dsnansum(
|
|
88
|
+
var v = dsnansum( 4, x, 2 );
|
|
92
89
|
// returns 5.0
|
|
93
90
|
```
|
|
94
91
|
|
|
@@ -98,45 +95,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
|
|
|
98
95
|
|
|
99
96
|
```javascript
|
|
100
97
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
101
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
102
98
|
|
|
103
99
|
var x0 = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
104
100
|
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
|
|
105
101
|
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
var v = dsnansum( N, x1, 2 );
|
|
102
|
+
var v = dsnansum( 4, x1, 2 );
|
|
109
103
|
// returns 5.0
|
|
110
104
|
```
|
|
111
105
|
|
|
112
|
-
#### dsnansum.ndarray( N, x,
|
|
106
|
+
#### dsnansum.ndarray( N, x, strideX, offsetX )
|
|
113
107
|
|
|
114
|
-
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values
|
|
108
|
+
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using extended accumulation and alternative indexing semantics, and returning an extended precision result.
|
|
115
109
|
|
|
116
110
|
```javascript
|
|
117
111
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
118
112
|
|
|
119
113
|
var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
|
|
120
|
-
var N = x.length;
|
|
121
114
|
|
|
122
|
-
var v = dsnansum.ndarray(
|
|
115
|
+
var v = dsnansum.ndarray( x.length, x, 1, 0 );
|
|
123
116
|
// returns 1.0
|
|
124
117
|
```
|
|
125
118
|
|
|
126
119
|
The function has the following additional parameters:
|
|
127
120
|
|
|
128
|
-
- **
|
|
121
|
+
- **offsetX**: starting index for `x`.
|
|
129
122
|
|
|
130
|
-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying
|
|
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:
|
|
131
124
|
|
|
132
125
|
```javascript
|
|
133
126
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
134
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
135
127
|
|
|
136
128
|
var x = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
137
|
-
var N = floor( x.length / 2 );
|
|
138
129
|
|
|
139
|
-
var v = dsnansum.ndarray(
|
|
130
|
+
var v = dsnansum.ndarray( 4, x, 2, 1 );
|
|
140
131
|
// returns 5.0
|
|
141
132
|
```
|
|
142
133
|
|
|
@@ -162,22 +153,19 @@ var v = dsnansum.ndarray( N, x, 2, 1 );
|
|
|
162
153
|
<!-- eslint no-undef: "error" -->
|
|
163
154
|
|
|
164
155
|
```javascript
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
var
|
|
156
|
+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
|
|
157
|
+
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
|
|
158
|
+
var filledarrayBy = require( '@stdlib/array-filled-by' );
|
|
168
159
|
var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );
|
|
169
160
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
x = new Float32Array( 10 );
|
|
174
|
-
for ( i = 0; i < x.length; i++ ) {
|
|
175
|
-
if ( randu() < 0.2 ) {
|
|
176
|
-
x[ i ] = NaN;
|
|
177
|
-
} else {
|
|
178
|
-
x[ i ] = round( randu()*100.0 );
|
|
161
|
+
function rand() {
|
|
162
|
+
if ( bernoulli( 0.7 ) > 0 ) {
|
|
163
|
+
return discreteUniform( -10, 10 );
|
|
179
164
|
}
|
|
165
|
+
return NaN;
|
|
180
166
|
}
|
|
167
|
+
|
|
168
|
+
var x = filledarrayBy( 10, 'float32', rand );
|
|
181
169
|
console.log( x );
|
|
182
170
|
|
|
183
171
|
var v = dsnansum( x.length, x, 1 );
|
|
@@ -188,6 +176,123 @@ console.log( v );
|
|
|
188
176
|
|
|
189
177
|
<!-- /.examples -->
|
|
190
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/dsnansum.h"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### stdlib_strided_dsnansum( N, \*X, strideX )
|
|
206
|
+
|
|
207
|
+
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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_dsnansum( 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_dsnansum( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
#### stdlib_strided_dsnansum_ndarray( N, \*X, strideX, offsetX )
|
|
227
|
+
|
|
228
|
+
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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_dsnansum_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_dsnansum_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/dsnansum.h"
|
|
268
|
+
#include <stdio.h>
|
|
269
|
+
|
|
270
|
+
int main( void ) {
|
|
271
|
+
// Create a strided array:
|
|
272
|
+
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 };
|
|
273
|
+
|
|
274
|
+
// Specify the number of elements:
|
|
275
|
+
const int N = 5;
|
|
276
|
+
|
|
277
|
+
// Specify the stride length:
|
|
278
|
+
const int strideX = 2;
|
|
279
|
+
|
|
280
|
+
// Compute the sum:
|
|
281
|
+
double v = stdlib_strided_dsnansum( N, x, strideX );
|
|
282
|
+
|
|
283
|
+
// Print the result:
|
|
284
|
+
printf( "sum: %lf\n", v );
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
</section>
|
|
289
|
+
|
|
290
|
+
<!-- /.examples -->
|
|
291
|
+
|
|
292
|
+
</section>
|
|
293
|
+
|
|
294
|
+
<!-- /.c -->
|
|
295
|
+
|
|
191
296
|
<section class="references">
|
|
192
297
|
|
|
193
298
|
</section>
|
|
@@ -202,7 +307,7 @@ console.log( v );
|
|
|
202
307
|
|
|
203
308
|
## See Also
|
|
204
309
|
|
|
205
|
-
- <span class="package-name">[`@stdlib/stats-
|
|
310
|
+
- <span class="package-name">[`@stdlib/stats-strided/dsnanmean`][@stdlib/stats/strided/dsnanmean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array, ignoring NaN values, using extended accumulation, and returning an extended precision result.</span>
|
|
206
311
|
- <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>
|
|
207
312
|
- <span class="package-name">[`@stdlib/blas-ext/base/sdsnansum`][@stdlib/blas/ext/base/sdsnansum]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements, ignoring NaN values and using extended accumulation.</span>
|
|
208
313
|
- <span class="package-name">[`@stdlib/blas-ext/base/snansum`][@stdlib/blas/ext/base/snansum]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements, ignoring NaN values.</span>
|
|
@@ -237,7 +342,7 @@ See [LICENSE][stdlib-license].
|
|
|
237
342
|
|
|
238
343
|
## Copyright
|
|
239
344
|
|
|
240
|
-
Copyright © 2016-
|
|
345
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
241
346
|
|
|
242
347
|
</section>
|
|
243
348
|
|
|
@@ -250,8 +355,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
250
355
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsnansum.svg
|
|
251
356
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsnansum
|
|
252
357
|
|
|
253
|
-
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
254
|
-
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml?query=branch:v0.
|
|
358
|
+
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
359
|
+
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml?query=branch:v0.3.0
|
|
255
360
|
|
|
256
361
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsnansum/main.svg
|
|
257
362
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsnansum?branch=main
|
|
@@ -263,8 +368,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
263
368
|
|
|
264
369
|
-->
|
|
265
370
|
|
|
266
|
-
[chat-image]: https://img.shields.io/
|
|
267
|
-
[chat-url]: https://
|
|
371
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
372
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
268
373
|
|
|
269
374
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
270
375
|
|
|
@@ -289,7 +394,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
289
394
|
|
|
290
395
|
<!-- <related-links> -->
|
|
291
396
|
|
|
292
|
-
[@stdlib/stats/
|
|
397
|
+
[@stdlib/stats/strided/dsnanmean]: https://www.npmjs.com/package/@stdlib/stats-strided-dsnanmean
|
|
293
398
|
|
|
294
399
|
[@stdlib/blas/ext/base/dssum]: https://www.npmjs.com/package/@stdlib/blas-ext-base-dssum
|
|
295
400
|
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
var
|
|
3
|
-
});var v=
|
|
4
|
-
var
|
|
5
|
-
});var
|
|
6
|
-
var
|
|
7
|
-
});var
|
|
1
|
+
"use strict";var s=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var n=s(function(g,u){
|
|
2
|
+
var p=require('@stdlib/blas-ext-base-dsnansumpw/dist').ndarray;function y(e,r,a,c){return p(e,r,a,c)}u.exports=y
|
|
3
|
+
});var v=s(function(h,t){
|
|
4
|
+
var f=require('@stdlib/strided-base-stride2offset/dist'),x=n();function j(e,r,a){return x(e,r,a,f(e,a))}t.exports=j
|
|
5
|
+
});var o=s(function(k,q){
|
|
6
|
+
var l=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),d=v(),R=n();l(d,"ndarray",R);q.exports=d
|
|
7
|
+
});var _=require("path").join,w=require('@stdlib/utils-try-require/dist'),E=require('@stdlib/assert-is-error/dist'),O=o(),i,m=w(_(__dirname,"./native.js"));E(m)?i=O:i=m;module.exports=i;
|
|
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/
|
|
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 dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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}
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../lib/ndarray.js", "../lib/dsnansum.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 dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' ).ndarray;\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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 = dsnansum( 5, x, 2, 1 );\n* // returns 5.0\n*/\nfunction dsnansum( N, x, strideX, offsetX ) {\n\treturn dsnansumpw( N, x, strideX, offsetX );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansum;\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 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 = dsnansum( x.length, x, 1 );\n* // returns 1.0\n*/\nfunction dsnansum( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansum;\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 dsnansum = require( './dsnansum.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsnansum, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsnansum;\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 extended accumulation, and returning an extended precision result.\n*\n* @module @stdlib/blas-ext-base-dsnansum\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n*\n* var v = dsnansum( x.length, x, 1 );\n* // returns 1.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );\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 = dsnansum.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 dsnansum;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsnansum = main;\n} else {\n\tdsnansum = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansum;\n\n// exports: { \"ndarray\": \"dsnansum.ndarray\" }\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,EAAE,QAsB/D,SAASC,EAAUC,EAAGC,EAAGC,EAASC,EAAU,CAC3C,OAAOL,EAAYE,EAAGC,EAAGC,EAASC,CAAQ,CAC3C,CAKAN,EAAO,QAAUE,ICnDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAqBd,SAASC,EAAUC,EAAGC,EAAGC,EAAU,CAClC,OAAOJ,EAASE,EAAGC,EAAGC,EAASL,EAAeG,EAAGE,CAAO,CAAE,CAC3D,CAKAN,EAAO,QAAUG,ICnDjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,IACXC,EAAU,IAKdF,EAAaC,EAAU,UAAWC,CAAQ,EAK1CH,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,EAAWD,EAEXC,EAAWC,EAMZ,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_ndarray", "__commonJSMin", "exports", "module", "dsnansumpw", "dsnansum", "N", "x", "strideX", "offsetX", "require_dsnansum", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "dsnansum", "N", "x", "strideX", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsnansum", "ndarray", "join", "tryRequire", "isError", "main", "dsnansum", "tmp"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ interface Routine {
|
|
|
27
27
|
*
|
|
28
28
|
* @param N - number of indexed elements
|
|
29
29
|
* @param x - input array
|
|
30
|
-
* @param
|
|
30
|
+
* @param strideX - stride length
|
|
31
31
|
* @returns sum
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
@@ -38,15 +38,15 @@ interface Routine {
|
|
|
38
38
|
* var v = dsnansum( x.length, x, 1 );
|
|
39
39
|
* // returns 1.0
|
|
40
40
|
*/
|
|
41
|
-
( N: number, x: Float32Array,
|
|
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
|
|
44
|
+
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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
|
|
49
|
-
* @param
|
|
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 = dsnansum.ndarray( x.length, x, 1, 0 );
|
|
58
58
|
* // returns 1.0
|
|
59
59
|
*/
|
|
60
|
-
ndarray( N: number, x: Float32Array,
|
|
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
|
|
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_DSNANSUM_H
|
|
23
20
|
#define STDLIB_BLAS_EXT_BASE_DSNANSUM_H
|
|
24
21
|
|
|
25
|
-
#include
|
|
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.
|
|
@@ -32,9 +29,14 @@ extern "C" {
|
|
|
32
29
|
#endif
|
|
33
30
|
|
|
34
31
|
/**
|
|
35
|
-
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using extended
|
|
32
|
+
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using extended accumulation, and returning an extended precision result.
|
|
33
|
+
*/
|
|
34
|
+
double API_SUFFIX(stdlib_strided_dsnansum)( 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, using extended accumulation and alternative indexing semantics, and returning an extended precision result.
|
|
36
38
|
*/
|
|
37
|
-
double
|
|
39
|
+
double API_SUFFIX(stdlib_strided_dsnansum_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
|
|
38
40
|
|
|
39
41
|
#ifdef __cplusplus
|
|
40
42
|
}
|
package/lib/dsnansum.js
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var stride2offset = require( '@stdlib/strided-base-stride2offset' );
|
|
24
|
+
var ndarray = require( './ndarray.js' );
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
// MAIN //
|
|
@@ -30,20 +31,19 @@ var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );
|
|
|
30
31
|
*
|
|
31
32
|
* @param {PositiveInteger} N - number of indexed elements
|
|
32
33
|
* @param {Float32Array} x - input array
|
|
33
|
-
* @param {integer}
|
|
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
|
-
|
|
41
|
-
*
|
|
42
|
-
* var v = dsnansum( N, x, 1 );
|
|
41
|
+
|
|
42
|
+
* var v = dsnansum( x.length, x, 1 );
|
|
43
43
|
* // returns 1.0
|
|
44
44
|
*/
|
|
45
|
-
function dsnansum( N, x,
|
|
46
|
-
return
|
|
45
|
+
function dsnansum( N, x, strideX ) {
|
|
46
|
+
return ndarray( N, x, strideX, stride2offset( N, strideX) );
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
|
package/lib/dsnansum.native.js
CHANGED
|
@@ -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}
|
|
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
|
-
|
|
41
|
-
*
|
|
42
|
-
* var v = dsnansum( N, x, 1 );
|
|
40
|
+
|
|
41
|
+
* var v = dsnansum( x.length, x, 1 );
|
|
43
42
|
* // returns 1.0
|
|
44
43
|
*/
|
|
45
|
-
function dsnansum( N, x,
|
|
46
|
-
return addon( N, x,
|
|
44
|
+
function dsnansum( N, x, strideX ) {
|
|
45
|
+
return addon( N, x, strideX );
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
|
package/lib/index.js
CHANGED
|
@@ -28,20 +28,17 @@
|
|
|
28
28
|
* var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );
|
|
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 = dsnansum(
|
|
32
|
+
* var v = dsnansum( x.length, x, 1 );
|
|
34
33
|
* // returns 1.0
|
|
35
34
|
*
|
|
36
35
|
* @example
|
|
37
36
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
38
|
-
* var floor = require( '@stdlib/math-base-special-floor' );
|
|
39
37
|
* var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );
|
|
40
38
|
*
|
|
41
39
|
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
|
|
42
|
-
* var N = floor( x.length / 2 );
|
|
43
40
|
*
|
|
44
|
-
* var v = dsnansum.ndarray(
|
|
41
|
+
* var v = dsnansum.ndarray( 5, x, 2, 1 );
|
|
45
42
|
* // returns 5.0
|
|
46
43
|
*/
|
|
47
44
|
|
package/lib/ndarray.js
CHANGED
|
@@ -30,22 +30,20 @@ var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' ).ndarray;
|
|
|
30
30
|
*
|
|
31
31
|
* @param {PositiveInteger} N - number of indexed elements
|
|
32
32
|
* @param {Float32Array} x - input array
|
|
33
|
-
* @param {integer}
|
|
34
|
-
* @param {NonNegativeInteger}
|
|
33
|
+
* @param {integer} strideX - stride length
|
|
34
|
+
* @param {NonNegativeInteger} offsetX - starting index
|
|
35
35
|
* @returns {number} sum
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
39
|
-
* var floor = require( '@stdlib/math-base-special-floor' );
|
|
40
39
|
*
|
|
41
40
|
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
|
|
42
|
-
* var N = floor( x.length / 2 );
|
|
43
41
|
*
|
|
44
|
-
* var v = dsnansum(
|
|
42
|
+
* var v = dsnansum( 5, x, 2, 1 );
|
|
45
43
|
* // returns 5.0
|
|
46
44
|
*/
|
|
47
|
-
function dsnansum( N, x,
|
|
48
|
-
return dsnansumpw( N, x,
|
|
45
|
+
function dsnansum( N, x, strideX, offsetX ) {
|
|
46
|
+
return dsnansumpw( N, x, strideX, offsetX );
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
|
package/lib/ndarray.native.js
CHANGED
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
24
|
-
var addon = require( './dsnansum.native.js' );
|
|
23
|
+
var addon = require( './../src/addon.node' );
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
// MAIN //
|
|
@@ -31,27 +30,20 @@ var addon = require( './dsnansum.native.js' );
|
|
|
31
30
|
*
|
|
32
31
|
* @param {PositiveInteger} N - number of indexed elements
|
|
33
32
|
* @param {Float32Array} x - input array
|
|
34
|
-
* @param {integer}
|
|
35
|
-
* @param {NonNegativeInteger}
|
|
33
|
+
* @param {integer} strideX - stride length
|
|
34
|
+
* @param {NonNegativeInteger} offsetX - starting index
|
|
36
35
|
* @returns {number} sum
|
|
37
36
|
*
|
|
38
37
|
* @example
|
|
39
38
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
40
|
-
* var floor = require( '@stdlib/math-base-special-floor' );
|
|
41
39
|
*
|
|
42
40
|
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
|
|
43
|
-
* var N = floor( x.length / 2 );
|
|
44
41
|
*
|
|
45
|
-
* var v = dsnansum(
|
|
42
|
+
* var v = dsnansum( 5, x, 2, 1 );
|
|
46
43
|
* // returns 5.0
|
|
47
44
|
*/
|
|
48
|
-
function dsnansum( N, x,
|
|
49
|
-
|
|
50
|
-
if ( stride < 0 ) {
|
|
51
|
-
offset += (N-1) * stride;
|
|
52
|
-
}
|
|
53
|
-
view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len
|
|
54
|
-
return addon( N, view, stride );
|
|
45
|
+
function dsnansum( N, x, strideX, offsetX ) {
|
|
46
|
+
return addon.ndarray( N, x, strideX, offsetX );
|
|
55
47
|
}
|
|
56
48
|
|
|
57
49
|
|
package/manifest.json
CHANGED
|
@@ -1,42 +1,82 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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/blas-ext-base-dsnansumpw",
|
|
40
|
+
"@stdlib/napi-export",
|
|
41
|
+
"@stdlib/napi-argv",
|
|
42
|
+
"@stdlib/napi-argv-int64",
|
|
43
|
+
"@stdlib/napi-argv-strided-float32array",
|
|
44
|
+
"@stdlib/napi-create-double",
|
|
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/blas-ext-base-dsnansumpw",
|
|
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/blas-ext-base-dsnansumpw",
|
|
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-dsnansum",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Calculate the sum of single-precision floating-point strided array elements, ignoring NaN values, using extended accumulation, and returning an extended precision result.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -34,11 +34,18 @@
|
|
|
34
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@stdlib/assert-is-error": "^0.2.
|
|
38
|
-
"@stdlib/blas-
|
|
39
|
-
"@stdlib/
|
|
40
|
-
"@stdlib/
|
|
41
|
-
"@stdlib/
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.2",
|
|
38
|
+
"@stdlib/blas-base-shared": "^0.1.0",
|
|
39
|
+
"@stdlib/blas-ext-base-dsnansumpw": "^0.3.0",
|
|
40
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
41
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
42
|
+
"@stdlib/napi-argv-strided-float32array": "^0.2.2",
|
|
43
|
+
"@stdlib/napi-create-double": "^0.0.2",
|
|
44
|
+
"@stdlib/napi-export": "^0.3.0",
|
|
45
|
+
"@stdlib/strided-base-stride2offset": "^0.1.0",
|
|
46
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
47
|
+
"@stdlib/utils-library-manifest": "^0.2.3",
|
|
48
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {},
|
|
44
51
|
"engines": {
|
|
@@ -77,7 +84,6 @@
|
|
|
77
84
|
"float",
|
|
78
85
|
"float32array"
|
|
79
86
|
],
|
|
80
|
-
"__stdlib__": {},
|
|
81
87
|
"funding": {
|
|
82
88
|
"type": "opencollective",
|
|
83
89
|
"url": "https://opencollective.com/stdlib"
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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/dsnansum.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/create_double.h"
|
|
26
|
+
#include <node_api.h>
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Receives JavaScript callback invocation data.
|
|
30
|
+
*
|
|
31
|
+
* @param env environment under which the function is invoked
|
|
32
|
+
* @param info callback data
|
|
33
|
+
* @return Node-API value
|
|
34
|
+
*/
|
|
35
|
+
static napi_value addon( napi_env env, napi_callback_info info ) {
|
|
36
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 3 );
|
|
37
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
38
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
|
|
39
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
|
|
40
|
+
STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dsnansum)( N, X, strideX ), v );
|
|
41
|
+
return v;
|
|
42
|
+
}
|
|
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_dsnansum_ndarray)( N, X, strideX, offsetX ), v );
|
|
58
|
+
return v;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method );
|
package/src/main.c
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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/dsnansum.h"
|
|
20
|
+
#include "stdlib/blas/ext/base/dsnansumpw.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 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_dsnansum)( 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_dsnansum_ndarray)( N, X, strideX, ox );
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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_dsnansum_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
|
|
47
|
+
return API_SUFFIX(stdlib_strided_dsnansumpw_ndarray)( N, X, strideX, offsetX );
|
|
48
|
+
}
|
package/include.gypi
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# @license Apache-2.0
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2020 The Stdlib Authors.
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
# A GYP include file for building a Node.js native add-on.
|
|
18
|
-
#
|
|
19
|
-
# Main documentation:
|
|
20
|
-
#
|
|
21
|
-
# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
|
|
22
|
-
# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
|
|
23
|
-
{
|
|
24
|
-
# Define variables to be used throughout the configuration for all targets:
|
|
25
|
-
'variables': {
|
|
26
|
-
# Source directory:
|
|
27
|
-
'src_dir': './src',
|
|
28
|
-
|
|
29
|
-
# Include directories:
|
|
30
|
-
'include_dirs': [
|
|
31
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
32
|
-
],
|
|
33
|
-
|
|
34
|
-
# Add-on destination directory:
|
|
35
|
-
'addon_output_dir': './src',
|
|
36
|
-
|
|
37
|
-
# Source files:
|
|
38
|
-
'src_files': [
|
|
39
|
-
'<(src_dir)/addon.cpp',
|
|
40
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
# Library dependencies:
|
|
44
|
-
'libraries': [
|
|
45
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
46
|
-
],
|
|
47
|
-
|
|
48
|
-
# Library directories:
|
|
49
|
-
'library_dirs': [
|
|
50
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
51
|
-
],
|
|
52
|
-
}, # end variables
|
|
53
|
-
}
|
package/src/addon.cpp
DELETED
|
@@ -1,117 +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/dsnansum.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_dsnansum {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using extended accumulation, and returning an extended precision result.
|
|
33
|
-
*
|
|
34
|
-
* ## Notes
|
|
35
|
-
*
|
|
36
|
-
* - When called from JavaScript, the function expects three arguments:
|
|
37
|
-
*
|
|
38
|
-
* - `N`: number of indexed elements
|
|
39
|
-
* - `X`: input array
|
|
40
|
-
* - `stride`: stride length
|
|
41
|
-
*/
|
|
42
|
-
napi_value node_dsnansum( napi_env env, napi_callback_info info ) {
|
|
43
|
-
napi_status status;
|
|
44
|
-
|
|
45
|
-
size_t argc = 3;
|
|
46
|
-
napi_value argv[ 3 ];
|
|
47
|
-
status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
|
|
48
|
-
assert( status == napi_ok );
|
|
49
|
-
|
|
50
|
-
if ( argc < 3 ) {
|
|
51
|
-
napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." );
|
|
52
|
-
return nullptr;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
napi_valuetype vtype0;
|
|
56
|
-
status = napi_typeof( env, argv[ 0 ], &vtype0 );
|
|
57
|
-
assert( status == napi_ok );
|
|
58
|
-
if ( vtype0 != napi_number ) {
|
|
59
|
-
napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
|
|
60
|
-
return nullptr;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
bool res;
|
|
64
|
-
status = napi_is_typedarray( env, argv[ 1 ], &res );
|
|
65
|
-
assert( status == napi_ok );
|
|
66
|
-
if ( res == false ) {
|
|
67
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
|
|
68
|
-
return nullptr;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
napi_valuetype vtype2;
|
|
72
|
-
status = napi_typeof( env, argv[ 2 ], &vtype2 );
|
|
73
|
-
assert( status == napi_ok );
|
|
74
|
-
if ( vtype2 != napi_number ) {
|
|
75
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." );
|
|
76
|
-
return nullptr;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
int64_t N;
|
|
80
|
-
status = napi_get_value_int64( env, argv[ 0 ], &N );
|
|
81
|
-
assert( status == napi_ok );
|
|
82
|
-
|
|
83
|
-
int64_t stride;
|
|
84
|
-
status = napi_get_value_int64( env, argv[ 2 ], &stride );
|
|
85
|
-
assert( status == napi_ok );
|
|
86
|
-
|
|
87
|
-
napi_typedarray_type vtype1;
|
|
88
|
-
size_t xlen;
|
|
89
|
-
void *X;
|
|
90
|
-
status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr );
|
|
91
|
-
assert( status == napi_ok );
|
|
92
|
-
if ( vtype1 != napi_float32_array ) {
|
|
93
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
|
|
94
|
-
return nullptr;
|
|
95
|
-
}
|
|
96
|
-
if ( (N-1)*llabs(stride) >= (int64_t)xlen ) {
|
|
97
|
-
napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." );
|
|
98
|
-
return nullptr;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
napi_value v;
|
|
102
|
-
status = napi_create_double( env, stdlib_strided_dsnansum( N, (float *)X, stride ), &v );
|
|
103
|
-
assert( status == napi_ok );
|
|
104
|
-
|
|
105
|
-
return v;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
napi_value Init( napi_env env, napi_value exports ) {
|
|
109
|
-
napi_status status;
|
|
110
|
-
napi_value fcn;
|
|
111
|
-
status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dsnansum, NULL, &fcn );
|
|
112
|
-
assert( status == napi_ok );
|
|
113
|
-
return fcn;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
|
|
117
|
-
} // end namespace stdlib_blas_ext_base_dsnansum
|
package/src/dsnansum.c
DELETED
|
@@ -1,33 +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/dsnansum.h"
|
|
20
|
-
#include "stdlib/blas/ext/base/dsnansumpw.h"
|
|
21
|
-
#include <stdint.h>
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using 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_dsnansum( const int64_t N, const float *X, const int64_t stride ) {
|
|
32
|
-
return stdlib_strided_dsnansumpw( N, X, stride );
|
|
33
|
-
}
|