@stdlib/blas-ext-base-gcusumors 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 +40 -2
- package/lib/index.js +9 -2
- package/lib/main.js +44 -8
- package/package.json +1 -1
- package/lib/gcusumors.js +0 -71
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
|
# gcusumors
|
|
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 ordinary recursive summation.
|
|
26
26
|
|
|
@@ -196,6 +196,25 @@ console.log( y );
|
|
|
196
196
|
|
|
197
197
|
<!-- /.references -->
|
|
198
198
|
|
|
199
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
200
|
+
|
|
201
|
+
<section class="related">
|
|
202
|
+
|
|
203
|
+
* * *
|
|
204
|
+
|
|
205
|
+
## See Also
|
|
206
|
+
|
|
207
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/dcusumors`][@stdlib/blas/ext/base/dcusumors]</span><span class="delimiter">: </span><span class="description">calculate the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation.</span>
|
|
208
|
+
- <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>
|
|
209
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/gcusumpw`][@stdlib/blas/ext/base/gcusumpw]</span><span class="delimiter">: </span><span class="description">calculate the cumulative sum of strided array elements using pairwise summation.</span>
|
|
210
|
+
- <span class="package-name">[`@stdlib/blas/ext/base/scusumors`][@stdlib/blas/ext/base/scusumors]</span><span class="delimiter">: </span><span class="description">calculate the cumulative sum of single-precision floating-point strided array elements using ordinary recursive summation.</span>
|
|
211
|
+
|
|
212
|
+
</section>
|
|
213
|
+
|
|
214
|
+
<!-- /.related -->
|
|
215
|
+
|
|
216
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
217
|
+
|
|
199
218
|
|
|
200
219
|
<section class="main-repo" >
|
|
201
220
|
|
|
@@ -220,7 +239,7 @@ See [LICENSE][stdlib-license].
|
|
|
220
239
|
|
|
221
240
|
## Copyright
|
|
222
241
|
|
|
223
|
-
Copyright © 2016-
|
|
242
|
+
Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
224
243
|
|
|
225
244
|
</section>
|
|
226
245
|
|
|
@@ -239,9 +258,20 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
239
258
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gcusumors/main.svg
|
|
240
259
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gcusumors?branch=main
|
|
241
260
|
|
|
261
|
+
<!--
|
|
262
|
+
|
|
242
263
|
[dependencies-image]: https://img.shields.io/david/stdlib-js/blas-ext-base-gcusumors.svg
|
|
243
264
|
[dependencies-url]: https://david-dm.org/stdlib-js/blas-ext-base-gcusumors/main
|
|
244
265
|
|
|
266
|
+
-->
|
|
267
|
+
|
|
268
|
+
[umd]: https://github.com/umdjs/umd
|
|
269
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
270
|
+
|
|
271
|
+
[deno-url]: https://github.com/stdlib-js/blas-ext-base-gcusumors/tree/deno
|
|
272
|
+
[umd-url]: https://github.com/stdlib-js/blas-ext-base-gcusumors/tree/umd
|
|
273
|
+
[esm-url]: https://github.com/stdlib-js/blas-ext-base-gcusumors/tree/esm
|
|
274
|
+
|
|
245
275
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
246
276
|
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
247
277
|
|
|
@@ -255,10 +285,18 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
255
285
|
|
|
256
286
|
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
|
|
257
287
|
|
|
288
|
+
<!-- <related-links> -->
|
|
289
|
+
|
|
258
290
|
[@stdlib/blas/ext/base/dcusumors]: https://www.npmjs.com/package/@stdlib/blas-ext-base-dcusumors
|
|
259
291
|
|
|
292
|
+
[@stdlib/blas/ext/base/gcusum]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gcusum
|
|
293
|
+
|
|
294
|
+
[@stdlib/blas/ext/base/gcusumpw]: https://www.npmjs.com/package/@stdlib/blas-ext-base-gcusumpw
|
|
295
|
+
|
|
260
296
|
[@stdlib/blas/ext/base/scusumors]: https://www.npmjs.com/package/@stdlib/blas-ext-base-scusumors
|
|
261
297
|
|
|
298
|
+
<!-- </related-links> -->
|
|
299
|
+
|
|
262
300
|
</section>
|
|
263
301
|
|
|
264
302
|
<!-- /.links -->
|
package/lib/index.js
CHANGED
|
@@ -46,9 +46,16 @@
|
|
|
46
46
|
|
|
47
47
|
// MODULES //
|
|
48
48
|
|
|
49
|
-
var
|
|
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 =
|
|
61
|
+
module.exports = main;
|
package/lib/main.js
CHANGED
|
@@ -18,16 +18,52 @@
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
// MODULES //
|
|
22
|
-
|
|
23
|
-
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
24
|
-
var gcusumors = require( './gcusumors.js' );
|
|
25
|
-
var ndarray = require( './ndarray.js' );
|
|
26
|
-
|
|
27
|
-
|
|
28
21
|
// MAIN //
|
|
29
22
|
|
|
30
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Computes the cumulative sum of strided array elements using ordinary recursive summation.
|
|
25
|
+
*
|
|
26
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
27
|
+
* @param {number} sum - initial sum
|
|
28
|
+
* @param {NumericArray} x - input array
|
|
29
|
+
* @param {integer} strideX - `x` stride length
|
|
30
|
+
* @param {NumericArray} y - output array
|
|
31
|
+
* @param {integer} strideY - `y` stride length
|
|
32
|
+
* @returns {NumericArray} output array
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
36
|
+
* var y = [ 0.0, 0.0, 0.0 ];
|
|
37
|
+
*
|
|
38
|
+
* var v = gcusumors( x.length, 0.0, x, 1, y, 1 );
|
|
39
|
+
* // returns [ 1.0, -1.0, 1.0 ]
|
|
40
|
+
*/
|
|
41
|
+
function gcusumors( N, sum, x, strideX, y, strideY ) {
|
|
42
|
+
var ix;
|
|
43
|
+
var iy;
|
|
44
|
+
var i;
|
|
45
|
+
|
|
46
|
+
if ( N <= 0 ) {
|
|
47
|
+
return y;
|
|
48
|
+
}
|
|
49
|
+
if ( strideX < 0 ) {
|
|
50
|
+
ix = (1-N) * strideX;
|
|
51
|
+
} else {
|
|
52
|
+
ix = 0;
|
|
53
|
+
}
|
|
54
|
+
if ( strideY < 0 ) {
|
|
55
|
+
iy = (1-N) * strideY;
|
|
56
|
+
} else {
|
|
57
|
+
iy = 0;
|
|
58
|
+
}
|
|
59
|
+
for ( i = 0; i < N; i++ ) {
|
|
60
|
+
sum += x[ ix ];
|
|
61
|
+
y[ iy ] = sum;
|
|
62
|
+
ix += strideX;
|
|
63
|
+
iy += strideY;
|
|
64
|
+
}
|
|
65
|
+
return y;
|
|
66
|
+
}
|
|
31
67
|
|
|
32
68
|
|
|
33
69
|
// EXPORTS //
|
package/package.json
CHANGED
package/lib/gcusumors.js
DELETED
|
@@ -1,71 +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
|
-
// MAIN //
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Computes the cumulative sum of strided array elements using ordinary recursive summation.
|
|
25
|
-
*
|
|
26
|
-
* @param {PositiveInteger} N - number of indexed elements
|
|
27
|
-
* @param {number} sum - initial sum
|
|
28
|
-
* @param {NumericArray} x - input array
|
|
29
|
-
* @param {integer} strideX - `x` stride length
|
|
30
|
-
* @param {NumericArray} y - output array
|
|
31
|
-
* @param {integer} strideY - `y` stride length
|
|
32
|
-
* @returns {NumericArray} output array
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* var x = [ 1.0, -2.0, 2.0 ];
|
|
36
|
-
* var y = [ 0.0, 0.0, 0.0 ];
|
|
37
|
-
*
|
|
38
|
-
* var v = gcusumors( x.length, 0.0, x, 1, y, 1 );
|
|
39
|
-
* // returns [ 1.0, -1.0, 1.0 ]
|
|
40
|
-
*/
|
|
41
|
-
function gcusumors( N, sum, x, strideX, y, strideY ) {
|
|
42
|
-
var ix;
|
|
43
|
-
var iy;
|
|
44
|
-
var i;
|
|
45
|
-
|
|
46
|
-
if ( N <= 0 ) {
|
|
47
|
-
return y;
|
|
48
|
-
}
|
|
49
|
-
if ( strideX < 0 ) {
|
|
50
|
-
ix = (1-N) * strideX;
|
|
51
|
-
} else {
|
|
52
|
-
ix = 0;
|
|
53
|
-
}
|
|
54
|
-
if ( strideY < 0 ) {
|
|
55
|
-
iy = (1-N) * strideY;
|
|
56
|
-
} else {
|
|
57
|
-
iy = 0;
|
|
58
|
-
}
|
|
59
|
-
for ( i = 0; i < N; i++ ) {
|
|
60
|
-
sum += x[ ix ];
|
|
61
|
-
y[ iy ] = sum;
|
|
62
|
-
ix += strideX;
|
|
63
|
-
iy += strideY;
|
|
64
|
-
}
|
|
65
|
-
return y;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// EXPORTS //
|
|
70
|
-
|
|
71
|
-
module.exports = gcusumors;
|