@stdlib/blas-ext-base-dsnansum 0.2.0 → 0.2.2
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/README.md +16 -27
- package/dist/index.js.map +2 -2
- package/lib/index.js +1 -3
- package/lib/ndarray.js +1 -3
- package/lib/ndarray.native.js +5 -8
- package/manifest.json +79 -40
- package/package.json +13 -30
- package/src/addon.c +45 -0
- package/include.gypi +0 -53
- package/src/addon.cpp +0 -117
package/README.md
CHANGED
|
@@ -79,16 +79,14 @@ The function has the following parameters:
|
|
|
79
79
|
- **x**: input [`Float32Array`][@stdlib/array/float32].
|
|
80
80
|
- **stride**: index increment for `x`.
|
|
81
81
|
|
|
82
|
-
The `N` and
|
|
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`,
|
|
83
83
|
|
|
84
84
|
```javascript
|
|
85
85
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
86
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
87
86
|
|
|
88
87
|
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
88
|
|
|
91
|
-
var v = dsnansum(
|
|
89
|
+
var v = dsnansum( 4, x, 2 );
|
|
92
90
|
// returns 5.0
|
|
93
91
|
```
|
|
94
92
|
|
|
@@ -98,14 +96,11 @@ Note that indexing is relative to the first index. To introduce an offset, use [
|
|
|
98
96
|
|
|
99
97
|
```javascript
|
|
100
98
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
101
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
102
99
|
|
|
103
100
|
var x0 = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
104
101
|
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
|
|
105
102
|
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
var v = dsnansum( N, x1, 2 );
|
|
103
|
+
var v = dsnansum( 4, x1, 2 );
|
|
109
104
|
// returns 5.0
|
|
110
105
|
```
|
|
111
106
|
|
|
@@ -117,9 +112,8 @@ Computes the sum of single-precision floating-point strided array elements, igno
|
|
|
117
112
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
118
113
|
|
|
119
114
|
var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
|
|
120
|
-
var N = x.length;
|
|
121
115
|
|
|
122
|
-
var v = dsnansum.ndarray(
|
|
116
|
+
var v = dsnansum.ndarray( 4, x, 1, 0 );
|
|
123
117
|
// returns 1.0
|
|
124
118
|
```
|
|
125
119
|
|
|
@@ -131,12 +125,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
|
|
|
131
125
|
|
|
132
126
|
```javascript
|
|
133
127
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
134
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
135
128
|
|
|
136
129
|
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
130
|
|
|
139
|
-
var v = dsnansum.ndarray(
|
|
131
|
+
var v = dsnansum.ndarray( 4, x, 2, 1 );
|
|
140
132
|
// returns 5.0
|
|
141
133
|
```
|
|
142
134
|
|
|
@@ -162,22 +154,19 @@ var v = dsnansum.ndarray( N, x, 2, 1 );
|
|
|
162
154
|
<!-- eslint no-undef: "error" -->
|
|
163
155
|
|
|
164
156
|
```javascript
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
var
|
|
157
|
+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
|
|
158
|
+
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
|
|
159
|
+
var filledarrayBy = require( '@stdlib/array-filled-by' );
|
|
168
160
|
var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );
|
|
169
161
|
|
|
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 );
|
|
162
|
+
function clbk() {
|
|
163
|
+
if ( bernoulli( 0.7 ) > 0 ) {
|
|
164
|
+
return discreteUniform( -10, 10 );
|
|
179
165
|
}
|
|
166
|
+
return NaN;
|
|
180
167
|
}
|
|
168
|
+
|
|
169
|
+
var x = filledarrayBy( 10, 'float64', clbk );
|
|
181
170
|
console.log( x );
|
|
182
171
|
|
|
183
172
|
var v = dsnansum( x.length, x, 1 );
|
|
@@ -250,8 +239,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
250
239
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsnansum.svg
|
|
251
240
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsnansum
|
|
252
241
|
|
|
253
|
-
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
254
|
-
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml?query=branch:v0.2.
|
|
242
|
+
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml/badge.svg?branch=v0.2.2
|
|
243
|
+
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansum/actions/workflows/test.yml?query=branch:v0.2.2
|
|
255
244
|
|
|
256
245
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsnansum/main.svg
|
|
257
246
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsnansum?branch=main
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/dsnansum.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 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} 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 = dsnansum( N, x, 1 );\n* // returns 1.0\n*/\nfunction dsnansum( N, x, stride ) {\n\treturn dsnansumpw( N, x, stride );\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 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} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @returns {number} sum\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,EAsB7D,SAASC,EAAUC,EAAGC,EAAGC,EAAS,CACjC,OAAOJ,EAAYE,EAAGC,EAAGC,CAAO,CACjC,CAKAL,EAAO,QAAUE,ICnDjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,EAAE,
|
|
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} 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 = dsnansum( N, x, 1 );\n* // returns 1.0\n*/\nfunction dsnansum( N, x, stride ) {\n\treturn dsnansumpw( N, x, stride );\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 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} 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 = dsnansum( 5, x, 2, 1 );\n* // returns 5.0\n*/\nfunction dsnansum( N, x, stride, offset ) {\n\treturn dsnansumpw( N, x, stride, offset );\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* var N = x.length;\n*\n* var v = dsnansum( N, 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,EAsB7D,SAASC,EAAUC,EAAGC,EAAGC,EAAS,CACjC,OAAOJ,EAAYE,EAAGC,EAAGC,CAAO,CACjC,CAKAL,EAAO,QAAUE,ICnDjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,EAAE,QAsB/D,SAASC,EAAUC,EAAGC,EAAGC,EAAQC,EAAS,CACzC,OAAOL,EAAYE,EAAGC,EAAGC,EAAQC,CAAO,CACzC,CAKAN,EAAO,QAAUE,ICnDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,IACXC,EAAU,IAKdF,EAAaC,EAAU,UAAWC,CAAQ,EAK1CH,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,EAAWD,EAEXC,EAAWC,EAMZ,OAAO,QAAUD",
|
|
6
6
|
"names": ["require_dsnansum", "__commonJSMin", "exports", "module", "dsnansumpw", "dsnansum", "N", "x", "stride", "require_ndarray", "__commonJSMin", "exports", "module", "dsnansumpw", "dsnansum", "N", "x", "stride", "offset", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsnansum", "ndarray", "join", "tryRequire", "isError", "main", "dsnansum", "tmp"]
|
|
7
7
|
}
|
package/lib/index.js
CHANGED
|
@@ -35,13 +35,11 @@
|
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
38
|
-
* var floor = require( '@stdlib/math-base-special-floor' );
|
|
39
38
|
* var dsnansum = require( '@stdlib/blas-ext-base-dsnansum' );
|
|
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.ndarray(
|
|
42
|
+
* var v = dsnansum.ndarray( 5, x, 2, 1 );
|
|
45
43
|
* // returns 5.0
|
|
46
44
|
*/
|
|
47
45
|
|
package/lib/ndarray.js
CHANGED
|
@@ -36,12 +36,10 @@ var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' ).ndarray;
|
|
|
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
45
|
function dsnansum( N, x, stride, offset ) {
|
package/lib/ndarray.native.js
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var minViewBufferIndex = require( '@stdlib/strided-base-min-view-buffer-index' );
|
|
24
|
+
var offsetView = require( '@stdlib/strided-base-offset-view' );
|
|
24
25
|
var addon = require( './dsnansum.native.js' );
|
|
25
26
|
|
|
26
27
|
|
|
@@ -37,20 +38,16 @@ var addon = require( './dsnansum.native.js' );
|
|
|
37
38
|
*
|
|
38
39
|
* @example
|
|
39
40
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
40
|
-
* var floor = require( '@stdlib/math-base-special-floor' );
|
|
41
41
|
*
|
|
42
42
|
* 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
43
|
*
|
|
45
|
-
* var v = dsnansum(
|
|
44
|
+
* var v = dsnansum( 5, x, 2, 1 );
|
|
46
45
|
* // returns 5.0
|
|
47
46
|
*/
|
|
48
47
|
function dsnansum( N, x, stride, offset ) {
|
|
49
48
|
var view;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len
|
|
49
|
+
offset = minViewBufferIndex( N, stride, offset );
|
|
50
|
+
view = offsetView( x, offset );
|
|
54
51
|
return addon( N, view, stride );
|
|
55
52
|
}
|
|
56
53
|
|
package/manifest.json
CHANGED
|
@@ -1,42 +1,81 @@
|
|
|
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/dsnansum.c"
|
|
32
|
+
],
|
|
33
|
+
"include": [
|
|
34
|
+
"./include"
|
|
35
|
+
],
|
|
36
|
+
"libraries": [
|
|
37
|
+
"-lm"
|
|
38
|
+
],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/blas-ext-base-dsnansumpw",
|
|
42
|
+
"@stdlib/napi-export",
|
|
43
|
+
"@stdlib/napi-argv",
|
|
44
|
+
"@stdlib/napi-argv-int64",
|
|
45
|
+
"@stdlib/napi-argv-strided-float32array"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"task": "benchmark",
|
|
50
|
+
"src": [
|
|
51
|
+
"./src/dsnansum.c"
|
|
52
|
+
],
|
|
53
|
+
"include": [
|
|
54
|
+
"./include"
|
|
55
|
+
],
|
|
56
|
+
"libraries": [
|
|
57
|
+
"-lm"
|
|
58
|
+
],
|
|
59
|
+
"libpath": [],
|
|
60
|
+
"dependencies": [
|
|
61
|
+
"@stdlib/blas-ext-base-dsnansumpw"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"task": "examples",
|
|
66
|
+
"src": [
|
|
67
|
+
"./src/dsnansum.c"
|
|
68
|
+
],
|
|
69
|
+
"include": [
|
|
70
|
+
"./include"
|
|
71
|
+
],
|
|
72
|
+
"libraries": [
|
|
73
|
+
"-lm"
|
|
74
|
+
],
|
|
75
|
+
"libpath": [],
|
|
76
|
+
"dependencies": [
|
|
77
|
+
"@stdlib/blas-ext-base-dsnansumpw"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
42
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/blas-ext-base-dsnansum",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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": {
|
|
@@ -17,21 +17,14 @@
|
|
|
17
17
|
"browser": "./lib/main.js",
|
|
18
18
|
"gypfile": false,
|
|
19
19
|
"directories": {
|
|
20
|
-
"benchmark": "./benchmark",
|
|
21
20
|
"doc": "./docs",
|
|
22
|
-
"example": "./examples",
|
|
23
21
|
"include": "./include",
|
|
24
22
|
"lib": "./lib",
|
|
25
23
|
"src": "./src",
|
|
26
|
-
"
|
|
24
|
+
"dist": "./dist"
|
|
27
25
|
},
|
|
28
26
|
"types": "./docs/types",
|
|
29
|
-
"scripts": {
|
|
30
|
-
"test": "make test",
|
|
31
|
-
"test-cov": "make test-cov",
|
|
32
|
-
"examples": "make examples",
|
|
33
|
-
"benchmark": "make benchmark"
|
|
34
|
-
},
|
|
27
|
+
"scripts": {},
|
|
35
28
|
"homepage": "https://stdlib.io",
|
|
36
29
|
"repository": {
|
|
37
30
|
"type": "git",
|
|
@@ -41,27 +34,17 @@
|
|
|
41
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
42
35
|
},
|
|
43
36
|
"dependencies": {
|
|
44
|
-
"@stdlib/assert-is-error": "^0.2.
|
|
45
|
-
"@stdlib/blas-ext-base-dsnansumpw": "^0.2.
|
|
46
|
-
"@stdlib/
|
|
47
|
-
"@stdlib/
|
|
48
|
-
"@stdlib/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"@stdlib/
|
|
52
|
-
"@stdlib/
|
|
53
|
-
"@stdlib/math-base-assert-is-nan": "^0.1.1",
|
|
54
|
-
"@stdlib/math-base-special-floor": "^0.1.1",
|
|
55
|
-
"@stdlib/math-base-special-pow": "^0.1.0",
|
|
56
|
-
"@stdlib/math-base-special-round": "^0.1.1",
|
|
57
|
-
"@stdlib/random-base-randu": "^0.1.0",
|
|
58
|
-
"proxyquire": "^2.0.0",
|
|
59
|
-
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
60
|
-
"istanbul": "^0.4.1",
|
|
61
|
-
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
62
|
-
"@stdlib/bench-harness": "^0.2.0",
|
|
63
|
-
"@stdlib/bench": "^0.3.1"
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.2",
|
|
38
|
+
"@stdlib/blas-ext-base-dsnansumpw": "^0.2.1",
|
|
39
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
40
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
41
|
+
"@stdlib/napi-argv-strided-float32array": "^0.2.2",
|
|
42
|
+
"@stdlib/napi-export": "^0.2.2",
|
|
43
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
44
|
+
"@stdlib/utils-library-manifest": "^0.2.2",
|
|
45
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
64
46
|
},
|
|
47
|
+
"devDependencies": {},
|
|
65
48
|
"engines": {
|
|
66
49
|
"node": ">=0.10.0",
|
|
67
50
|
"npm": ">2.7.0"
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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/napi/export.h"
|
|
21
|
+
#include "stdlib/napi/argv.h"
|
|
22
|
+
#include "stdlib/napi/argv_int64.h"
|
|
23
|
+
#include "stdlib/napi/argv_strided_float32array.h"
|
|
24
|
+
#include <node_api.h>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Receives JavaScript callback invocation data.
|
|
28
|
+
*
|
|
29
|
+
* @param env environment under which the function is invoked
|
|
30
|
+
* @param info callback data
|
|
31
|
+
* @return Node-API value
|
|
32
|
+
*/
|
|
33
|
+
static napi_value addon( napi_env env, napi_callback_info info ) {
|
|
34
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 3 );
|
|
35
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
36
|
+
STDLIB_NAPI_ARGV_INT64( env, stride, argv, 2 );
|
|
37
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 );
|
|
38
|
+
|
|
39
|
+
napi_value v;
|
|
40
|
+
napi_status status = napi_create_double( env, stdlib_strided_dsnansum( N, X, stride ), &v );
|
|
41
|
+
assert( status == napi_ok );
|
|
42
|
+
return v;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
|
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
|