@stdlib/blas-ext-base-gcusumpw 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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2021 The Stdlib Authors.
1
+ Copyright (c) 2016-2022 The Stdlib Authors.
package/README.md CHANGED
@@ -20,7 +20,7 @@ limitations under the License.
20
20
 
21
21
  # gcusumpw
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 cumulative sum of strided array elements using pairwise summation.
26
26
 
@@ -202,6 +202,24 @@ console.log( y );
202
202
 
203
203
  <!-- /.references -->
204
204
 
205
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
206
+
207
+ <section class="related">
208
+
209
+ * * *
210
+
211
+ ## See Also
212
+
213
+ - <span class="package-name">[`@stdlib/blas/ext/base/dcusumpw`][@stdlib/blas/ext/base/dcusumpw]</span><span class="delimiter">: </span><span class="description">calculate the cumulative sum of double-precision floating-point strided array elements using pairwise summation.</span>
214
+ - <span class="package-name">[`@stdlib/blas/ext/base/gcusum`][@stdlib/blas/ext/base/gcusum]</span><span class="delimiter">: </span><span class="description">calculate the cumulative sum of strided array elements.</span>
215
+ - <span class="package-name">[`@stdlib/blas/ext/base/scusumpw`][@stdlib/blas/ext/base/scusumpw]</span><span class="delimiter">: </span><span class="description">calculate the cumulative sum of single-precision floating-point strided array elements using pairwise summation.</span>
216
+
217
+ </section>
218
+
219
+ <!-- /.related -->
220
+
221
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
222
+
205
223
 
206
224
  <section class="main-repo" >
207
225
 
@@ -226,7 +244,7 @@ See [LICENSE][stdlib-license].
226
244
 
227
245
  ## Copyright
228
246
 
229
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
247
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
230
248
 
231
249
  </section>
232
250
 
@@ -245,9 +263,20 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
245
263
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gcusumpw/main.svg
246
264
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gcusumpw?branch=main
247
265
 
266
+ <!--
267
+
248
268
  [dependencies-image]: https://img.shields.io/david/stdlib-js/blas-ext-base-gcusumpw.svg
249
269
  [dependencies-url]: https://david-dm.org/stdlib-js/blas-ext-base-gcusumpw/main
250
270
 
271
+ -->
272
+
273
+ [umd]: https://github.com/umdjs/umd
274
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
275
+
276
+ [deno-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/tree/deno
277
+ [umd-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/tree/umd
278
+ [esm-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/tree/esm
279
+
251
280
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
252
281
  [chat-url]: https://gitter.im/stdlib-js/stdlib/
253
282
 
@@ -261,11 +290,17 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
261
290
 
262
291
  [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
263
292
 
293
+ [@higham:1993a]: https://doi.org/10.1137/0914050
294
+
295
+ <!-- <related-links> -->
296
+
264
297
  [@stdlib/blas/ext/base/dcusumpw]: https://www.npmjs.com/package/@stdlib/blas-ext-base-dcusumpw
265
298
 
299
+ [@stdlib/blas/ext/base/gcusum]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gcusum
300
+
266
301
  [@stdlib/blas/ext/base/scusumpw]: https://www.npmjs.com/package/@stdlib/blas-ext-base-scusumpw
267
302
 
268
- [@higham:1993a]: https://doi.org/10.1137/0914050
303
+ <!-- </related-links> -->
269
304
 
270
305
  </section>
271
306
 
package/lib/index.js CHANGED
@@ -46,9 +46,16 @@
46
46
 
47
47
  // MODULES //
48
48
 
49
- var gcusumpw = require( './main.js' );
49
+ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
50
+ var main = require( './main.js' );
51
+ var ndarray = require( './ndarray.js' );
52
+
53
+
54
+ // MAIN //
55
+
56
+ setReadOnly( main, 'ndarray', ndarray );
50
57
 
51
58
 
52
59
  // EXPORTS //
53
60
 
54
- module.exports = gcusumpw;
61
+ module.exports = main;
package/lib/main.js CHANGED
@@ -20,14 +20,56 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
24
- var gcusumpw = require( './gcusumpw.js' );
25
- var ndarray = require( './ndarray.js' );
23
+ var cusum = require( './ndarray.js' );
26
24
 
27
25
 
28
26
  // MAIN //
29
27
 
30
- setReadOnly( gcusumpw, 'ndarray', ndarray );
28
+ /**
29
+ * Computes the cumulative sum of strided array elements using pairwise summation.
30
+ *
31
+ * ## Method
32
+ *
33
+ * - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.
34
+ *
35
+ * ## References
36
+ *
37
+ * - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).
38
+ *
39
+ * @param {PositiveInteger} N - number of indexed elements
40
+ * @param {number} sum - initial sum
41
+ * @param {NumericArray} x - input array
42
+ * @param {integer} strideX - `x` stride length
43
+ * @param {NumericArray} y - output array
44
+ * @param {integer} strideY - `y` stride length
45
+ * @returns {NumericArray} output array
46
+ *
47
+ * @example
48
+ * var x = [ 1.0, -2.0, 2.0 ];
49
+ * var y = [ 0.0, 0.0, 0.0 ];
50
+ *
51
+ * var v = gcusumpw( x.length, 0.0, x, 1, y, 1 );
52
+ * // returns [ 1.0, -1.0, 1.0 ]
53
+ */
54
+ function gcusumpw( N, sum, x, strideX, y, strideY ) {
55
+ var ix;
56
+ var iy;
57
+
58
+ if ( N <= 0 ) {
59
+ return y;
60
+ }
61
+ if ( strideX < 0 ) {
62
+ ix = (1-N) * strideX;
63
+ } else {
64
+ ix = 0;
65
+ }
66
+ if ( strideY < 0 ) {
67
+ iy = (1-N) * strideY;
68
+ } else {
69
+ iy = 0;
70
+ }
71
+ return cusum( N, sum, x, strideX, ix, y, strideY, iy );
72
+ }
31
73
 
32
74
 
33
75
  // EXPORTS //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-gcusumpw",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Calculate the cumulative sum of strided array elements using pairwise summation.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
package/lib/gcusumpw.js DELETED
@@ -1,77 +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 cusum = require( './ndarray.js' );
24
-
25
-
26
- // MAIN //
27
-
28
- /**
29
- * Computes the cumulative sum of strided array elements using pairwise summation.
30
- *
31
- * ## Method
32
- *
33
- * - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.
34
- *
35
- * ## References
36
- *
37
- * - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).
38
- *
39
- * @param {PositiveInteger} N - number of indexed elements
40
- * @param {number} sum - initial sum
41
- * @param {NumericArray} x - input array
42
- * @param {integer} strideX - `x` stride length
43
- * @param {NumericArray} y - output array
44
- * @param {integer} strideY - `y` stride length
45
- * @returns {NumericArray} output array
46
- *
47
- * @example
48
- * var x = [ 1.0, -2.0, 2.0 ];
49
- * var y = [ 0.0, 0.0, 0.0 ];
50
- *
51
- * var v = gcusumpw( x.length, 0.0, x, 1, y, 1 );
52
- * // returns [ 1.0, -1.0, 1.0 ]
53
- */
54
- function gcusumpw( N, sum, x, strideX, y, strideY ) {
55
- var ix;
56
- var iy;
57
-
58
- if ( N <= 0 ) {
59
- return y;
60
- }
61
- if ( strideX < 0 ) {
62
- ix = (1-N) * strideX;
63
- } else {
64
- ix = 0;
65
- }
66
- if ( strideY < 0 ) {
67
- iy = (1-N) * strideY;
68
- } else {
69
- iy = 0;
70
- }
71
- return cusum( N, sum, x, strideX, ix, y, strideY, iy );
72
- }
73
-
74
-
75
- // EXPORTS //
76
-
77
- module.exports = gcusumpw;