@stdlib/blas-ext-base-dsnansumpw 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 +141 -38
- package/dist/index.js +7 -7
- package/dist/index.js.map +3 -3
- package/docs/types/index.d.ts +7 -7
- package/include/stdlib/blas/ext/base/dsnansumpw.h +8 -6
- package/lib/dsnansumpw.js +6 -36
- package/lib/dsnansumpw.native.js +4 -5
- package/lib/index.js +2 -5
- package/lib/ndarray.js +28 -30
- package/lib/ndarray.native.js +6 -13
- package/manifest.json +80 -40
- package/package.json +14 -8
- package/src/addon.c +62 -0
- package/src/{dsnansumpw.c → main.c} +58 -48
- package/include.gypi +0 -53
- package/src/addon.cpp +0 -117
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-dsnansumpw
|
|
|
59
59
|
var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
#### dsnansumpw( N, x,
|
|
62
|
+
#### dsnansumpw( N, x, strideX )
|
|
63
63
|
|
|
64
64
|
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using pairwise summation with extended accumulation, and returning an extended precision result.
|
|
65
65
|
|
|
@@ -67,9 +67,8 @@ Computes the sum of single-precision floating-point strided array elements, igno
|
|
|
67
67
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
68
68
|
|
|
69
69
|
var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
|
|
70
|
-
var N = x.length;
|
|
71
70
|
|
|
72
|
-
var v = dsnansumpw(
|
|
71
|
+
var v = dsnansumpw( 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
|
-
- **stride**:
|
|
79
|
+
- **stride**: 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 = dsnansumpw(
|
|
88
|
+
var v = dsnansumpw( 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 = dsnansumpw( N, x1, 2 );
|
|
102
|
+
var v = dsnansumpw( 4, x1, 2 );
|
|
109
103
|
// returns 5.0
|
|
110
104
|
```
|
|
111
105
|
|
|
112
|
-
#### dsnansumpw.ndarray( N, x,
|
|
106
|
+
#### dsnansumpw.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 pairwise summation with 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 = dsnansumpw.ndarray(
|
|
115
|
+
var v = dsnansumpw.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 `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 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 = dsnansumpw.ndarray(
|
|
130
|
+
var v = dsnansumpw.ndarray( 4, x, 2, 1 );
|
|
140
131
|
// returns 5.0
|
|
141
132
|
```
|
|
142
133
|
|
|
@@ -162,22 +153,19 @@ var v = dsnansumpw.ndarray( N, x, 2, 1 );
|
|
|
162
153
|
<!-- eslint no-undef: "error" -->
|
|
163
154
|
|
|
164
155
|
```javascript
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
var
|
|
156
|
+
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
|
|
157
|
+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
|
|
158
|
+
var filledarrayBy = require( '@stdlib/array-filled-by' );
|
|
168
159
|
var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );
|
|
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.8 ) > 0 ) {
|
|
163
|
+
return NaN;
|
|
179
164
|
}
|
|
165
|
+
return discreteUniform( 0, 100 );
|
|
180
166
|
}
|
|
167
|
+
|
|
168
|
+
var x = filledarrayBy( 10, 'float32', rand );
|
|
181
169
|
console.log( x );
|
|
182
170
|
|
|
183
171
|
var v = dsnansumpw( x.length, x, 1 );
|
|
@@ -188,8 +176,123 @@ console.log( v );
|
|
|
188
176
|
|
|
189
177
|
<!-- /.examples -->
|
|
190
178
|
|
|
179
|
+
<!-- C interface documentation. -->
|
|
180
|
+
|
|
191
181
|
* * *
|
|
192
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/dsnansumpw.h"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### stdlib_strided_dsnansumpw( N, \*X, strideX )
|
|
206
|
+
|
|
207
|
+
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using pairwise summation with extended accumulation, and returning an extended precision result.
|
|
208
|
+
|
|
209
|
+
```c
|
|
210
|
+
const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
|
|
211
|
+
|
|
212
|
+
double v = stdlib_strided_dsnansumpw( 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_dsnansumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
#### stdlib_strided_dsnansumpw_ndarray( N, \*X, strideX, offsetX )
|
|
227
|
+
|
|
228
|
+
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using pairwise summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
|
|
229
|
+
|
|
230
|
+
```c
|
|
231
|
+
const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
|
|
232
|
+
|
|
233
|
+
double v = stdlib_strided_dsnansumpw_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_dsnansumpw_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/dsnansumpw.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_dsnansumpw( 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
|
+
|
|
193
296
|
<section class="references">
|
|
194
297
|
|
|
195
298
|
## References
|
|
@@ -243,7 +346,7 @@ See [LICENSE][stdlib-license].
|
|
|
243
346
|
|
|
244
347
|
## Copyright
|
|
245
348
|
|
|
246
|
-
Copyright © 2016-
|
|
349
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
247
350
|
|
|
248
351
|
</section>
|
|
249
352
|
|
|
@@ -256,8 +359,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
256
359
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsnansumpw.svg
|
|
257
360
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsnansumpw
|
|
258
361
|
|
|
259
|
-
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansumpw/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
260
|
-
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansumpw/actions/workflows/test.yml?query=branch:v0.
|
|
362
|
+
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsnansumpw/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
363
|
+
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsnansumpw/actions/workflows/test.yml?query=branch:v0.3.0
|
|
261
364
|
|
|
262
365
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsnansumpw/main.svg
|
|
263
366
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsnansumpw?branch=main
|
|
@@ -269,8 +372,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
269
372
|
|
|
270
373
|
-->
|
|
271
374
|
|
|
272
|
-
[chat-image]: https://img.shields.io/
|
|
273
|
-
[chat-url]: https://
|
|
375
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
376
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
274
377
|
|
|
275
378
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
276
379
|
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
var
|
|
3
|
-
});var
|
|
4
|
-
var
|
|
5
|
-
});var
|
|
6
|
-
var k=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),
|
|
7
|
-
});var A=require("path").join,D=require('@stdlib/utils-try-require/dist'),F=require('@stdlib/assert-is-error/dist'),G=
|
|
1
|
+
"use strict";var y=function(v,a){return function(){return a||v((a={exports:{}}).exports,a),a.exports}};var j=y(function(J,R){
|
|
2
|
+
var u=require('@stdlib/math-base-assert-is-nanf/dist'),S=require('@stdlib/math-base-special-floor/dist'),Z=128;function w(v,a,n,M){var r,o,i,q,p,m,c,l,t,O,f,s,e;if(v<=0)return 0;if(r=M,n===0)return u(a[r])?0:v*a[r];if(v<8){for(f=0,e=0;e<v;e++)u(a[r])===!1&&(f+=a[r]),r+=n;return f}if(v<=Z){for(o=u(a[r])?0:a[r],r+=n,i=u(a[r])?0:a[r],r+=n,q=u(a[r])?0:a[r],r+=n,p=u(a[r])?0:a[r],r+=n,m=u(a[r])?0:a[r],r+=n,c=u(a[r])?0:a[r],r+=n,l=u(a[r])?0:a[r],r+=n,t=u(a[r])?0:a[r],r+=n,O=v%8,e=8;e<v-O;e+=8)o+=u(a[r])?0:a[r],r+=n,i+=u(a[r])?0:a[r],r+=n,q+=u(a[r])?0:a[r],r+=n,p+=u(a[r])?0:a[r],r+=n,m+=u(a[r])?0:a[r],r+=n,c+=u(a[r])?0:a[r],r+=n,l+=u(a[r])?0:a[r],r+=n,t+=u(a[r])?0:a[r],r+=n;for(f=o+i+(q+p)+(m+c+(l+t)),e;e<v;e++)u(a[r])===!1&&(f+=a[r]),r+=n;return f}return s=S(v/2),s-=s%8,w(s,a,n,r)+w(v-s,a,n,r+s*n)}R.exports=w
|
|
3
|
+
});var B=y(function(P,_){
|
|
4
|
+
var b=require('@stdlib/strided-base-stride2offset/dist'),g=j();function h(v,a,n){return g(v,a,n,b(v,n))}_.exports=h
|
|
5
|
+
});var K=y(function(Q,I){
|
|
6
|
+
var k=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),C=B(),z=j();k(C,"ndarray",z);I.exports=C
|
|
7
|
+
});var A=require("path").join,D=require('@stdlib/utils-try-require/dist'),F=require('@stdlib/assert-is-error/dist'),G=K(),E,L=D(A(__dirname,"./native.js"));F(L)?E=G:E=L;module.exports=E;
|
|
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
3
|
"sources": ["../lib/ndarray.js", "../lib/dsnansumpw.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 isnanf = require( '@stdlib/math-base-assert-is-nanf' );\nvar floor = require( '@stdlib/math-base-special-floor' );\n\n\n// VARIABLES //\n\n// Blocksize for pairwise summation (NOTE: decreasing the blocksize decreases rounding error as more pairs are summed, but also decreases performance. Because the inner loop is unrolled eight times, the blocksize is effectively `16`.):\nvar BLOCKSIZE = 128;\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using pairwise summation with extended accumulation, and returning an extended precision result.\n*\n* ## Method\n*\n* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.\n*\n* ## References\n*\n* - Higham, Nicholas J. 1993. \"The Accuracy of Floating Point Summation.\" _SIAM Journal on Scientific Computing_ 14 (4): 783\u201399. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).\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* var floor = require( '@stdlib/math-base-special-floor' );\n*\n* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );\n* var N = floor( x.length / 2 );\n*\n* var v = dsnansumpw( N, x, 2, 1 );\n* // returns 5.0\n*/\nfunction dsnansumpw( N, x, stride, offset ) {\n\tvar ix;\n\tvar s0;\n\tvar s1;\n\tvar s2;\n\tvar s3;\n\tvar s4;\n\tvar s5;\n\tvar s6;\n\tvar s7;\n\tvar M;\n\tvar s;\n\tvar n;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn 0.0;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnanf( x[ offset ] ) ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn x[ offset ];\n\t}\n\tix = offset;\n\tif ( N < 8 ) {\n\t\t// Use simple summation...\n\t\ts = 0.0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( isnanf( x[ ix ] ) === false ) {\n\t\t\t\ts += x[ ix ];\n\t\t\t}\n\t\t\tix += stride;\n\t\t}\n\t\treturn s;\n\t}\n\tif ( N <= BLOCKSIZE ) {\n\t\t// Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...\n\t\ts0 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\t\ts1 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\t\ts2 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\t\ts3 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\t\ts4 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\t\ts5 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\t\ts6 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\t\ts7 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += stride;\n\n\t\tM = N % 8;\n\t\tfor ( i = 8; i < N-M; i += 8 ) {\n\t\t\ts0 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t\ts1 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t\ts2 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t\ts3 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t\ts4 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t\ts5 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t\ts6 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t\ts7 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += stride;\n\t\t}\n\t\t// Pairwise sum the accumulators:\n\t\ts = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));\n\n\t\t// Clean-up loop...\n\t\tfor ( i; i < N; i++ ) {\n\t\t\tif ( isnanf( x[ ix ] ) === false ) {\n\t\t\t\ts += x[ ix ];\n\t\t\t}\n\t\t\tix += stride;\n\t\t}\n\t\treturn s;\n\t}\n\t// Recurse by dividing by two, but avoiding non-multiples of unroll factor...\n\tn = floor( N/2 );\n\tn -= n % 8;\n\treturn dsnansumpw( n, x, stride, ix ) + dsnansumpw( N-n, x, stride, ix+(n*stride) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\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 isnanf = require( '@stdlib/math-base-assert-is-nanf' );\nvar sum = 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 pairwise summation with extended accumulation, and returning an extended precision result.\n*\n* ## Method\n*\n* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.\n*\n* ## References\n*\n* - Higham, Nicholas J. 1993. \"The Accuracy of Floating Point Summation.\" _SIAM Journal on Scientific Computing_ 14 (4): 783\u201399. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).\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 = dsnansumpw( N, x, 1 );\n* // returns 1.0\n*/\nfunction dsnansumpw( N, x, stride ) {\n\tvar ix;\n\tvar s;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn 0.0;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnanf( x[ 0 ] ) ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn x[ 0 ];\n\t}\n\tif ( stride < 0 ) {\n\t\tix = (1-N) * stride;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( N < 8 ) {\n\t\t// Use simple summation...\n\t\ts = 0.0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( isnanf( x[ ix ] ) === false ) {\n\t\t\t\ts += x[ ix ];\n\t\t\t}\n\t\t\tix += stride;\n\t\t}\n\t\treturn s;\n\t}\n\treturn sum( N, x, stride, ix );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\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 dsnansumpw = require( './dsnansumpw.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsnansumpw, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\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 pairwise summation with extended accumulation, and returning an extended precision result.\n*\n* @module @stdlib/blas-ext-base-dsnansumpw\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n* var N = x.length;\n*\n* var v = dsnansumpw( N, x, 1 );\n* // returns 1.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );\n*\n* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );\n* var N = floor( x.length / 2 );\n*\n* var v = dsnansumpw.ndarray( N, 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 dsnansumpw;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsnansumpw = main;\n} else {\n\tdsnansumpw = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\n\n// exports: { \"ndarray\": \"dsnansumpw.ndarray\" }\n"],
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,kCAAmC,EACrDC,EAAQ,QAAS,iCAAkC,EAMnDC,EAAY,
|
|
6
|
-
"names": ["require_ndarray", "__commonJSMin", "exports", "module", "isnanf", "floor", "BLOCKSIZE", "dsnansumpw", "N", "x", "
|
|
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 isnanf = require( '@stdlib/math-base-assert-is-nanf' );\nvar floor = require( '@stdlib/math-base-special-floor' );\n\n\n// VARIABLES //\n\n// Blocksize for pairwise summation (NOTE: decreasing the blocksize decreases rounding error as more pairs are summed, but also decreases performance. Because the inner loop is unrolled eight times, the blocksize is effectively `16`.):\nvar BLOCKSIZE = 128;\n\n\n// MAIN //\n\n/**\n* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using pairwise summation with extended accumulation, and returning an extended precision result.\n*\n* ## Method\n*\n* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.\n*\n* ## References\n*\n* - Higham, Nicholas J. 1993. \"The Accuracy of Floating Point Summation.\" _SIAM Journal on Scientific Computing_ 14 (4): 783\u201399. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).\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 = dsnansumpw( 5, x, 2, 1 );\n* // returns 5.0\n*/\nfunction dsnansumpw( N, x, strideX, offsetX ) {\n\tvar ix;\n\tvar s0;\n\tvar s1;\n\tvar s2;\n\tvar s3;\n\tvar s4;\n\tvar s5;\n\tvar s6;\n\tvar s7;\n\tvar M;\n\tvar s;\n\tvar n;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn 0.0;\n\t}\n\tix = offsetX;\n\tif ( strideX === 0 ) {\n\t\tif ( isnanf( x[ ix ] ) ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn N * x[ ix ];\n\t}\n\tif ( N < 8 ) {\n\t\t// Use simple summation...\n\t\ts = 0.0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( isnanf( x[ ix ] ) === false ) {\n\t\t\t\ts += x[ ix ];\n\t\t\t}\n\t\t\tix += strideX;\n\t\t}\n\t\treturn s;\n\t}\n\tif ( N <= BLOCKSIZE ) {\n\t\t// Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...\n\t\ts0 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\t\ts1 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\t\ts2 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\t\ts3 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\t\ts4 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\t\ts5 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\t\ts6 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\t\ts7 = ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\tix += strideX;\n\n\t\tM = N % 8;\n\t\tfor ( i = 8; i < N-M; i += 8 ) {\n\t\t\ts0 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t\ts1 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t\ts2 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t\ts3 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t\ts4 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t\ts5 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t\ts6 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t\ts7 += ( isnanf( x[ ix ] ) ) ? 0.0 : x[ ix ];\n\t\t\tix += strideX;\n\t\t}\n\t\t// Pairwise sum the accumulators:\n\t\ts = ( (s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7) );\n\n\t\t// Clean-up loop...\n\t\tfor ( i; i < N; i++ ) {\n\t\t\tif ( isnanf( x[ ix ] ) === false ) {\n\t\t\t\ts += x[ ix ];\n\t\t\t}\n\t\t\tix += strideX;\n\t\t}\n\t\treturn s;\n\t}\n\t// Recurse by dividing by two, but avoiding non-multiples of unroll factor...\n\tn = floor( N/2 );\n\tn -= n % 8;\n\treturn dsnansumpw( n, x, strideX, ix ) + dsnansumpw( N-n, x, strideX, ix+(n*strideX) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\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 pairwise summation with extended accumulation, and returning an extended precision result.\n*\n* ## Method\n*\n* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.\n*\n* ## References\n*\n* - Higham, Nicholas J. 1993. \"The Accuracy of Floating Point Summation.\" _SIAM Journal on Scientific Computing_ 14 (4): 783\u201399. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).\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 = dsnansumpw( x.length, x, 1 );\n* // returns 1.0\n*/\nfunction dsnansumpw( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\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 dsnansumpw = require( './dsnansumpw.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsnansumpw, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\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 pairwise summation with extended accumulation, and returning an extended precision result.\n*\n* @module @stdlib/blas-ext-base-dsnansumpw\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );\n*\n* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );\n*\n* var v = dsnansumpw( x.length, x, 1 );\n* // returns 1.0\n*\n* @example\n* var Float32Array = require( '@stdlib/array-float32' );\n* var dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );\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 = dsnansumpw.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 dsnansumpw;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsnansumpw = main;\n} else {\n\tdsnansumpw = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsnansumpw;\n\n// exports: { \"ndarray\": \"dsnansumpw.ndarray\" }\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["require_ndarray", "__commonJSMin", "exports", "module", "isnanf", "floor", "BLOCKSIZE", "dsnansumpw", "N", "x", "strideX", "offsetX", "ix", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "M", "s", "n", "i", "require_dsnansumpw", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "dsnansumpw", "N", "x", "strideX", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsnansumpw", "ndarray", "join", "tryRequire", "isError", "main", "dsnansumpw", "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 = dsnansumpw( 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 pairwise summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
|
|
45
45
|
*
|
|
46
46
|
* @param N - number of indexed elements
|
|
47
47
|
* @param x - input array
|
|
48
|
-
* @param
|
|
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 = dsnansumpw.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_DSNANSUMPW_H
|
|
23
20
|
#define STDLIB_BLAS_EXT_BASE_DSNANSUMPW_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 pairwise summation with extended
|
|
32
|
+
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using pairwise summation with extended accumulation, and returning an extended precision result.
|
|
33
|
+
*/
|
|
34
|
+
double API_SUFFIX(stdlib_strided_dsnansumpw)( 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 pairwise summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
|
|
36
38
|
*/
|
|
37
|
-
double
|
|
39
|
+
double API_SUFFIX(stdlib_strided_dsnansumpw_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/dsnansumpw.js
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
24
|
-
var
|
|
23
|
+
var stride2offset = require( '@stdlib/strided-base-stride2offset' );
|
|
24
|
+
var ndarray = require( './ndarray.js' );
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
// MAIN //
|
|
@@ -39,49 +39,19 @@ var sum = require( './ndarray.js' );
|
|
|
39
39
|
*
|
|
40
40
|
* @param {PositiveInteger} N - number of indexed elements
|
|
41
41
|
* @param {Float32Array} x - input array
|
|
42
|
-
* @param {integer}
|
|
42
|
+
* @param {integer} strideX - stride length
|
|
43
43
|
* @returns {number} sum
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
46
|
* var Float32Array = require( '@stdlib/array-float32' );
|
|
47
47
|
*
|
|
48
48
|
* var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
|
|
49
|
-
* var N = x.length;
|
|
50
49
|
*
|
|
51
|
-
* var v = dsnansumpw(
|
|
50
|
+
* var v = dsnansumpw( x.length, x, 1 );
|
|
52
51
|
* // returns 1.0
|
|
53
52
|
*/
|
|
54
|
-
function dsnansumpw( N, x,
|
|
55
|
-
|
|
56
|
-
var s;
|
|
57
|
-
var i;
|
|
58
|
-
|
|
59
|
-
if ( N <= 0 ) {
|
|
60
|
-
return 0.0;
|
|
61
|
-
}
|
|
62
|
-
if ( N === 1 || stride === 0 ) {
|
|
63
|
-
if ( isnanf( x[ 0 ] ) ) {
|
|
64
|
-
return 0.0;
|
|
65
|
-
}
|
|
66
|
-
return x[ 0 ];
|
|
67
|
-
}
|
|
68
|
-
if ( stride < 0 ) {
|
|
69
|
-
ix = (1-N) * stride;
|
|
70
|
-
} else {
|
|
71
|
-
ix = 0;
|
|
72
|
-
}
|
|
73
|
-
if ( N < 8 ) {
|
|
74
|
-
// Use simple summation...
|
|
75
|
-
s = 0.0;
|
|
76
|
-
for ( i = 0; i < N; i++ ) {
|
|
77
|
-
if ( isnanf( x[ ix ] ) === false ) {
|
|
78
|
-
s += x[ ix ];
|
|
79
|
-
}
|
|
80
|
-
ix += stride;
|
|
81
|
-
}
|
|
82
|
-
return s;
|
|
83
|
-
}
|
|
84
|
-
return sum( N, x, stride, ix );
|
|
53
|
+
function dsnansumpw( N, x, strideX ) {
|
|
54
|
+
return ndarray( N, x, strideX, stride2offset( N, strideX ) );
|
|
85
55
|
}
|
|
86
56
|
|
|
87
57
|
|
package/lib/dsnansumpw.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
|
-
* var N = x.length;
|
|
41
40
|
*
|
|
42
|
-
* var v = dsnansumpw(
|
|
41
|
+
* var v = dsnansumpw( x.length, x, 1 );
|
|
43
42
|
* // returns 1.0
|
|
44
43
|
*/
|
|
45
|
-
function dsnansumpw( N, x,
|
|
46
|
-
return addon( N, x,
|
|
44
|
+
function dsnansumpw( 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 dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );
|
|
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 = dsnansumpw(
|
|
32
|
+
* var v = dsnansumpw( 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 dsnansumpw = require( '@stdlib/blas-ext-base-dsnansumpw' );
|
|
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 = dsnansumpw.ndarray(
|
|
41
|
+
* var v = dsnansumpw.ndarray( 5, x, 2, 1 );
|
|
45
42
|
* // returns 5.0
|
|
46
43
|
*/
|
|
47
44
|
|