@stdlib/blas-ext-base-gcusumpw 0.0.10 → 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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2022 The Stdlib Authors.
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
  # gcusumpw
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] -->
@@ -210,9 +221,9 @@ console.log( y );
210
221
 
211
222
  ## See Also
212
223
 
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>
224
+ - <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>
225
+ - <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>
226
+ - <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
227
 
217
228
  </section>
218
229
 
@@ -244,7 +255,7 @@ See [LICENSE][stdlib-license].
244
255
 
245
256
  ## Copyright
246
257
 
247
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
258
+ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
248
259
 
249
260
  </section>
250
261
 
@@ -257,8 +268,8 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
257
268
  [npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-gcusumpw.svg
258
269
  [npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-gcusumpw
259
270
 
260
- [test-image]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/actions/workflows/test.yml/badge.svg?branch=v0.0.10
261
- [test-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/actions/workflows/test.yml?query=branch:v0.0.10
271
+ [test-image]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/actions/workflows/test.yml/badge.svg?branch=v0.2.0
272
+ [test-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/actions/workflows/test.yml?query=branch:v0.2.0
262
273
 
263
274
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gcusumpw/main.svg
264
275
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gcusumpw?branch=main
@@ -271,7 +282,7 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
271
282
  -->
272
283
 
273
284
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
274
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
285
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
275
286
 
276
287
  [stdlib]: https://github.com/stdlib-js/stdlib
277
288
 
@@ -281,8 +292,11 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
281
292
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
282
293
 
283
294
  [deno-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/tree/deno
295
+ [deno-readme]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/blob/deno/README.md
284
296
  [umd-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/tree/umd
297
+ [umd-readme]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/blob/umd/README.md
285
298
  [esm-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/tree/esm
299
+ [esm-readme]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/blob/esm/README.md
286
300
  [branches-url]: https://github.com/stdlib-js/blas-ext-base-gcusumpw/blob/main/branches.md
287
301
 
288
302
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/blas-ext-base-gcusumpw/main/LICENSE
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import gcusumpw from '../docs/types/index';
3
+ export = gcusumpw;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var m=function(r,a){return function(){return a||r((a={exports:{}}).exports,a),a.exports}};var s=m(function(S,x){
2
+ var B=require('@stdlib/math-base-special-floor/dist'),C=128;function l(r,a,i,n,t,u,e,f){var c,v,p,o,q;if(r<=0)return u;if(c=t,v=f,r<=C){for(p=0,q=0;q<r;q++)p+=i[c],u[v]=a+p,c+=n,v+=e;return u}return o=B(r/2),l(o,a,i,n,c,u,e,v),v+=(o-1)*e,l(r-o,u[v],i,n,c+o*n,u,e,v+e),u}x.exports=l
3
+ });var w=m(function(Z,g){
4
+ var E=s();function I(r,a,i,n,t,u){var e,f;return r<=0?t:(n<0?e=(1-r)*n:e=0,u<0?f=(1-r)*u:f=0,E(r,a,i,n,e,t,u,f))}g.exports=I
5
+ });var K=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),O=w(),L=s();K(O,"ndarray",L);module.exports=O;
6
+ /** @license Apache-2.0 */
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/ndarray.js", "../lib/main.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 floor = require( '@stdlib/math-base-special-floor' );\n\n\n// VARIABLES //\n\n// Blocksize for pairwise summation:\nvar BLOCKSIZE = 128;\n\n\n// MAIN //\n\n/**\n* Computes the cumulative sum of strided array elements using pairwise summation.\n*\n* ## Method\n*\n* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.\n*\n* ## References\n*\n* - Higham, Nicholas J. 1993. \"The Accuracy of Floating Point Summation.\" _SIAM Journal on Scientific Computing_ 14 (4): 783\u201399. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} sum - initial sum\n* @param {NumericArray} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting index for `x`\n* @param {NumericArray} y - output array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting index for `y`\n* @returns {NumericArray} output array\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 y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];\n* var N = floor( x.length / 2 );\n*\n* gcusumpw( N, 0.0, x, 2, 1, y, 1, 0 );\n* // y => [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction gcusumpw( N, sum, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar ix;\n\tvar iy;\n\tvar s;\n\tvar n;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tix = offsetX;\n\tiy = offsetY;\n\tif ( N <= BLOCKSIZE ) {\n\t\ts = 0.0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\ts += x[ ix ];\n\t\t\ty[ iy ] = sum + s;\n\t\t\tix += strideX;\n\t\t\tiy += strideY;\n\t\t}\n\t\treturn y;\n\t}\n\tn = floor( N/2 );\n\tgcusumpw( n, sum, x, strideX, ix, y, strideY, iy );\n\tiy += (n-1) * strideY;\n\tgcusumpw( N-n, y[ iy ], x, strideX, ix+(n*strideX), y, strideY, iy+strideY ); // eslint-disable-line max-len\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gcusumpw;\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 cusum = require( './ndarray.js' );\n\n\n// MAIN //\n\n/**\n* Computes the cumulative sum of strided array elements using pairwise summation.\n*\n* ## Method\n*\n* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.\n*\n* ## References\n*\n* - Higham, Nicholas J. 1993. \"The Accuracy of Floating Point Summation.\" _SIAM Journal on Scientific Computing_ 14 (4): 783\u201399. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} sum - initial sum\n* @param {NumericArray} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NumericArray} y - output array\n* @param {integer} strideY - `y` stride length\n* @returns {NumericArray} output array\n*\n* @example\n* var x = [ 1.0, -2.0, 2.0 ];\n* var y = [ 0.0, 0.0, 0.0 ];\n*\n* var v = gcusumpw( x.length, 0.0, x, 1, y, 1 );\n* // returns [ 1.0, -1.0, 1.0 ]\n*/\nfunction gcusumpw( N, sum, x, strideX, y, strideY ) {\n\tvar ix;\n\tvar iy;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tif ( strideX < 0 ) {\n\t\tix = (1-N) * strideX;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( strideY < 0 ) {\n\t\tiy = (1-N) * strideY;\n\t} else {\n\t\tiy = 0;\n\t}\n\treturn cusum( N, sum, x, strideX, ix, y, strideY, iy );\n}\n\n\n// EXPORTS //\n\nmodule.exports = gcusumpw;\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 cumulative sum of strided array elements using pairwise summation.\n*\n* @module @stdlib/blas-ext-base-gcusumpw\n*\n* @example\n* var gcusumpw = require( '@stdlib/blas-ext-base-gcusumpw' );\n*\n* var x = [ 1.0, -2.0, 2.0 ];\n* var y = [ 0.0, 0.0, 0.0 ];\n*\n* gcusumpw( x.length, 0.0, x, 1, y, 1 );\n* // y => [ 1.0, -1.0, 1.0 ]\n*\n* @example\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var gcusumpw = require( '@stdlib/blas-ext-base-gcusumpw' );\n*\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];\n* var N = floor( x.length / 2 );\n*\n* gcusumpw.ndarray( N, 0.0, x, 2, 1, y, 1, 0 );\n* // y => [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.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,EAMnDC,EAAY,IAoChB,SAASC,EAAUC,EAAGC,EAAKC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAAU,CACrE,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKZ,GAAK,EACT,OAAOK,EAIR,GAFAG,EAAKJ,EACLK,EAAKF,EACAP,GAAKF,EAAY,CAErB,IADAY,EAAI,EACEE,EAAI,EAAGA,EAAIZ,EAAGY,IACnBF,GAAKR,EAAGM,CAAG,EACXH,EAAGI,CAAG,EAAIR,EAAMS,EAChBF,GAAML,EACNM,GAAMH,EAEP,OAAOD,CACR,CACA,OAAAM,EAAId,EAAOG,EAAE,CAAE,EACfD,EAAUY,EAAGV,EAAKC,EAAGC,EAASK,EAAIH,EAAGC,EAASG,CAAG,EACjDA,IAAOE,EAAE,GAAKL,EACdP,EAAUC,EAAEW,EAAGN,EAAGI,CAAG,EAAGP,EAAGC,EAASK,EAAIG,EAAER,EAAUE,EAAGC,EAASG,EAAGH,CAAQ,EACpED,CACR,CAKAT,EAAO,QAAUG,IChGjB,IAAAc,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,IA+BZ,SAASC,EAAUC,EAAGC,EAAKC,EAAGC,EAASC,EAAGC,EAAU,CACnD,IAAIC,EACAC,EAEJ,OAAKP,GAAK,EACFI,GAEHD,EAAU,EACdG,GAAM,EAAEN,GAAKG,EAEbG,EAAK,EAEDD,EAAU,EACdE,GAAM,EAAEP,GAAKK,EAEbE,EAAK,EAECT,EAAOE,EAAGC,EAAKC,EAAGC,EAASG,EAAIF,EAAGC,EAASE,CAAG,EACtD,CAKAV,EAAO,QAAUE,IC5BjB,IAAIS,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
6
+ "names": ["require_ndarray", "__commonJSMin", "exports", "module", "floor", "BLOCKSIZE", "gcusumpw", "N", "sum", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "ix", "iy", "s", "n", "i", "require_main", "__commonJSMin", "exports", "module", "cusum", "gcusumpw", "N", "sum", "x", "strideX", "y", "strideY", "ix", "iy", "setReadOnly", "main", "ndarray"]
7
+ }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
@@ -44,7 +44,7 @@ interface Routine {
44
44
  * gcusumpw( x.length, 0.0, x, 1, y, 1 );
45
45
  * // y => [ 1.0, -1.0, 1.0 ]
46
46
  */
47
- ( N: number, sum: number, x: NumericArray, strideX: number, y: NumericArray, strideY: number ): NumericArray; // tslint:disable-line:max-line-length
47
+ ( N: number, sum: number, x: NumericArray, strideX: number, y: NumericArray, strideY: number ): NumericArray;
48
48
 
49
49
  /**
50
50
  * Computes the cumulative sum of strided array elements using pairwise summation and alternative indexing semantics.
@@ -66,7 +66,7 @@ interface Routine {
66
66
  * gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 );
67
67
  * // y => [ 1.0, -1.0, 1.0 ]
68
68
  */
69
- ndarray( N: number, sum: number, x: NumericArray, strideX: number, offsetX: number, y: NumericArray, strideY: number, offsetY: number ): NumericArray; // tslint:disable-line:max-line-length
69
+ ndarray( N: number, sum: number, x: NumericArray, strideX: number, offsetX: number, y: NumericArray, strideY: number, offsetY: number ): NumericArray;
70
70
  }
71
71
 
72
72
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-gcusumpw",
3
- "version": "0.0.10",
3
+ "version": "0.2.0",
4
4
  "description": "Calculate the cumulative sum of strided array elements using pairwise summation.",
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-special-floor": "^0.0.x",
41
- "@stdlib/types": "^0.0.x",
42
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x"
40
+ "@stdlib/math-base-special-floor": "^0.2.0",
41
+ "@stdlib/types": "^0.3.1",
42
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@stdlib/array-float64": "^0.0.x",
46
- "@stdlib/bench": "^0.0.x",
47
- "@stdlib/blas-ext-base-gfill": "^0.0.x",
48
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
49
- "@stdlib/math-base-special-pow": "^0.0.x",
50
- "@stdlib/math-base-special-round": "^0.0.x",
51
- "@stdlib/random-base-randu": "^0.0.x",
45
+ "@stdlib/array-float64": "^0.1.1",
46
+ "@stdlib/blas-ext-base-gfill": "^0.1.0",
47
+ "@stdlib/math-base-assert-is-nan": "^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-spec": "5.x.x"
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",
@@ -90,7 +91,7 @@
90
91
  ],
91
92
  "__stdlib__": {},
92
93
  "funding": {
93
- "type": "patreon",
94
- "url": "https://www.patreon.com/athan"
94
+ "type": "opencollective",
95
+ "url": "https://opencollective.com/stdlib"
95
96
  }
96
97
  }
package/docs/repl.txt DELETED
@@ -1,121 +0,0 @@
1
-
2
- {{alias}}( N, sum, x, strideX, y, strideY )
3
- Computes the cumulative sum of strided array elements using pairwise
4
- summation.
5
-
6
- The `N` and `stride` parameters determine which elements in `x` and `y` are
7
- accessed 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 `y` unchanged.
13
-
14
- Parameters
15
- ----------
16
- N: integer
17
- Number of indexed elements.
18
-
19
- sum: number
20
- Initial sum.
21
-
22
- x: Array<number>|TypedArray
23
- Input array.
24
-
25
- strideX: integer
26
- Index increment for `x`.
27
-
28
- y: Array<number>|TypedArray
29
- Output array.
30
-
31
- strideY: integer
32
- Index increment for `y`.
33
-
34
- Returns
35
- -------
36
- out: Array<number>|TypedArray
37
- Output array.
38
-
39
- Examples
40
- --------
41
- // Standard Usage:
42
- > var x = [ 1.0, -2.0, 2.0 ];
43
- > var y = [ 0.0, 0.0, 0.0 ];
44
- > {{alias}}( x.length, 0.0, x, 1, y, 1 )
45
- [ 1.0, -1.0, 1.0 ]
46
-
47
- // Using `N` and `stride` parameters:
48
- > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ];
49
- > y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
50
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
51
- > {{alias}}( N, 0.0, x, 2, y, 2 )
52
- [ -2.0, 0.0, -1.0, 0.0, 1.0, 0.0 ]
53
-
54
- // Using view offsets:
55
- > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
56
- > var y0 = new {{alias:@stdlib/array/float64}}( x0.length );
57
- > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
58
- > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 );
59
- > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
60
- > {{alias}}( N, 0.0, x1, 2, y1, 1 )
61
- <Float64Array>[ -2.0, 0.0, -1.0 ]
62
- > y0
63
- <Float64Array>[ 0.0, 0.0, 0.0, -2.0, 0.0, -1.0 ]
64
-
65
- {{alias}}.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY )
66
- Computes the cumulative sum of strided array elements using pairwise
67
- summation and alternative indexing semantics.
68
-
69
- While typed array views mandate a view offset based on the underlying
70
- buffer, the `offset` parameter supports indexing semantics based on a
71
- starting index.
72
-
73
- Parameters
74
- ----------
75
- N: integer
76
- Number of indexed elements.
77
-
78
- sum: number
79
- Initial sum.
80
-
81
- x: Array<number>|TypedArray
82
- Input array.
83
-
84
- strideX: integer
85
- Index increment for `x`.
86
-
87
- offsetX: integer
88
- Starting index for `x`.
89
-
90
- y: Array<number>|TypedArray
91
- Output array.
92
-
93
- strideY: integer
94
- Index increment for `y`.
95
-
96
- offsetY: integer
97
- Starting index for `y`.
98
-
99
- Returns
100
- -------
101
- out: Array<number>|TypedArray
102
- Output array.
103
-
104
- Examples
105
- --------
106
- // Standard Usage:
107
- > var x = [ 1.0, -2.0, 2.0 ];
108
- > var y = [ 0.0, 0.0, 0.0 ];
109
- > {{alias}}.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 )
110
- <Float64Array>[ 1.0, -1.0, 1.0 ]
111
-
112
- // Advanced indexing:
113
- > x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ];
114
- > y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
115
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
116
- > {{alias}}.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 )
117
- <Float64Array>[ 0.0, 0.0, 0.0, -1.0, 0.0, -2.0 ]
118
-
119
- See Also
120
- --------
121
-
@@ -1,280 +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 gcusumpw = require( './index' );
20
-
21
-
22
- // TESTS //
23
-
24
- // The function returns a numeric array...
25
- {
26
- const x = new Float64Array( 10 );
27
- const y = new Float64Array( 10 );
28
-
29
- gcusumpw( x.length, 0.0, x, 1, y, 1 ); // $ExpectType NumericArray
30
- }
31
-
32
- // The compiler throws an error if the function is provided a first argument which is not a number...
33
- {
34
- const x = new Float64Array( 10 );
35
- const y = new Float64Array( 10 );
36
-
37
- gcusumpw( '10', 0.0, x, 1, y, 1 ); // $ExpectError
38
- gcusumpw( true, 0.0, x, 1, y, 1 ); // $ExpectError
39
- gcusumpw( false, 0.0, x, 1, y, 1 ); // $ExpectError
40
- gcusumpw( null, 0.0, x, 1, y, 1 ); // $ExpectError
41
- gcusumpw( undefined, 0.0, x, 1, y, 1 ); // $ExpectError
42
- gcusumpw( [], 0.0, x, 1, y, 1 ); // $ExpectError
43
- gcusumpw( {}, 0.0, x, 1, y, 1 ); // $ExpectError
44
- gcusumpw( ( x: number ): number => x, 0.0, x, 1, y, 1 ); // $ExpectError
45
- }
46
-
47
- // The compiler throws an error if the function is provided a second argument which is not a number...
48
- {
49
- const x = new Float64Array( 10 );
50
- const y = new Float64Array( 10 );
51
-
52
- gcusumpw( x.length, '10', 0.0, x, 1, y, 1 ); // $ExpectError
53
- gcusumpw( x.length, true, 0.0, x, 1, y, 1 ); // $ExpectError
54
- gcusumpw( x.length, false, 0.0, x, 1, y, 1 ); // $ExpectError
55
- gcusumpw( x.length, null, 0.0, x, 1, y, 1 ); // $ExpectError
56
- gcusumpw( x.length, undefined, 0.0, x, 1, y, 1 ); // $ExpectError
57
- gcusumpw( x.length, [], 0.0, x, 1, y, 1 ); // $ExpectError
58
- gcusumpw( x.length, {}, 0.0, x, 1, y, 1 ); // $ExpectError
59
- gcusumpw( x.length, ( x: number ): number => x, 0.0, x, 1, y, 1 ); // $ExpectError
60
- }
61
-
62
- // The compiler throws an error if the function is provided a third argument which is not a numeric array...
63
- {
64
- const x = new Float64Array( 10 );
65
- const y = new Float64Array( 10 );
66
-
67
- gcusumpw( x.length, 0.0, 10, 1, y, 1 ); // $ExpectError
68
- gcusumpw( x.length, 0.0, '10', 1, y, 1 ); // $ExpectError
69
- gcusumpw( x.length, 0.0, true, 1, y, 1 ); // $ExpectError
70
- gcusumpw( x.length, 0.0, false, 1, y, 1 ); // $ExpectError
71
- gcusumpw( x.length, 0.0, null, 1, y, 1 ); // $ExpectError
72
- gcusumpw( x.length, 0.0, undefined, 1, y, 1 ); // $ExpectError
73
- gcusumpw( x.length, 0.0, [ '1' ], 1, y, 1 ); // $ExpectError
74
- gcusumpw( x.length, 0.0, {}, 1, y, 1 ); // $ExpectError
75
- gcusumpw( x.length, 0.0, ( x: number ): number => x, 1, y, 1 ); // $ExpectError
76
- }
77
-
78
- // The compiler throws an error if the function is provided a fourth argument which is not a number...
79
- {
80
- const x = new Float64Array( 10 );
81
- const y = new Float64Array( 10 );
82
-
83
- gcusumpw( x.length, 0.0, x, '10', y, 1 ); // $ExpectError
84
- gcusumpw( x.length, 0.0, x, true, y, 1 ); // $ExpectError
85
- gcusumpw( x.length, 0.0, x, false, y, 1 ); // $ExpectError
86
- gcusumpw( x.length, 0.0, x, null, y, 1 ); // $ExpectError
87
- gcusumpw( x.length, 0.0, x, undefined, y, 1 ); // $ExpectError
88
- gcusumpw( x.length, 0.0, x, [], y, 1 ); // $ExpectError
89
- gcusumpw( x.length, 0.0, x, {}, y, 1 ); // $ExpectError
90
- gcusumpw( x.length, 0.0, x, ( x: number ): number => x, y, 1 ); // $ExpectError
91
- }
92
-
93
- // The compiler throws an error if the function is provided a fifth argument which is not a numeric array...
94
- {
95
- const x = new Float64Array( 10 );
96
-
97
- gcusumpw( x.length, 0.0, x, 1, 10, 1 ); // $ExpectError
98
- gcusumpw( x.length, 0.0, x, 1, '10', 1 ); // $ExpectError
99
- gcusumpw( x.length, 0.0, x, 1, true, 1 ); // $ExpectError
100
- gcusumpw( x.length, 0.0, x, 1, false, 1 ); // $ExpectError
101
- gcusumpw( x.length, 0.0, x, 1, null, 1 ); // $ExpectError
102
- gcusumpw( x.length, 0.0, x, 1, undefined, 1 ); // $ExpectError
103
- gcusumpw( x.length, 0.0, x, 1, [ '1' ], 1 ); // $ExpectError
104
- gcusumpw( x.length, 0.0, x, 1, {}, 1 ); // $ExpectError
105
- gcusumpw( x.length, 0.0, x, 1, ( x: number ): number => x, 1 ); // $ExpectError
106
- }
107
-
108
- // The compiler throws an error if the function is provided a sixth argument which is not a number...
109
- {
110
- const x = new Float64Array( 10 );
111
- const y = new Float64Array( 10 );
112
-
113
- gcusumpw( x.length, 0.0, x, 1, y, '10' ); // $ExpectError
114
- gcusumpw( x.length, 0.0, x, 1, y, true ); // $ExpectError
115
- gcusumpw( x.length, 0.0, x, 1, y, false ); // $ExpectError
116
- gcusumpw( x.length, 0.0, x, 1, y, null ); // $ExpectError
117
- gcusumpw( x.length, 0.0, x, 1, y, undefined ); // $ExpectError
118
- gcusumpw( x.length, 0.0, x, 1, y, [] ); // $ExpectError
119
- gcusumpw( x.length, 0.0, x, 1, y, {} ); // $ExpectError
120
- gcusumpw( x.length, 0.0, x, 1, y, ( x: number ): number => x ); // $ExpectError
121
- }
122
-
123
- // The compiler throws an error if the function is provided an unsupported number of arguments...
124
- {
125
- const x = new Float64Array( 10 );
126
- const y = new Float64Array( 10 );
127
-
128
- gcusumpw(); // $ExpectError
129
- gcusumpw( x.length ); // $ExpectError
130
- gcusumpw( x.length, 0.0 ); // $ExpectError
131
- gcusumpw( x.length, 0.0, x ); // $ExpectError
132
- gcusumpw( x.length, 0.0, x, 1 ); // $ExpectError
133
- gcusumpw( x.length, 0.0, x, 1, y ); // $ExpectError
134
- gcusumpw( x.length, 0.0, x, 1, y, 1, 10 ); // $ExpectError
135
- }
136
-
137
- // Attached to main export is an `ndarray` method which returns a numeric array...
138
- {
139
- const x = new Float64Array( 10 );
140
- const y = new Float64Array( 10 );
141
-
142
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectType NumericArray
143
- }
144
-
145
- // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
146
- {
147
- const x = new Float64Array( 10 );
148
- const y = new Float64Array( 10 );
149
-
150
- gcusumpw.ndarray( '10', 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
151
- gcusumpw.ndarray( true, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
152
- gcusumpw.ndarray( false, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
153
- gcusumpw.ndarray( null, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
154
- gcusumpw.ndarray( undefined, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
155
- gcusumpw.ndarray( [], 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
156
- gcusumpw.ndarray( {}, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
157
- gcusumpw.ndarray( ( x: number ): number => x, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
158
- }
159
-
160
- // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number...
161
- {
162
- const x = new Float64Array( 10 );
163
- const y = new Float64Array( 10 );
164
-
165
- gcusumpw.ndarray( x.length, '10', 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
166
- gcusumpw.ndarray( x.length, true, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
167
- gcusumpw.ndarray( x.length, false, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
168
- gcusumpw.ndarray( x.length, null, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
169
- gcusumpw.ndarray( x.length, undefined, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
170
- gcusumpw.ndarray( x.length, [], 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
171
- gcusumpw.ndarray( x.length, {}, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
172
- gcusumpw.ndarray( x.length, ( x: number ): number => x, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectError
173
- }
174
-
175
- // The compiler throws an error if the `ndarray` method is provided a third argument which is not a numeric array...
176
- {
177
- const x = new Float64Array( 10 );
178
- const y = new Float64Array( 10 );
179
-
180
- gcusumpw.ndarray( x.length, 0.0, 10, 1, 0, y, 1, 0 ); // $ExpectError
181
- gcusumpw.ndarray( x.length, 0.0, '10', 1, 0, y, 1, 0 ); // $ExpectError
182
- gcusumpw.ndarray( x.length, 0.0, true, 1, 0, y, 1, 0 ); // $ExpectError
183
- gcusumpw.ndarray( x.length, 0.0, false, 1, 0, y, 1, 0 ); // $ExpectError
184
- gcusumpw.ndarray( x.length, 0.0, null, 1, 0, y, 1, 0 ); // $ExpectError
185
- gcusumpw.ndarray( x.length, 0.0, undefined, 1, 0, y, 1, 0 ); // $ExpectError
186
- gcusumpw.ndarray( x.length, 0.0, [ '1' ], 1, 0, y, 1, 0 ); // $ExpectError
187
- gcusumpw.ndarray( x.length, 0.0, {}, 1, 0, y, 1, 0 ); // $ExpectError
188
- gcusumpw.ndarray( x.length, 0.0, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError
189
- }
190
-
191
- // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
192
- {
193
- const x = new Float64Array( 10 );
194
- const y = new Float64Array( 10 );
195
-
196
- gcusumpw.ndarray( x.length, 0.0, x, '10', 0, y, 1, 0 ); // $ExpectError
197
- gcusumpw.ndarray( x.length, 0.0, x, true, 0, y, 1, 0 ); // $ExpectError
198
- gcusumpw.ndarray( x.length, 0.0, x, false, 0, y, 1, 0 ); // $ExpectError
199
- gcusumpw.ndarray( x.length, 0.0, x, null, 0, y, 1, 0 ); // $ExpectError
200
- gcusumpw.ndarray( x.length, 0.0, x, undefined, 0, y, 1, 0 ); // $ExpectError
201
- gcusumpw.ndarray( x.length, 0.0, x, [], 0, y, 1, 0 ); // $ExpectError
202
- gcusumpw.ndarray( x.length, 0.0, x, {}, 0, y, 1, 0 ); // $ExpectError
203
- gcusumpw.ndarray( x.length, 0.0, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError
204
- }
205
-
206
- // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number...
207
- {
208
- const x = new Float64Array( 10 );
209
- const y = new Float64Array( 10 );
210
-
211
- gcusumpw.ndarray( x.length, 0.0, x, 1, '10', y, 1, 0 ); // $ExpectError
212
- gcusumpw.ndarray( x.length, 0.0, x, 1, true, y, 1, 0 ); // $ExpectError
213
- gcusumpw.ndarray( x.length, 0.0, x, 1, false, y, 1, 0 ); // $ExpectError
214
- gcusumpw.ndarray( x.length, 0.0, x, 1, null, y, 1, 0 ); // $ExpectError
215
- gcusumpw.ndarray( x.length, 0.0, x, 1, undefined, y, 1, 0 ); // $ExpectError
216
- gcusumpw.ndarray( x.length, 0.0, x, 1, [], y, 1, 0 ); // $ExpectError
217
- gcusumpw.ndarray( x.length, 0.0, x, 1, {}, y, 1, 0 ); // $ExpectError
218
- gcusumpw.ndarray( x.length, 0.0, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError
219
- }
220
-
221
- // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a numeric array...
222
- {
223
- const x = new Float64Array( 10 );
224
-
225
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, 10, 1, 0 ); // $ExpectError
226
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, '10', 1, 0 ); // $ExpectError
227
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, true, 1, 0 ); // $ExpectError
228
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, false, 1, 0 ); // $ExpectError
229
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, null, 1, 0 ); // $ExpectError
230
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, undefined, 1, 0 ); // $ExpectError
231
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, [ '1' ], 1, 0 ); // $ExpectError
232
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, {}, 1, 0 ); // $ExpectError
233
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError
234
- }
235
-
236
- // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number...
237
- {
238
- const x = new Float64Array( 10 );
239
- const y = new Float64Array( 10 );
240
-
241
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, '10', 0 ); // $ExpectError
242
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, true, 0 ); // $ExpectError
243
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, false, 0 ); // $ExpectError
244
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, null, 0 ); // $ExpectError
245
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, undefined, 0 ); // $ExpectError
246
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, [], 0 ); // $ExpectError
247
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, {}, 0 ); // $ExpectError
248
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError
249
- }
250
-
251
- // The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number...
252
- {
253
- const x = new Float64Array( 10 );
254
- const y = new Float64Array( 10 );
255
-
256
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, '10' ); // $ExpectError
257
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, true ); // $ExpectError
258
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, false ); // $ExpectError
259
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, null ); // $ExpectError
260
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, undefined ); // $ExpectError
261
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, [] ); // $ExpectError
262
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, {} ); // $ExpectError
263
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError
264
- }
265
-
266
- // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments...
267
- {
268
- const x = new Float64Array( 10 );
269
- const y = new Float64Array( 10 );
270
-
271
- gcusumpw.ndarray(); // $ExpectError
272
- gcusumpw.ndarray( x.length ); // $ExpectError
273
- gcusumpw.ndarray( x.length, 0.0 ); // $ExpectError
274
- gcusumpw.ndarray( x.length, 0.0, x ); // $ExpectError
275
- gcusumpw.ndarray( x.length, 0.0, x, 1 ); // $ExpectError
276
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0 ); // $ExpectError
277
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y ); // $ExpectError
278
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1 ); // $ExpectError
279
- gcusumpw.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0, 10 ); // $ExpectError
280
- }