@stdlib/blas-ext-base-gcusumpw 0.0.3 → 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
 
@@ -108,7 +108,7 @@ var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th
108
108
  var N = floor( x0.length / 2 );
109
109
 
110
110
  gcusumpw( N, 0.0, x1, -2, y1, 1 );
111
- // y0 => <Float64Array>[ 0.0, 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0 ]
111
+ // y0 => <Float64Array>[ 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0, 0.0 ]
112
112
  ```
113
113
 
114
114
  #### gcusumpw.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY )
@@ -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
 
@@ -213,6 +231,10 @@ This package is part of [stdlib][stdlib], a standard library for JavaScript and
213
231
 
214
232
  For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
215
233
 
234
+ #### Community
235
+
236
+ [![Chat][chat-image]][chat-url]
237
+
216
238
  ---
217
239
 
218
240
  ## License
@@ -222,7 +244,7 @@ See [LICENSE][stdlib-license].
222
244
 
223
245
  ## Copyright
224
246
 
225
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
247
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
226
248
 
227
249
  </section>
228
250
 
@@ -241,9 +263,23 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
241
263
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gcusumpw/main.svg
242
264
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gcusumpw?branch=main
243
265
 
244
- [dependencies-image]: https://img.shields.io/david/stdlib-js/blas-ext-base-gcusumpw
266
+ <!--
267
+
268
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/blas-ext-base-gcusumpw.svg
245
269
  [dependencies-url]: https://david-dm.org/stdlib-js/blas-ext-base-gcusumpw/main
246
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
+
280
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
281
+ [chat-url]: https://gitter.im/stdlib-js/stdlib/
282
+
247
283
  [stdlib]: https://github.com/stdlib-js/stdlib
248
284
 
249
285
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
@@ -254,11 +290,17 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
254
290
 
255
291
  [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
256
292
 
257
- [@stdlib/blas/ext/base/dcusumpw]: https://github.com/stdlib-js/blas-ext-base-dcusumpw
293
+ [@higham:1993a]: https://doi.org/10.1137/0914050
258
294
 
259
- [@stdlib/blas/ext/base/scusumpw]: https://github.com/stdlib-js/blas-ext-base-scusumpw
295
+ <!-- <related-links> -->
260
296
 
261
- [@higham:1993a]: https://doi.org/10.1137/0914050
297
+ [@stdlib/blas/ext/base/dcusumpw]: https://www.npmjs.com/package/@stdlib/blas-ext-base-dcusumpw
298
+
299
+ [@stdlib/blas/ext/base/gcusum]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gcusum
300
+
301
+ [@stdlib/blas/ext/base/scusumpw]: https://www.npmjs.com/package/@stdlib/blas-ext-base-scusumpw
302
+
303
+ <!-- </related-links> -->
262
304
 
263
305
  </section>
264
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.3",
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": {
@@ -28,7 +28,7 @@
28
28
  "examples": "make examples",
29
29
  "benchmark": "make benchmark"
30
30
  },
31
- "homepage": "https://github.com/stdlib-js/stdlib",
31
+ "homepage": "https://stdlib.io",
32
32
  "repository": {
33
33
  "type": "git",
34
34
  "url": "git://github.com/stdlib-js/blas-ext-base-gcusumpw.git"
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # CHANGELOG
2
-
3
- > Package changelog.
4
-
5
- See [GitHub Releases](https://github.com/stdlib-js/blas-ext-base-gcusumpw/releases) for the changelog.
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;