@stdlib/blas-ext-base-gnansumors 0.0.6 → 0.0.7
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 +46 -2
- package/lib/index.js +9 -2
- package/lib/main.js +44 -4
- package/package.json +1 -1
- package/lib/gnansumors.js +0 -75
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2022 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|
|
20
20
|
|
|
21
21
|
# gnansumors
|
|
22
22
|
|
|
23
|
-
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
|
|
23
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
24
24
|
|
|
25
25
|
> Calculate the sum of strided array elements, ignoring `NaN` values and using ordinary recursive summation.
|
|
26
26
|
|
|
@@ -172,6 +172,27 @@ console.log( v );
|
|
|
172
172
|
|
|
173
173
|
<!-- /.examples -->
|
|
174
174
|
|
|
175
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
176
|
+
|
|
177
|
+
<section class="related">
|
|
178
|
+
|
|
179
|
+
* * *
|
|
180
|
+
|
|
181
|
+
## See Also
|
|
182
|
+
|
|
183
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/dnansumors`][@stdlib/blas/ext/base/dnansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of double-precision floating-point strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
|
|
184
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/gnansum`][@stdlib/blas/ext/base/gnansum]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements, ignoring NaN values.</span>
|
|
185
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/gnansumkbn2`][@stdlib/blas/ext/base/gnansumkbn2]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements, ignoring NaN values and using a second-order iterative Kahan–Babuška algorithm.</span>
|
|
186
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/gnansumpw`][@stdlib/blas/ext/base/gnansumpw]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements, ignoring NaN values and using pairwise summation.</span>
|
|
187
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/gsumors`][@stdlib/blas/ext/base/gsumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements using ordinary recursive summation.</span>
|
|
188
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/snansumors`][@stdlib/blas/ext/base/snansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
|
|
189
|
+
|
|
190
|
+
</section>
|
|
191
|
+
|
|
192
|
+
<!-- /.related -->
|
|
193
|
+
|
|
194
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
195
|
+
|
|
175
196
|
|
|
176
197
|
<section class="main-repo" >
|
|
177
198
|
|
|
@@ -196,7 +217,7 @@ See [LICENSE][stdlib-license].
|
|
|
196
217
|
|
|
197
218
|
## Copyright
|
|
198
219
|
|
|
199
|
-
Copyright © 2016-
|
|
220
|
+
Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
200
221
|
|
|
201
222
|
</section>
|
|
202
223
|
|
|
@@ -215,9 +236,20 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
215
236
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gnansumors/main.svg
|
|
216
237
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gnansumors?branch=main
|
|
217
238
|
|
|
239
|
+
<!--
|
|
240
|
+
|
|
218
241
|
[dependencies-image]: https://img.shields.io/david/stdlib-js/blas-ext-base-gnansumors.svg
|
|
219
242
|
[dependencies-url]: https://david-dm.org/stdlib-js/blas-ext-base-gnansumors/main
|
|
220
243
|
|
|
244
|
+
-->
|
|
245
|
+
|
|
246
|
+
[umd]: https://github.com/umdjs/umd
|
|
247
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
248
|
+
|
|
249
|
+
[deno-url]: https://github.com/stdlib-js/blas-ext-base-gnansumors/tree/deno
|
|
250
|
+
[umd-url]: https://github.com/stdlib-js/blas-ext-base-gnansumors/tree/umd
|
|
251
|
+
[esm-url]: https://github.com/stdlib-js/blas-ext-base-gnansumors/tree/esm
|
|
252
|
+
|
|
221
253
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
222
254
|
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
223
255
|
|
|
@@ -231,10 +263,22 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
231
263
|
|
|
232
264
|
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
|
|
233
265
|
|
|
266
|
+
<!-- <related-links> -->
|
|
267
|
+
|
|
234
268
|
[@stdlib/blas/ext/base/dnansumors]: https://www.npmjs.com/package/@stdlib/blas-ext-base-dnansumors
|
|
235
269
|
|
|
270
|
+
[@stdlib/blas/ext/base/gnansum]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gnansum
|
|
271
|
+
|
|
272
|
+
[@stdlib/blas/ext/base/gnansumkbn2]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gnansumkbn2
|
|
273
|
+
|
|
274
|
+
[@stdlib/blas/ext/base/gnansumpw]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gnansumpw
|
|
275
|
+
|
|
276
|
+
[@stdlib/blas/ext/base/gsumors]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gsumors
|
|
277
|
+
|
|
236
278
|
[@stdlib/blas/ext/base/snansumors]: https://www.npmjs.com/package/@stdlib/blas-ext-base-snansumors
|
|
237
279
|
|
|
280
|
+
<!-- </related-links> -->
|
|
281
|
+
|
|
238
282
|
</section>
|
|
239
283
|
|
|
240
284
|
<!-- /.links -->
|
package/lib/index.js
CHANGED
|
@@ -45,9 +45,16 @@
|
|
|
45
45
|
|
|
46
46
|
// MODULES //
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
49
|
+
var main = require( './main.js' );
|
|
50
|
+
var ndarray = require( './ndarray.js' );
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// MAIN //
|
|
54
|
+
|
|
55
|
+
setReadOnly( main, 'ndarray', ndarray );
|
|
49
56
|
|
|
50
57
|
|
|
51
58
|
// EXPORTS //
|
|
52
59
|
|
|
53
|
-
module.exports =
|
|
60
|
+
module.exports = main;
|
package/lib/main.js
CHANGED
|
@@ -20,14 +20,54 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
24
|
-
var gnansumors = require( './gnansumors.js' );
|
|
25
|
-
var ndarray = require( './ndarray.js' );
|
|
23
|
+
var isnan = require( '@stdlib/math-base-assert-is-nan' );
|
|
26
24
|
|
|
27
25
|
|
|
28
26
|
// MAIN //
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Computes the sum of strided array elements, ignoring `NaN` values and using ordinary recursive summation.
|
|
30
|
+
*
|
|
31
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
32
|
+
* @param {NumericArray} x - input array
|
|
33
|
+
* @param {integer} stride - stride length
|
|
34
|
+
* @returns {number} sum
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
38
|
+
* var N = x.length;
|
|
39
|
+
*
|
|
40
|
+
* var v = gnansumors( N, x, 1 );
|
|
41
|
+
* // returns 1.0
|
|
42
|
+
*/
|
|
43
|
+
function gnansumors( N, x, stride ) {
|
|
44
|
+
var ix;
|
|
45
|
+
var s;
|
|
46
|
+
var i;
|
|
47
|
+
|
|
48
|
+
s = 0.0;
|
|
49
|
+
if ( N <= 0 ) {
|
|
50
|
+
return s;
|
|
51
|
+
}
|
|
52
|
+
if ( N === 1 || stride === 0 ) {
|
|
53
|
+
if ( isnan( x[ 0 ] ) ) {
|
|
54
|
+
return s;
|
|
55
|
+
}
|
|
56
|
+
return x[ 0 ];
|
|
57
|
+
}
|
|
58
|
+
if ( stride < 0 ) {
|
|
59
|
+
ix = (1-N) * stride;
|
|
60
|
+
} else {
|
|
61
|
+
ix = 0;
|
|
62
|
+
}
|
|
63
|
+
for ( i = 0; i < N; i++ ) {
|
|
64
|
+
if ( isnan( x[ ix ] ) === false ) {
|
|
65
|
+
s += x[ ix ];
|
|
66
|
+
}
|
|
67
|
+
ix += stride;
|
|
68
|
+
}
|
|
69
|
+
return s;
|
|
70
|
+
}
|
|
31
71
|
|
|
32
72
|
|
|
33
73
|
// EXPORTS //
|
package/package.json
CHANGED
package/lib/gnansumors.js
DELETED
|
@@ -1,75 +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
|
-
'use strict';
|
|
20
|
-
|
|
21
|
-
// MODULES //
|
|
22
|
-
|
|
23
|
-
var isnan = require( '@stdlib/math-base-assert-is-nan' );
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// MAIN //
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Computes the sum of strided array elements, ignoring `NaN` values and using ordinary recursive summation.
|
|
30
|
-
*
|
|
31
|
-
* @param {PositiveInteger} N - number of indexed elements
|
|
32
|
-
* @param {NumericArray} x - input array
|
|
33
|
-
* @param {integer} stride - stride length
|
|
34
|
-
* @returns {number} sum
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
38
|
-
* var N = x.length;
|
|
39
|
-
*
|
|
40
|
-
* var v = gnansumors( N, x, 1 );
|
|
41
|
-
* // returns 1.0
|
|
42
|
-
*/
|
|
43
|
-
function gnansumors( N, x, stride ) {
|
|
44
|
-
var ix;
|
|
45
|
-
var s;
|
|
46
|
-
var i;
|
|
47
|
-
|
|
48
|
-
s = 0.0;
|
|
49
|
-
if ( N <= 0 ) {
|
|
50
|
-
return s;
|
|
51
|
-
}
|
|
52
|
-
if ( N === 1 || stride === 0 ) {
|
|
53
|
-
if ( isnan( x[ 0 ] ) ) {
|
|
54
|
-
return s;
|
|
55
|
-
}
|
|
56
|
-
return x[ 0 ];
|
|
57
|
-
}
|
|
58
|
-
if ( stride < 0 ) {
|
|
59
|
-
ix = (1-N) * stride;
|
|
60
|
-
} else {
|
|
61
|
-
ix = 0;
|
|
62
|
-
}
|
|
63
|
-
for ( i = 0; i < N; i++ ) {
|
|
64
|
-
if ( isnan( x[ ix ] ) === false ) {
|
|
65
|
-
s += x[ ix ];
|
|
66
|
-
}
|
|
67
|
-
ix += stride;
|
|
68
|
-
}
|
|
69
|
-
return s;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// EXPORTS //
|
|
74
|
-
|
|
75
|
-
module.exports = gnansumors;
|