@stdlib/blas-ext-base-dsapxsum 0.2.1 → 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 +12 -28
- package/dist/index.js.map +2 -2
- package/lib/dsapxsum.js +1 -2
- package/lib/dsapxsum.native.js +1 -2
- package/lib/index.js +2 -5
- package/lib/ndarray.js +1 -3
- package/lib/ndarray.native.js +6 -8
- package/manifest.json +80 -40
- package/package.json +13 -6
- package/src/addon.c +48 -0
- package/include.gypi +0 -53
- package/src/addon.cpp +0 -130
package/README.md
CHANGED
|
@@ -67,9 +67,8 @@ Adds a constant to each single-precision floating-point strided array element an
|
|
|
67
67
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
68
68
|
|
|
69
69
|
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
70
|
-
var N = x.length;
|
|
71
70
|
|
|
72
|
-
var v = dsapxsum(
|
|
71
|
+
var v = dsapxsum( 3, 5.0, x, 1 );
|
|
73
72
|
// returns 16.0
|
|
74
73
|
```
|
|
75
74
|
|
|
@@ -79,16 +78,14 @@ The function has the following parameters:
|
|
|
79
78
|
- **x**: input [`Float32Array`][@stdlib/array/float32].
|
|
80
79
|
- **stride**: index increment for `x`.
|
|
81
80
|
|
|
82
|
-
The `N` and `stride` parameters determine which elements in
|
|
81
|
+
The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element in the strided array,
|
|
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, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
|
|
89
|
-
var N = floor( x.length / 2 );
|
|
90
87
|
|
|
91
|
-
var v = dsapxsum(
|
|
88
|
+
var v = dsapxsum( 4, 5.0, x, 2 );
|
|
92
89
|
// returns 25.0
|
|
93
90
|
```
|
|
94
91
|
|
|
@@ -98,14 +95,11 @@ 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, 2.0, -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 = dsapxsum( N, 5.0, x1, 2 );
|
|
102
|
+
var v = dsapxsum( 4, 5.0, x1, 2 );
|
|
109
103
|
// returns 25.0
|
|
110
104
|
```
|
|
111
105
|
|
|
@@ -117,9 +111,8 @@ Adds a constant to each single-precision floating-point strided array element an
|
|
|
117
111
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
118
112
|
|
|
119
113
|
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
120
|
-
var N = x.length;
|
|
121
114
|
|
|
122
|
-
var v = dsapxsum.ndarray(
|
|
115
|
+
var v = dsapxsum.ndarray( 3, 5.0, x, 1, 0 );
|
|
123
116
|
// returns 16.0
|
|
124
117
|
```
|
|
125
118
|
|
|
@@ -127,16 +120,14 @@ The function has the following additional parameters:
|
|
|
127
120
|
|
|
128
121
|
- **offset**: starting index for `x`.
|
|
129
122
|
|
|
130
|
-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the
|
|
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 access every other value in the strided array starting from the second value
|
|
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, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
137
|
-
var N = floor( x.length / 2 );
|
|
138
129
|
|
|
139
|
-
var v = dsapxsum.ndarray(
|
|
130
|
+
var v = dsapxsum.ndarray( 4, 5.0, x, 2, 1 );
|
|
140
131
|
// returns 25.0
|
|
141
132
|
```
|
|
142
133
|
|
|
@@ -162,18 +153,11 @@ var v = dsapxsum.ndarray( N, 5.0, x, 2, 1 );
|
|
|
162
153
|
<!-- eslint no-undef: "error" -->
|
|
163
154
|
|
|
164
155
|
```javascript
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
var Float32Array = require( '@stdlib/array-float32' );
|
|
156
|
+
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
|
|
157
|
+
var filledarrayBy = require( '@stdlib/array-filled-by' );
|
|
168
158
|
var dsapxsum = require( '@stdlib/blas-ext-base-dsapxsum' );
|
|
169
159
|
|
|
170
|
-
var x;
|
|
171
|
-
var i;
|
|
172
|
-
|
|
173
|
-
x = new Float32Array( 10 );
|
|
174
|
-
for ( i = 0; i < x.length; i++ ) {
|
|
175
|
-
x[ i ] = round( randu()*100.0 );
|
|
176
|
-
}
|
|
160
|
+
var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
|
|
177
161
|
console.log( x );
|
|
178
162
|
|
|
179
163
|
var v = dsapxsum( x.length, 5.0, x, 1 );
|
|
@@ -245,8 +229,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
245
229
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsapxsum.svg
|
|
246
230
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsapxsum
|
|
247
231
|
|
|
248
|
-
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsapxsum/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
249
|
-
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsapxsum/actions/workflows/test.yml?query=branch:v0.2.
|
|
232
|
+
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsapxsum/actions/workflows/test.yml/badge.svg?branch=v0.2.2
|
|
233
|
+
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsapxsum/actions/workflows/test.yml?query=branch:v0.2.2
|
|
250
234
|
|
|
251
235
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsapxsum/main.svg
|
|
252
236
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsapxsum?branch=main
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/dsapxsum.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 dsapxsumpw = require( '@stdlib/blas-ext-base-dsapxsumpw' );\n\n\n// MAIN //\n\n/**\n* Adds a constant to each single-precision floating-point strided array element and computes the sum using extended accumulation and returning an extended precision result.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} alpha - constant\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, 2.0 ] );\n
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,
|
|
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 dsapxsumpw = require( '@stdlib/blas-ext-base-dsapxsumpw' );\n\n\n// MAIN //\n\n/**\n* Adds a constant to each single-precision floating-point strided array element and computes the sum using extended accumulation and returning an extended precision result.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} alpha - constant\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, 2.0 ] );\n*\n* var v = dsapxsum( 3, 5.0, x, 1 );\n* // returns 16.0\n*/\nfunction dsapxsum( N, alpha, x, stride ) {\n\treturn dsapxsumpw( N, alpha, x, stride );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsapxsum;\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 dsapxsumpw = require( '@stdlib/blas-ext-base-dsapxsumpw' ).ndarray;\n\n\n// MAIN //\n\n/**\n* Adds a constant to each single-precision floating-point strided array element and computes the sum using extended accumulation and returning an extended precision result.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} alpha - constant\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 ] );\n*\n* var v = dsapxsum( 4, 5.0, x, 2, 1 );\n* // returns 25.0\n*/\nfunction dsapxsum( N, alpha, x, stride, offset ) {\n\treturn dsapxsumpw( N, alpha, x, stride, offset );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsapxsum;\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 dsapxsum = require( './dsapxsum.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsapxsum, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsapxsum;\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* Add a constant to each single-precision floating-point strided array element and compute the sum using extended accumulation and returning an extended precision result.\n*\n* @module @stdlib/blas-ext-base-dsapxsum\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsapxsum = require( '@stdlib/blas-ext-base-dsapxsum' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );\n*\n* var v = dsapxsum( 3, 5.0, x, 1 );\n* // returns 16.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsapxsum = require( '@stdlib/blas-ext-base-dsapxsum' );\n*\n* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );\n*\n* var v = dsapxsum.ndarray( 4, 5.0, x, 2, 1 );\n* // returns 25.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 dsapxsum;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsapxsum = main;\n} else {\n\tdsapxsum = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsapxsum;\n\n// exports: { \"ndarray\": \"dsapxsum.ndarray\" }\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,EAsB7D,SAASC,EAAUC,EAAGC,EAAOC,EAAGC,EAAS,CACxC,OAAOL,EAAYE,EAAGC,EAAOC,EAAGC,CAAO,CACxC,CAKAN,EAAO,QAAUE,ICnDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,kCAAmC,EAAE,QAuB/D,SAASC,EAAUC,EAAGC,EAAOC,EAAGC,EAAQC,EAAS,CAChD,OAAON,EAAYE,EAAGC,EAAOC,EAAGC,EAAQC,CAAO,CAChD,CAKAP,EAAO,QAAUE,ICpDjB,IAAAM,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
6
|
"names": ["require_dsapxsum", "__commonJSMin", "exports", "module", "dsapxsumpw", "dsapxsum", "N", "alpha", "x", "stride", "require_ndarray", "__commonJSMin", "exports", "module", "dsapxsumpw", "dsapxsum", "N", "alpha", "x", "stride", "offset", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsapxsum", "ndarray", "join", "tryRequire", "isError", "main", "dsapxsum", "tmp"]
|
|
7
7
|
}
|
package/lib/dsapxsum.js
CHANGED
|
@@ -38,9 +38,8 @@ var dsapxsumpw = require( '@stdlib/blas-ext-base-dsapxsumpw' );
|
|
|
38
38
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
39
39
|
*
|
|
40
40
|
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
41
|
-
* var N = x.length;
|
|
42
41
|
*
|
|
43
|
-
* var v = dsapxsum(
|
|
42
|
+
* var v = dsapxsum( 3, 5.0, x, 1 );
|
|
44
43
|
* // returns 16.0
|
|
45
44
|
*/
|
|
46
45
|
function dsapxsum( N, alpha, x, stride ) {
|
package/lib/dsapxsum.native.js
CHANGED
|
@@ -38,9 +38,8 @@ var addon = require( './../src/addon.node' );
|
|
|
38
38
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
39
39
|
*
|
|
40
40
|
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
41
|
-
* var N = x.length;
|
|
42
41
|
*
|
|
43
|
-
* var v = dsapxsum(
|
|
42
|
+
* var v = dsapxsum( 3, 5.0, x, 1 );
|
|
44
43
|
* // returns 16.0
|
|
45
44
|
*/
|
|
46
45
|
function dsapxsum( N, alpha, x, stride ) {
|
package/lib/index.js
CHANGED
|
@@ -28,20 +28,17 @@
|
|
|
28
28
|
* var dsapxsum = require( '@stdlib/blas-ext-base-dsapxsum' );
|
|
29
29
|
*
|
|
30
30
|
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
31
|
-
* var N = x.length;
|
|
32
31
|
*
|
|
33
|
-
* var v = dsapxsum(
|
|
32
|
+
* var v = dsapxsum( 3, 5.0, x, 1 );
|
|
34
33
|
* // returns 16.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 dsapxsum = require( '@stdlib/blas-ext-base-dsapxsum' );
|
|
40
38
|
*
|
|
41
39
|
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
42
|
-
* var N = floor( x.length / 2 );
|
|
43
40
|
*
|
|
44
|
-
* var v = dsapxsum.ndarray(
|
|
41
|
+
* var v = dsapxsum.ndarray( 4, 5.0, x, 2, 1 );
|
|
45
42
|
* // returns 25.0
|
|
46
43
|
*/
|
|
47
44
|
|
package/lib/ndarray.js
CHANGED
|
@@ -37,12 +37,10 @@ var dsapxsumpw = require( '@stdlib/blas-ext-base-dsapxsumpw' ).ndarray;
|
|
|
37
37
|
*
|
|
38
38
|
* @example
|
|
39
39
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
40
|
-
* var floor = require( '@stdlib/math-base-special-floor' );
|
|
41
40
|
*
|
|
42
41
|
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
43
|
-
* var N = floor( x.length / 2 );
|
|
44
42
|
*
|
|
45
|
-
* var v = dsapxsum(
|
|
43
|
+
* var v = dsapxsum( 4, 5.0, x, 2, 1 );
|
|
46
44
|
* // returns 25.0
|
|
47
45
|
*/
|
|
48
46
|
function dsapxsum( N, alpha, 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( './dsapxsum.native.js' );
|
|
25
26
|
|
|
26
27
|
|
|
@@ -38,20 +39,17 @@ var addon = require( './dsapxsum.native.js' );
|
|
|
38
39
|
*
|
|
39
40
|
* @example
|
|
40
41
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
41
|
-
* var floor = require( '@stdlib/math-base-special-floor' );
|
|
42
42
|
*
|
|
43
43
|
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
44
|
-
* var N = floor( x.length / 2 );
|
|
45
44
|
*
|
|
46
|
-
* var v = dsapxsum(
|
|
45
|
+
* var v = dsapxsum( 4, 5.0, x, 2, 1 );
|
|
47
46
|
* // returns 25.0
|
|
48
47
|
*/
|
|
49
48
|
function dsapxsum( N, alpha, x, stride, offset ) {
|
|
50
49
|
var view;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len
|
|
50
|
+
|
|
51
|
+
offset = minViewBufferIndex( N, stride, offset );
|
|
52
|
+
view = offsetView( x, offset );
|
|
55
53
|
return addon( N, alpha, view, stride );
|
|
56
54
|
}
|
|
57
55
|
|
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/dsapxsum.c"
|
|
32
|
+
],
|
|
33
|
+
"include": [
|
|
34
|
+
"./include"
|
|
35
|
+
],
|
|
36
|
+
"libraries": [
|
|
37
|
+
"-lm"
|
|
38
|
+
],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/napi-export",
|
|
42
|
+
"@stdlib/napi-argv",
|
|
43
|
+
"@stdlib/napi-argv-int64",
|
|
44
|
+
"@stdlib/napi-argv-float",
|
|
45
|
+
"@stdlib/napi-argv-strided-float32array",
|
|
46
|
+
"@stdlib/blas-ext-base-dsapxsumpw"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"task": "benchmark",
|
|
51
|
+
"src": [
|
|
52
|
+
"./src/dsapxsum.c"
|
|
53
|
+
],
|
|
54
|
+
"include": [
|
|
55
|
+
"./include"
|
|
56
|
+
],
|
|
57
|
+
"libraries": [
|
|
58
|
+
"-lm"
|
|
59
|
+
],
|
|
60
|
+
"libpath": [],
|
|
61
|
+
"dependencies": [
|
|
62
|
+
"@stdlib/blas-ext-base-dsapxsumpw"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"task": "examples",
|
|
67
|
+
"src": [
|
|
68
|
+
"./src/dsapxsum.c"
|
|
69
|
+
],
|
|
70
|
+
"include": [
|
|
71
|
+
"./include"
|
|
72
|
+
],
|
|
73
|
+
"libraries": [
|
|
74
|
+
"-lm"
|
|
75
|
+
],
|
|
76
|
+
"libpath": [],
|
|
77
|
+
"dependencies": [
|
|
78
|
+
"@stdlib/blas-ext-base-dsapxsumpw"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
]
|
|
42
82
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/blas-ext-base-dsapxsum",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Adds a constant to each single-precision floating-point strided array element and computes the sum using extended accumulation and returning an extended precision result.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -34,11 +34,16 @@
|
|
|
34
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@stdlib/assert-is-error": "^0.2.
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.2",
|
|
38
38
|
"@stdlib/blas-ext-base-dsapxsumpw": "^0.2.1",
|
|
39
|
-
"@stdlib/
|
|
40
|
-
"@stdlib/
|
|
41
|
-
"@stdlib/
|
|
39
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
40
|
+
"@stdlib/napi-argv-float": "^0.2.2",
|
|
41
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
42
|
+
"@stdlib/napi-argv-strided-float32array": "^0.2.2",
|
|
43
|
+
"@stdlib/napi-export": "^0.2.2",
|
|
44
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
45
|
+
"@stdlib/utils-library-manifest": "^0.2.2",
|
|
46
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
42
47
|
},
|
|
43
48
|
"devDependencies": {},
|
|
44
49
|
"engines": {
|
|
@@ -77,7 +82,9 @@
|
|
|
77
82
|
"float",
|
|
78
83
|
"float32array"
|
|
79
84
|
],
|
|
80
|
-
"__stdlib__": {
|
|
85
|
+
"__stdlib__": {
|
|
86
|
+
"wasm": false
|
|
87
|
+
},
|
|
81
88
|
"funding": {
|
|
82
89
|
"type": "opencollective",
|
|
83
90
|
"url": "https://opencollective.com/stdlib"
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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/dsapxsum.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_float.h"
|
|
24
|
+
#include "stdlib/napi/argv_strided_float32array.h"
|
|
25
|
+
#include <node_api.h>
|
|
26
|
+
#include <assert.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, 4 );
|
|
37
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
38
|
+
STDLIB_NAPI_ARGV_FLOAT( env, N, argv, 1 );
|
|
39
|
+
STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
|
|
40
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 2 );
|
|
41
|
+
|
|
42
|
+
napi_value v;
|
|
43
|
+
status = napi_create_double( env, stdlib_strided_dsapxsum( N, alpha, X, stride ), &v );
|
|
44
|
+
assert( status == napi_ok );
|
|
45
|
+
return v;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
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,130 +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/dsapxsum.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_dsapxsum {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Adds a constant to each single-precision floating-point strided array element and computes the sum using extended accumulation and returning an extended precision result.
|
|
33
|
-
*
|
|
34
|
-
* ## Notes
|
|
35
|
-
*
|
|
36
|
-
* - When called from JavaScript, the function expects four arguments:
|
|
37
|
-
*
|
|
38
|
-
* - `N`: number of indexed elements
|
|
39
|
-
* - `alpha`: constant
|
|
40
|
-
* - `X`: input array
|
|
41
|
-
* - `stride`: stride length
|
|
42
|
-
*/
|
|
43
|
-
napi_value node_dsapxsum( napi_env env, napi_callback_info info ) {
|
|
44
|
-
napi_status status;
|
|
45
|
-
|
|
46
|
-
size_t argc = 4;
|
|
47
|
-
napi_value argv[ 4 ];
|
|
48
|
-
status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
|
|
49
|
-
assert( status == napi_ok );
|
|
50
|
-
|
|
51
|
-
if ( argc < 4 ) {
|
|
52
|
-
napi_throw_error( env, nullptr, "invalid invocation. Must provide 4 arguments." );
|
|
53
|
-
return nullptr;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
napi_valuetype vtype0;
|
|
57
|
-
status = napi_typeof( env, argv[ 0 ], &vtype0 );
|
|
58
|
-
assert( status == napi_ok );
|
|
59
|
-
if ( vtype0 != napi_number ) {
|
|
60
|
-
napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
|
|
61
|
-
return nullptr;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
napi_valuetype vtype1;
|
|
65
|
-
status = napi_typeof( env, argv[ 1 ], &vtype1 );
|
|
66
|
-
assert( status == napi_ok );
|
|
67
|
-
if ( vtype1 != napi_number ) {
|
|
68
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." );
|
|
69
|
-
return nullptr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
bool res;
|
|
73
|
-
status = napi_is_typedarray( env, argv[ 2 ], &res );
|
|
74
|
-
assert( status == napi_ok );
|
|
75
|
-
if ( res == false ) {
|
|
76
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." );
|
|
77
|
-
return nullptr;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
napi_valuetype vtype3;
|
|
81
|
-
status = napi_typeof( env, argv[ 3 ], &vtype3 );
|
|
82
|
-
assert( status == napi_ok );
|
|
83
|
-
if ( vtype3 != napi_number ) {
|
|
84
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." );
|
|
85
|
-
return nullptr;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
int64_t N;
|
|
89
|
-
status = napi_get_value_int64( env, argv[ 0 ], &N );
|
|
90
|
-
assert( status == napi_ok );
|
|
91
|
-
|
|
92
|
-
double alpha;
|
|
93
|
-
status = napi_get_value_double( env, argv[ 1 ], &alpha );
|
|
94
|
-
assert( status == napi_ok );
|
|
95
|
-
|
|
96
|
-
int64_t stride;
|
|
97
|
-
status = napi_get_value_int64( env, argv[ 3 ], &stride );
|
|
98
|
-
assert( status == napi_ok );
|
|
99
|
-
|
|
100
|
-
napi_typedarray_type vtype2;
|
|
101
|
-
size_t xlen;
|
|
102
|
-
void *X;
|
|
103
|
-
status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr );
|
|
104
|
-
assert( status == napi_ok );
|
|
105
|
-
if ( vtype2 != napi_float32_array ) {
|
|
106
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." );
|
|
107
|
-
return nullptr;
|
|
108
|
-
}
|
|
109
|
-
if ( (N-1)*llabs(stride) >= (int64_t)xlen ) {
|
|
110
|
-
napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." );
|
|
111
|
-
return nullptr;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
napi_value v;
|
|
115
|
-
status = napi_create_double( env, stdlib_strided_dsapxsum( N, (float)alpha, (float *)X, stride ), &v );
|
|
116
|
-
assert( status == napi_ok );
|
|
117
|
-
|
|
118
|
-
return v;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
napi_value Init( napi_env env, napi_value exports ) {
|
|
122
|
-
napi_status status;
|
|
123
|
-
napi_value fcn;
|
|
124
|
-
status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dsapxsum, NULL, &fcn );
|
|
125
|
-
assert( status == napi_ok );
|
|
126
|
-
return fcn;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
|
|
130
|
-
} // end namespace stdlib_blas_ext_base_dsapxsum
|