@stdlib/blas-ext-base-gnansumkbn 0.0.9 → 0.2.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 +30 -16
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +2 -2
- package/package.json +15 -14
- package/docs/repl.txt +0 -94
- package/docs/types/test.ts +0 -155
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# gnansumkbn
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -132,7 +143,7 @@ var v = gnansumkbn.ndarray( N, x, 2, 1 );
|
|
|
132
143
|
## Notes
|
|
133
144
|
|
|
134
145
|
- If `N <= 0`, both functions return `0.0`.
|
|
135
|
-
- Depending on the environment, the typed versions ([`
|
|
146
|
+
- Depending on the environment, the typed versions ([`dnansumkbn`][@stdlib/blas/ext/base/dnansumkbn], [`snansumkbn`][@stdlib/blas/ext/base/snansumkbn], etc.) are likely to be significantly more performant.
|
|
136
147
|
|
|
137
148
|
</section>
|
|
138
149
|
|
|
@@ -191,13 +202,13 @@ console.log( v );
|
|
|
191
202
|
|
|
192
203
|
## See Also
|
|
193
204
|
|
|
194
|
-
- <span class="package-name">[`@stdlib/blas
|
|
195
|
-
- <span class="package-name">[`@stdlib/blas
|
|
196
|
-
- <span class="package-name">[`@stdlib/blas
|
|
197
|
-
- <span class="package-name">[`@stdlib/blas
|
|
198
|
-
- <span class="package-name">[`@stdlib/blas
|
|
199
|
-
- <span class="package-name">[`@stdlib/blas
|
|
200
|
-
- <span class="package-name">[`@stdlib/blas
|
|
205
|
+
- <span class="package-name">[`@stdlib/blas-ext/base/dnansumkbn`][@stdlib/blas/ext/base/dnansumkbn]</span><span class="delimiter">: </span><span class="description">calculate the sum of double-precision floating-point strided array elements, ignoring NaN values and using an improved Kahan–Babuška algorithm.</span>
|
|
206
|
+
- <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>
|
|
207
|
+
- <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>
|
|
208
|
+
- <span class="package-name">[`@stdlib/blas-ext/base/gnansumors`][@stdlib/blas/ext/base/gnansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
|
|
209
|
+
- <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>
|
|
210
|
+
- <span class="package-name">[`@stdlib/blas-ext/base/gsumkbn`][@stdlib/blas/ext/base/gsumkbn]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements using an improved Kahan–Babuška algorithm.</span>
|
|
211
|
+
- <span class="package-name">[`@stdlib/blas-ext/base/snansumkbn`][@stdlib/blas/ext/base/snansumkbn]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements, ignoring NaN values and using an improved Kahan–Babuška algorithm.</span>
|
|
201
212
|
|
|
202
213
|
</section>
|
|
203
214
|
|
|
@@ -229,7 +240,7 @@ See [LICENSE][stdlib-license].
|
|
|
229
240
|
|
|
230
241
|
## Copyright
|
|
231
242
|
|
|
232
|
-
Copyright © 2016-
|
|
243
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
233
244
|
|
|
234
245
|
</section>
|
|
235
246
|
|
|
@@ -242,8 +253,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
242
253
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-gnansumkbn.svg
|
|
243
254
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-gnansumkbn
|
|
244
255
|
|
|
245
|
-
[test-image]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
246
|
-
[test-url]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/actions/workflows/test.yml?query=branch:v0.0
|
|
256
|
+
[test-image]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
257
|
+
[test-url]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/actions/workflows/test.yml?query=branch:v0.2.0
|
|
247
258
|
|
|
248
259
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gnansumkbn/main.svg
|
|
249
260
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gnansumkbn?branch=main
|
|
@@ -256,7 +267,7 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
256
267
|
-->
|
|
257
268
|
|
|
258
269
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
259
|
-
[chat-url]: https://gitter.im
|
|
270
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
260
271
|
|
|
261
272
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
262
273
|
|
|
@@ -266,8 +277,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
266
277
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
267
278
|
|
|
268
279
|
[deno-url]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/tree/deno
|
|
280
|
+
[deno-readme]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/blob/deno/README.md
|
|
269
281
|
[umd-url]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/tree/umd
|
|
282
|
+
[umd-readme]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/blob/umd/README.md
|
|
270
283
|
[esm-url]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/tree/esm
|
|
284
|
+
[esm-readme]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/blob/esm/README.md
|
|
271
285
|
[branches-url]: https://github.com/stdlib-js/blas-ext-base-gnansumkbn/blob/main/branches.md
|
|
272
286
|
|
|
273
287
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/blas-ext-base-gnansumkbn/main/LICENSE
|
|
@@ -278,10 +292,12 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
278
292
|
|
|
279
293
|
[@neumaier:1974a]: https://doi.org/10.1002/zamm.19740540106
|
|
280
294
|
|
|
281
|
-
<!-- <related-links> -->
|
|
282
|
-
|
|
283
295
|
[@stdlib/blas/ext/base/dnansumkbn]: https://www.npmjs.com/package/@stdlib/blas-ext-base-dnansumkbn
|
|
284
296
|
|
|
297
|
+
[@stdlib/blas/ext/base/snansumkbn]: https://www.npmjs.com/package/@stdlib/blas-ext-base-snansumkbn
|
|
298
|
+
|
|
299
|
+
<!-- <related-links> -->
|
|
300
|
+
|
|
285
301
|
[@stdlib/blas/ext/base/gnansum]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gnansum
|
|
286
302
|
|
|
287
303
|
[@stdlib/blas/ext/base/gnansumkbn2]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gnansumkbn2
|
|
@@ -292,8 +308,6 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
292
308
|
|
|
293
309
|
[@stdlib/blas/ext/base/gsumkbn]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gsumkbn
|
|
294
310
|
|
|
295
|
-
[@stdlib/blas/ext/base/snansumkbn]: https://www.npmjs.com/package/@stdlib/blas-ext-base-snansumkbn
|
|
296
|
-
|
|
297
311
|
<!-- </related-links> -->
|
|
298
312
|
|
|
299
313
|
</section>
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";var c=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var o=c(function(w,m){
|
|
2
|
+
var q=require('@stdlib/math-base-assert-is-nan/dist'),l=require('@stdlib/math-base-special-abs/dist');function x(n,r,t){var e,a,u,i,v,s;if(n<=0)return 0;if(n===1||t===0)return q(r[0])?0:r[0];for(t<0?a=(1-n)*t:a=0,e=0,v=0,s=0;s<n;s++)u=r[a],q(u)===!1&&(i=e+u,l(e)>=l(u)?v+=e-i+u:v+=u-i+e,e=i),a+=t;return e+v}m.exports=x
|
|
3
|
+
});var g=c(function(z,y){
|
|
4
|
+
var b=require('@stdlib/math-base-assert-is-nan/dist'),p=require('@stdlib/math-base-special-abs/dist');function O(n,r,t,e){var a,u,i,v,s,f;if(n<=0)return 0;if(n===1||t===0)return b(r[e])?0:r[e];for(u=e,a=0,s=0,f=0;f<n;f++)i=r[u],b(i)===!1&&(v=a+i,p(a)>=p(i)?s+=a-v+i:s+=i-v+a,a=v),u+=t;return a+s}y.exports=O
|
|
5
|
+
});var R=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),k=o(),h=g();R(k,"ndarray",h);module.exports=k;
|
|
6
|
+
/** @license Apache-2.0 */
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/ndarray.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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar abs = require( '@stdlib/math-base-special-abs' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of strided array elements, ignoring `NaN` values and using an improved Kahan\u2013Babu\u0161ka algorithm.\n*\n* ## Method\n*\n* - This implementation uses an \"improved Kahan\u2013Babu\u0161ka algorithm\", as described by Neumaier (1974).\n*\n* ## References\n*\n* - Neumaier, Arnold. 1974. \"Rounding Error Analysis of Some Methods for Summing Finite Sums.\" _Zeitschrift F\u00FCr Angewandte Mathematik Und Mechanik_ 54 (1): 39\u201351. doi:[10.1002/zamm.19740540106](https://doi.org/10.1002/zamm.19740540106).\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} stride - stride length\n* @returns {number} sum\n*\n* @example\n* var x = [ 1.0, -2.0, NaN, 2.0 ];\n* var N = x.length;\n*\n* var v = gnansumkbn( N, x, 1 );\n* // returns 1.0\n*/\nfunction gnansumkbn( N, x, stride ) {\n\tvar sum;\n\tvar ix;\n\tvar v;\n\tvar t;\n\tvar c;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn 0.0;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnan( 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\tsum = 0.0;\n\tc = 0.0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv = x[ ix ];\n\t\tif ( isnan( v ) === false ) {\n\t\t\tt = sum + v;\n\t\t\tif ( abs( sum ) >= abs( v ) ) {\n\t\t\t\tc += (sum-t) + v;\n\t\t\t} else {\n\t\t\t\tc += (v-t) + sum;\n\t\t\t}\n\t\t\tsum = t;\n\t\t}\n\t\tix += stride;\n\t}\n\treturn sum + c;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gnansumkbn;\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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar abs = require( '@stdlib/math-base-special-abs' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of strided array elements, ignoring `NaN` values and using an improved Kahan\u2013Babu\u0161ka algorithm.\n*\n* ## Method\n*\n* - This implementation uses an \"improved Kahan\u2013Babu\u0161ka algorithm\", as described by Neumaier (1974).\n*\n* ## References\n*\n* - Neumaier, Arnold. 1974. \"Rounding Error Analysis of Some Methods for Summing Finite Sums.\" _Zeitschrift F\u00FCr Angewandte Mathematik Und Mechanik_ 54 (1): 39\u201351. doi:[10.1002/zamm.19740540106](https://doi.org/10.1002/zamm.19740540106).\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @returns {number} sum\n*\n* @example\n* var floor = require( '@stdlib/math-base-special-floor' );\n*\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n* var N = floor( x.length / 2 );\n*\n* var v = gnansumkbn( N, x, 2, 1 );\n* // returns 5.0\n*/\nfunction gnansumkbn( N, x, stride, offset ) {\n\tvar sum;\n\tvar ix;\n\tvar v;\n\tvar t;\n\tvar c;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn 0.0;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnan( x[ offset ] ) ) {\n\t\t\treturn 0.0;\n\t\t}\n\t\treturn x[ offset ];\n\t}\n\tix = offset;\n\tsum = 0.0;\n\tc = 0.0;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv = x[ ix ];\n\t\tif ( isnan( v ) === false ) {\n\t\t\tt = sum + v;\n\t\t\tif ( abs( sum ) >= abs( v ) ) {\n\t\t\t\tc += (sum-t) + v;\n\t\t\t} else {\n\t\t\t\tc += (v-t) + sum;\n\t\t\t}\n\t\t\tsum = t;\n\t\t}\n\t\tix += stride;\n\t}\n\treturn sum + c;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gnansumkbn;\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 strided array elements, ignoring `NaN` values and using an improved Kahan\u2013Babu\u0161ka algorithm.\n*\n* @module @stdlib/blas-ext-base-gnansumkbn\n*\n* @example\n* var gnansumkbn = require( '@stdlib/blas-ext-base-gnansumkbn' );\n*\n* var x = [ 1.0, -2.0, NaN, 2.0 ];\n* var N = x.length;\n*\n* var v = gnansumkbn( N, x, 1 );\n* // returns 1.0\n*\n* @example\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var gnansumkbn = require( '@stdlib/blas-ext-base-gnansumkbn' );\n*\n* var x = [ 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 = gnansumkbn.ndarray( N, x, 2, 1 );\n* // returns 5.0\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAM,QAAS,+BAAgC,EA4BnD,SAASC,EAAYC,EAAGC,EAAGC,EAAS,CACnC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKR,GAAK,EACT,MAAO,GAER,GAAKA,IAAM,GAAKE,IAAW,EAC1B,OAAKL,EAAOI,EAAG,CAAE,CAAE,EACX,EAEDA,EAAG,CAAE,EASb,IAPKC,EAAS,EACbE,GAAM,EAAEJ,GAAKE,EAEbE,EAAK,EAEND,EAAM,EACNI,EAAI,EACEC,EAAI,EAAGA,EAAIR,EAAGQ,IACnBH,EAAIJ,EAAGG,CAAG,EACLP,EAAOQ,CAAE,IAAM,KACnBC,EAAIH,EAAME,EACLP,EAAKK,CAAI,GAAKL,EAAKO,CAAE,EACzBE,GAAMJ,EAAIG,EAAKD,EAEfE,GAAMF,EAAEC,EAAKH,EAEdA,EAAMG,GAEPF,GAAMF,EAEP,OAAOC,EAAMI,CACd,CAKAX,EAAO,QAAUG,IC9FjB,IAAAU,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAM,QAAS,+BAAgC,EA+BnD,SAASC,EAAYC,EAAGC,EAAGC,EAAQC,EAAS,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKT,GAAK,EACT,MAAO,GAER,GAAKA,IAAM,GAAKE,IAAW,EAC1B,OAAKL,EAAOI,EAAGE,CAAO,CAAE,EAChB,EAEDF,EAAGE,CAAO,EAKlB,IAHAE,EAAKF,EACLC,EAAM,EACNI,EAAI,EACEC,EAAI,EAAGA,EAAIT,EAAGS,IACnBH,EAAIL,EAAGI,CAAG,EACLR,EAAOS,CAAE,IAAM,KACnBC,EAAIH,EAAME,EACLR,EAAKM,CAAI,GAAKN,EAAKQ,CAAE,EACzBE,GAAMJ,EAAIG,EAAKD,EAEfE,GAAMF,EAAEC,EAAKH,EAEdA,EAAMG,GAEPF,GAAMH,EAEP,OAAOE,EAAMI,CACd,CAKAZ,EAAO,QAAUG,IC9CjB,IAAIW,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "abs", "gnansumkbn", "N", "x", "stride", "sum", "ix", "v", "t", "c", "i", "require_ndarray", "__commonJSMin", "exports", "module", "isnan", "abs", "gnansumkbn", "N", "x", "stride", "offset", "sum", "ix", "v", "t", "c", "i", "setReadOnly", "main", "ndarray"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
@@ -57,7 +57,7 @@ interface Routine {
|
|
|
57
57
|
* var v = gnansumkbn.ndarray( x.length, x, 1, 0 );
|
|
58
58
|
* // returns 1.0
|
|
59
59
|
*/
|
|
60
|
-
ndarray( N: number, x: NumericArray, stride: number, offset: number ): number;
|
|
60
|
+
ndarray( N: number, x: NumericArray, stride: number, offset: number ): number;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/blas-ext-base-gnansumkbn",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Calculate the sum of strided array elements, ignoring NaN values and using an improved Kahan–Babuška algorithm.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,21 +37,22 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/math-base-assert-is-nan": "^0.0
|
|
41
|
-
"@stdlib/math-base-special-abs": "^0.0
|
|
42
|
-
"@stdlib/types": "^0.
|
|
43
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0
|
|
40
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.0",
|
|
41
|
+
"@stdlib/math-base-special-abs": "^0.2.0",
|
|
42
|
+
"@stdlib/types": "^0.3.1",
|
|
43
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@stdlib/array-float64": "^0.
|
|
47
|
-
"@stdlib/
|
|
48
|
-
"@stdlib/math-base-special-
|
|
49
|
-
"@stdlib/math-base-special-
|
|
50
|
-
"@stdlib/
|
|
51
|
-
"@stdlib/random-base-randu": "^0.0.x",
|
|
46
|
+
"@stdlib/array-float64": "^0.1.1",
|
|
47
|
+
"@stdlib/math-base-special-floor": "^0.1.1",
|
|
48
|
+
"@stdlib/math-base-special-pow": "^0.1.0",
|
|
49
|
+
"@stdlib/math-base-special-round": "^0.1.1",
|
|
50
|
+
"@stdlib/random-base-randu": "^0.1.0",
|
|
52
51
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
53
52
|
"istanbul": "^0.4.1",
|
|
54
|
-
"tap-
|
|
53
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
54
|
+
"@stdlib/bench-harness": "^0.2.0",
|
|
55
|
+
"@stdlib/bench": "^0.3.1"
|
|
55
56
|
},
|
|
56
57
|
"engines": {
|
|
57
58
|
"node": ">=0.10.0",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
],
|
|
90
91
|
"__stdlib__": {},
|
|
91
92
|
"funding": {
|
|
92
|
-
"type": "
|
|
93
|
-
"url": "https://
|
|
93
|
+
"type": "opencollective",
|
|
94
|
+
"url": "https://opencollective.com/stdlib"
|
|
94
95
|
}
|
|
95
96
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( N, x, stride )
|
|
3
|
-
Computes the sum of strided array elements, ignoring `NaN` values and using
|
|
4
|
-
an improved Kahan–Babuška algorithm.
|
|
5
|
-
|
|
6
|
-
The `N` and `stride` parameters determine which elements in `x` are accessed
|
|
7
|
-
at runtime.
|
|
8
|
-
|
|
9
|
-
Indexing is relative to the first index. To introduce an offset, use a typed
|
|
10
|
-
array view.
|
|
11
|
-
|
|
12
|
-
If `N <= 0`, the function returns `0.0`.
|
|
13
|
-
|
|
14
|
-
Parameters
|
|
15
|
-
----------
|
|
16
|
-
N: integer
|
|
17
|
-
Number of indexed elements.
|
|
18
|
-
|
|
19
|
-
x: Array<number>|TypedArray
|
|
20
|
-
Input array.
|
|
21
|
-
|
|
22
|
-
stride: integer
|
|
23
|
-
Index increment.
|
|
24
|
-
|
|
25
|
-
Returns
|
|
26
|
-
-------
|
|
27
|
-
out: number
|
|
28
|
-
Sum.
|
|
29
|
-
|
|
30
|
-
Examples
|
|
31
|
-
--------
|
|
32
|
-
// Standard Usage:
|
|
33
|
-
> var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
34
|
-
> {{alias}}( x.length, x, 1 )
|
|
35
|
-
1.0
|
|
36
|
-
|
|
37
|
-
// Using `N` and `stride` parameters:
|
|
38
|
-
> x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ];
|
|
39
|
-
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
|
|
40
|
-
> var stride = 2;
|
|
41
|
-
> {{alias}}( N, x, stride )
|
|
42
|
-
1.0
|
|
43
|
-
|
|
44
|
-
// Using view offsets:
|
|
45
|
-
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] );
|
|
46
|
-
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
|
|
47
|
-
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
|
|
48
|
-
> stride = 2;
|
|
49
|
-
> {{alias}}( N, x1, stride )
|
|
50
|
-
-1.0
|
|
51
|
-
|
|
52
|
-
{{alias}}.ndarray( N, x, stride, offset )
|
|
53
|
-
Computes the sum of strided array elements, ignoring `NaN` values and using
|
|
54
|
-
an improved Kahan–Babuška algorithm and alternative indexing semantics.
|
|
55
|
-
|
|
56
|
-
While typed array views mandate a view offset based on the underlying
|
|
57
|
-
buffer, the `offset` parameter supports indexing semantics based on a
|
|
58
|
-
starting index.
|
|
59
|
-
|
|
60
|
-
Parameters
|
|
61
|
-
----------
|
|
62
|
-
N: integer
|
|
63
|
-
Number of indexed elements.
|
|
64
|
-
|
|
65
|
-
x: Array<number>|TypedArray
|
|
66
|
-
Input array.
|
|
67
|
-
|
|
68
|
-
stride: integer
|
|
69
|
-
Index increment.
|
|
70
|
-
|
|
71
|
-
offset: integer
|
|
72
|
-
Starting index.
|
|
73
|
-
|
|
74
|
-
Returns
|
|
75
|
-
-------
|
|
76
|
-
out: number
|
|
77
|
-
Sum.
|
|
78
|
-
|
|
79
|
-
Examples
|
|
80
|
-
--------
|
|
81
|
-
// Standard Usage:
|
|
82
|
-
> var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
83
|
-
> {{alias}}.ndarray( x.length, x, 1, 0 )
|
|
84
|
-
1.0
|
|
85
|
-
|
|
86
|
-
// Using offset parameter:
|
|
87
|
-
> var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ];
|
|
88
|
-
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
|
|
89
|
-
> {{alias}}.ndarray( N, x, 2, 1 )
|
|
90
|
-
-1.0
|
|
91
|
-
|
|
92
|
-
See Also
|
|
93
|
-
--------
|
|
94
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,155 +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
|
-
import gnansumkbn = require( './index' );
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// TESTS //
|
|
23
|
-
|
|
24
|
-
// The function returns a number...
|
|
25
|
-
{
|
|
26
|
-
const x = new Float64Array( 10 );
|
|
27
|
-
|
|
28
|
-
gnansumkbn( x.length, x, 1 ); // $ExpectType number
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// The compiler throws an error if the function is provided a first argument which is not a number...
|
|
32
|
-
{
|
|
33
|
-
const x = new Float64Array( 10 );
|
|
34
|
-
|
|
35
|
-
gnansumkbn( '10', x, 1 ); // $ExpectError
|
|
36
|
-
gnansumkbn( true, x, 1 ); // $ExpectError
|
|
37
|
-
gnansumkbn( false, x, 1 ); // $ExpectError
|
|
38
|
-
gnansumkbn( null, x, 1 ); // $ExpectError
|
|
39
|
-
gnansumkbn( undefined, x, 1 ); // $ExpectError
|
|
40
|
-
gnansumkbn( [], x, 1 ); // $ExpectError
|
|
41
|
-
gnansumkbn( {}, x, 1 ); // $ExpectError
|
|
42
|
-
gnansumkbn( ( x: number ): number => x, x, 1 ); // $ExpectError
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// The compiler throws an error if the function is provided a second argument which is not a numeric array...
|
|
46
|
-
{
|
|
47
|
-
const x = new Float64Array( 10 );
|
|
48
|
-
|
|
49
|
-
gnansumkbn( x.length, 10, 1 ); // $ExpectError
|
|
50
|
-
gnansumkbn( x.length, '10', 1 ); // $ExpectError
|
|
51
|
-
gnansumkbn( x.length, true, 1 ); // $ExpectError
|
|
52
|
-
gnansumkbn( x.length, false, 1 ); // $ExpectError
|
|
53
|
-
gnansumkbn( x.length, null, 1 ); // $ExpectError
|
|
54
|
-
gnansumkbn( x.length, undefined, 1 ); // $ExpectError
|
|
55
|
-
gnansumkbn( x.length, {}, 1 ); // $ExpectError
|
|
56
|
-
gnansumkbn( x.length, ( x: number ): number => x, 1 ); // $ExpectError
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// The compiler throws an error if the function is provided a third argument which is not a number...
|
|
60
|
-
{
|
|
61
|
-
const x = new Float64Array( 10 );
|
|
62
|
-
|
|
63
|
-
gnansumkbn( x.length, x, '10' ); // $ExpectError
|
|
64
|
-
gnansumkbn( x.length, x, true ); // $ExpectError
|
|
65
|
-
gnansumkbn( x.length, x, false ); // $ExpectError
|
|
66
|
-
gnansumkbn( x.length, x, null ); // $ExpectError
|
|
67
|
-
gnansumkbn( x.length, x, undefined ); // $ExpectError
|
|
68
|
-
gnansumkbn( x.length, x, [] ); // $ExpectError
|
|
69
|
-
gnansumkbn( x.length, x, {} ); // $ExpectError
|
|
70
|
-
gnansumkbn( x.length, x, ( x: number ): number => x ); // $ExpectError
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
74
|
-
{
|
|
75
|
-
const x = new Float64Array( 10 );
|
|
76
|
-
|
|
77
|
-
gnansumkbn(); // $ExpectError
|
|
78
|
-
gnansumkbn( x.length ); // $ExpectError
|
|
79
|
-
gnansumkbn( x.length, x ); // $ExpectError
|
|
80
|
-
gnansumkbn( x.length, x, 1, 10 ); // $ExpectError
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Attached to main export is an `ndarray` method which returns a number...
|
|
84
|
-
{
|
|
85
|
-
const x = new Float64Array( 10 );
|
|
86
|
-
|
|
87
|
-
gnansumkbn.ndarray( x.length, x, 1, 0 ); // $ExpectType number
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
|
|
91
|
-
{
|
|
92
|
-
const x = new Float64Array( 10 );
|
|
93
|
-
|
|
94
|
-
gnansumkbn.ndarray( '10', x, 1, 0 ); // $ExpectError
|
|
95
|
-
gnansumkbn.ndarray( true, x, 1, 0 ); // $ExpectError
|
|
96
|
-
gnansumkbn.ndarray( false, x, 1, 0 ); // $ExpectError
|
|
97
|
-
gnansumkbn.ndarray( null, x, 1, 0 ); // $ExpectError
|
|
98
|
-
gnansumkbn.ndarray( undefined, x, 1, 0 ); // $ExpectError
|
|
99
|
-
gnansumkbn.ndarray( [], x, 1, 0 ); // $ExpectError
|
|
100
|
-
gnansumkbn.ndarray( {}, x, 1, 0 ); // $ExpectError
|
|
101
|
-
gnansumkbn.ndarray( ( x: number ): number => x, x, 1, 0 ); // $ExpectError
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// The compiler throws an error if the `ndarray` method is provided a second argument which is not a numeric array...
|
|
105
|
-
{
|
|
106
|
-
const x = new Float64Array( 10 );
|
|
107
|
-
|
|
108
|
-
gnansumkbn.ndarray( x.length, 10, 1, 0 ); // $ExpectError
|
|
109
|
-
gnansumkbn.ndarray( x.length, '10', 1, 0 ); // $ExpectError
|
|
110
|
-
gnansumkbn.ndarray( x.length, true, 1, 0 ); // $ExpectError
|
|
111
|
-
gnansumkbn.ndarray( x.length, false, 1, 0 ); // $ExpectError
|
|
112
|
-
gnansumkbn.ndarray( x.length, null, 1, 0 ); // $ExpectError
|
|
113
|
-
gnansumkbn.ndarray( x.length, undefined, 1, 0 ); // $ExpectError
|
|
114
|
-
gnansumkbn.ndarray( x.length, {}, 1, 0 ); // $ExpectError
|
|
115
|
-
gnansumkbn.ndarray( x.length, ( x: number ): number => x, 1, 0 ); // $ExpectError
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number...
|
|
119
|
-
{
|
|
120
|
-
const x = new Float64Array( 10 );
|
|
121
|
-
|
|
122
|
-
gnansumkbn.ndarray( x.length, x, '10', 0 ); // $ExpectError
|
|
123
|
-
gnansumkbn.ndarray( x.length, x, true, 0 ); // $ExpectError
|
|
124
|
-
gnansumkbn.ndarray( x.length, x, false, 0 ); // $ExpectError
|
|
125
|
-
gnansumkbn.ndarray( x.length, x, null, 0 ); // $ExpectError
|
|
126
|
-
gnansumkbn.ndarray( x.length, x, undefined, 0 ); // $ExpectError
|
|
127
|
-
gnansumkbn.ndarray( x.length, x, [], 0 ); // $ExpectError
|
|
128
|
-
gnansumkbn.ndarray( x.length, x, {}, 0 ); // $ExpectError
|
|
129
|
-
gnansumkbn.ndarray( x.length, x, ( x: number ): number => x, 0 ); // $ExpectError
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
|
|
133
|
-
{
|
|
134
|
-
const x = new Float64Array( 10 );
|
|
135
|
-
|
|
136
|
-
gnansumkbn.ndarray( x.length, x, 1, '10' ); // $ExpectError
|
|
137
|
-
gnansumkbn.ndarray( x.length, x, 1, true ); // $ExpectError
|
|
138
|
-
gnansumkbn.ndarray( x.length, x, 1, false ); // $ExpectError
|
|
139
|
-
gnansumkbn.ndarray( x.length, x, 1, null ); // $ExpectError
|
|
140
|
-
gnansumkbn.ndarray( x.length, x, 1, undefined ); // $ExpectError
|
|
141
|
-
gnansumkbn.ndarray( x.length, x, 1, [] ); // $ExpectError
|
|
142
|
-
gnansumkbn.ndarray( x.length, x, 1, {} ); // $ExpectError
|
|
143
|
-
gnansumkbn.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments...
|
|
147
|
-
{
|
|
148
|
-
const x = new Float64Array( 10 );
|
|
149
|
-
|
|
150
|
-
gnansumkbn.ndarray(); // $ExpectError
|
|
151
|
-
gnansumkbn.ndarray( x.length ); // $ExpectError
|
|
152
|
-
gnansumkbn.ndarray( x.length, x ); // $ExpectError
|
|
153
|
-
gnansumkbn.ndarray( x.length, x, 1 ); // $ExpectError
|
|
154
|
-
gnansumkbn.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError
|
|
155
|
-
}
|