@stdlib/blas-ext-base-gnansumors 0.0.9 → 0.1.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/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 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
  # gnansumors
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] -->
@@ -180,12 +191,12 @@ console.log( v );
180
191
 
181
192
  ## See Also
182
193
 
183
- - <span class="package-name">[`@stdlib/blas/ext/base/dnansumors`][@stdlib/blas/ext/base/dnansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of double-precision floating-point strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
184
- - <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>
185
- - <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>
186
- - <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>
187
- - <span class="package-name">[`@stdlib/blas/ext/base/gsumors`][@stdlib/blas/ext/base/gsumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements using ordinary recursive summation.</span>
188
- - <span class="package-name">[`@stdlib/blas/ext/base/snansumors`][@stdlib/blas/ext/base/snansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
194
+ - <span class="package-name">[`@stdlib/blas-ext/base/dnansumors`][@stdlib/blas/ext/base/dnansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of double-precision floating-point strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
195
+ - <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>
196
+ - <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>
197
+ - <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>
198
+ - <span class="package-name">[`@stdlib/blas-ext/base/gsumors`][@stdlib/blas/ext/base/gsumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of strided array elements using ordinary recursive summation.</span>
199
+ - <span class="package-name">[`@stdlib/blas-ext/base/snansumors`][@stdlib/blas/ext/base/snansumors]</span><span class="delimiter">: </span><span class="description">calculate the sum of single-precision floating-point strided array elements, ignoring NaN values and using ordinary recursive summation.</span>
189
200
 
190
201
  </section>
191
202
 
@@ -217,7 +228,7 @@ See [LICENSE][stdlib-license].
217
228
 
218
229
  ## Copyright
219
230
 
220
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
231
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
221
232
 
222
233
  </section>
223
234
 
@@ -230,8 +241,8 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
230
241
  [npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-gnansumors.svg
231
242
  [npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-gnansumors
232
243
 
233
- [test-image]: https://github.com/stdlib-js/blas-ext-base-gnansumors/actions/workflows/test.yml/badge.svg?branch=v0.0.9
234
- [test-url]: https://github.com/stdlib-js/blas-ext-base-gnansumors/actions/workflows/test.yml?query=branch:v0.0.9
244
+ [test-image]: https://github.com/stdlib-js/blas-ext-base-gnansumors/actions/workflows/test.yml/badge.svg?branch=v0.1.0
245
+ [test-url]: https://github.com/stdlib-js/blas-ext-base-gnansumors/actions/workflows/test.yml?query=branch:v0.1.0
235
246
 
236
247
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gnansumors/main.svg
237
248
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gnansumors?branch=main
@@ -244,7 +255,7 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
244
255
  -->
245
256
 
246
257
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
247
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
258
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
248
259
 
249
260
  [stdlib]: https://github.com/stdlib-js/stdlib
250
261
 
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import gnansumors from '../docs/types/index';
3
+ export = gnansumors;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var t=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var o=t(function(b,v){
2
+ var f=require('@stdlib/math-base-assert-is-nan/dist');function p(e,r,u){var a,n,i;if(n=0,e<=0)return n;if(e===1||u===0)return f(r[0])?n:r[0];for(u<0?a=(1-e)*u:a=0,i=0;i<e;i++)f(r[a])===!1&&(n+=r[a]),a+=u;return n}v.exports=p
3
+ });var l=t(function(h,q){
4
+ var c=require('@stdlib/math-base-assert-is-nan/dist');function y(e,r,u,a){var n,i,s;if(i=0,e<=0)return i;if(e===1||u===0)return c(r[a])?i:r[a];for(n=a,s=0;s<e;s++)c(r[n])===!1&&(i+=r[n]),n+=u;return i}q.exports=y
5
+ });var g=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),m=o(),O=l();g(m,"ndarray",O);module.exports=m;
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' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of strided array elements, ignoring `NaN` values and using ordinary recursive summation.\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 = gnansumors( N, x, 1 );\n* // returns 1.0\n*/\nfunction gnansumors( N, x, stride ) {\n\tvar ix;\n\tvar s;\n\tvar i;\n\n\ts = 0.0;\n\tif ( N <= 0 ) {\n\t\treturn s;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnan( x[ 0 ] ) ) {\n\t\t\treturn s;\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\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\ts += x[ ix ];\n\t\t}\n\t\tix += stride;\n\t}\n\treturn s;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gnansumors;\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' );\n\n\n// MAIN //\n\n/**\n* Computes the sum of strided array elements, ignoring `NaN` values and using ordinary recursive summation.\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 = gnansumors( N, x, 2, 1 );\n* // returns 5.0\n*/\nfunction gnansumors( N, x, stride, offset ) {\n\tvar ix;\n\tvar s;\n\tvar i;\n\n\ts = 0.0;\n\tif ( N <= 0 ) {\n\t\treturn s;\n\t}\n\tif ( N === 1 || stride === 0 ) {\n\t\tif ( isnan( x[ offset ] ) ) {\n\t\t\treturn s;\n\t\t}\n\t\treturn x[ offset ];\n\t}\n\tix = offset;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( isnan( x[ ix ] ) === false ) {\n\t\t\ts += x[ ix ];\n\t\t}\n\t\tix += stride;\n\t}\n\treturn s;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gnansumors;\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 ordinary recursive summation.\n*\n* @module @stdlib/blas-ext-base-gnansumors\n*\n* @example\n* var gnansumors = require( '@stdlib/blas-ext-base-gnansumors' );\n*\n* var x = [ 1.0, -2.0, NaN, 2.0 ];\n* var N = x.length;\n*\n* var v = gnansumors( N, x, 1 );\n* // returns 1.0\n*\n* @example\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var gnansumors = require( '@stdlib/blas-ext-base-gnansumors' );\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 = gnansumors.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,EAoBvD,SAASC,EAAYC,EAAGC,EAAGC,EAAS,CACnC,IAAIC,EACAC,EACA,EAGJ,GADAA,EAAI,EACCJ,GAAK,EACT,OAAOI,EAER,GAAKJ,IAAM,GAAKE,IAAW,EAC1B,OAAKJ,EAAOG,EAAG,CAAE,CAAE,EACXG,EAEDH,EAAG,CAAE,EAOb,IALKC,EAAS,EACbC,GAAM,EAAEH,GAAKE,EAEbC,EAAK,EAEA,EAAI,EAAG,EAAIH,EAAG,IACdF,EAAOG,EAAGE,CAAG,CAAE,IAAM,KACzBC,GAAKH,EAAGE,CAAG,GAEZA,GAAMD,EAEP,OAAOE,CACR,CAKAP,EAAO,QAAUE,IC1EjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EAuBvD,SAASC,EAAYC,EAAGC,EAAGC,EAAQC,EAAS,CAC3C,IAAIC,EACAC,EACAC,EAGJ,GADAD,EAAI,EACCL,GAAK,EACT,OAAOK,EAER,GAAKL,IAAM,GAAKE,IAAW,EAC1B,OAAKJ,EAAOG,EAAGE,CAAO,CAAE,EAChBE,EAEDJ,EAAGE,CAAO,EAGlB,IADAC,EAAKD,EACCG,EAAI,EAAGA,EAAIN,EAAGM,IACdR,EAAOG,EAAGG,CAAG,CAAE,IAAM,KACzBC,GAAKJ,EAAGG,CAAG,GAEZA,GAAMF,EAEP,OAAOG,CACR,CAKAR,EAAO,QAAUE,IC1BjB,IAAIQ,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isnan", "gnansumors", "N", "x", "stride", "ix", "s", "require_ndarray", "__commonJSMin", "exports", "module", "isnan", "gnansumors", "N", "x", "stride", "offset", "ix", "s", "i", "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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-gnansumors",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "Calculate the sum of strided array elements, ignoring NaN values and using ordinary recursive summation.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,20 +37,20 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
41
- "@stdlib/types": "^0.0.x",
42
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x"
40
+ "@stdlib/math-base-assert-is-nan": "^0.1.0",
41
+ "@stdlib/types": "^0.1.0",
42
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@stdlib/array-float64": "^0.0.x",
46
- "@stdlib/bench": "^0.0.x",
47
- "@stdlib/math-base-special-floor": "^0.0.x",
48
- "@stdlib/math-base-special-pow": "^0.0.x",
49
- "@stdlib/math-base-special-round": "^0.0.x",
50
- "@stdlib/random-base-randu": "^0.0.x",
45
+ "@stdlib/array-float64": "^0.0.6",
46
+ "@stdlib/bench": "^0.1.0",
47
+ "@stdlib/math-base-special-floor": "^0.0.8",
48
+ "@stdlib/math-base-special-pow": "^0.0.7",
49
+ "@stdlib/math-base-special-round": "^0.1.0",
50
+ "@stdlib/random-base-randu": "^0.0.8",
51
51
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
52
52
  "istanbul": "^0.4.1",
53
- "tap-spec": "5.x.x"
53
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">=0.10.0",
@@ -86,7 +86,7 @@
86
86
  ],
87
87
  "__stdlib__": {},
88
88
  "funding": {
89
- "type": "patreon",
90
- "url": "https://www.patreon.com/athan"
89
+ "type": "opencollective",
90
+ "url": "https://opencollective.com/stdlib"
91
91
  }
92
92
  }
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
- ordinary recursive summation.
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
- ordinary recursive summation 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
-
@@ -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 gnansumors = require( './index' );
20
-
21
-
22
- // TESTS //
23
-
24
- // The function returns a number...
25
- {
26
- const x = new Float64Array( 10 );
27
-
28
- gnansumors( 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
- gnansumors( '10', x, 1 ); // $ExpectError
36
- gnansumors( true, x, 1 ); // $ExpectError
37
- gnansumors( false, x, 1 ); // $ExpectError
38
- gnansumors( null, x, 1 ); // $ExpectError
39
- gnansumors( undefined, x, 1 ); // $ExpectError
40
- gnansumors( [], x, 1 ); // $ExpectError
41
- gnansumors( {}, x, 1 ); // $ExpectError
42
- gnansumors( ( 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
- gnansumors( x.length, 10, 1 ); // $ExpectError
50
- gnansumors( x.length, '10', 1 ); // $ExpectError
51
- gnansumors( x.length, true, 1 ); // $ExpectError
52
- gnansumors( x.length, false, 1 ); // $ExpectError
53
- gnansumors( x.length, null, 1 ); // $ExpectError
54
- gnansumors( x.length, undefined, 1 ); // $ExpectError
55
- gnansumors( x.length, {}, 1 ); // $ExpectError
56
- gnansumors( 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
- gnansumors( x.length, x, '10' ); // $ExpectError
64
- gnansumors( x.length, x, true ); // $ExpectError
65
- gnansumors( x.length, x, false ); // $ExpectError
66
- gnansumors( x.length, x, null ); // $ExpectError
67
- gnansumors( x.length, x, undefined ); // $ExpectError
68
- gnansumors( x.length, x, [] ); // $ExpectError
69
- gnansumors( x.length, x, {} ); // $ExpectError
70
- gnansumors( 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
- gnansumors(); // $ExpectError
78
- gnansumors( x.length ); // $ExpectError
79
- gnansumors( x.length, x ); // $ExpectError
80
- gnansumors( 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
- gnansumors.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
- gnansumors.ndarray( '10', x, 1, 0 ); // $ExpectError
95
- gnansumors.ndarray( true, x, 1, 0 ); // $ExpectError
96
- gnansumors.ndarray( false, x, 1, 0 ); // $ExpectError
97
- gnansumors.ndarray( null, x, 1, 0 ); // $ExpectError
98
- gnansumors.ndarray( undefined, x, 1, 0 ); // $ExpectError
99
- gnansumors.ndarray( [], x, 1, 0 ); // $ExpectError
100
- gnansumors.ndarray( {}, x, 1, 0 ); // $ExpectError
101
- gnansumors.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
- gnansumors.ndarray( x.length, 10, 1, 0 ); // $ExpectError
109
- gnansumors.ndarray( x.length, '10', 1, 0 ); // $ExpectError
110
- gnansumors.ndarray( x.length, true, 1, 0 ); // $ExpectError
111
- gnansumors.ndarray( x.length, false, 1, 0 ); // $ExpectError
112
- gnansumors.ndarray( x.length, null, 1, 0 ); // $ExpectError
113
- gnansumors.ndarray( x.length, undefined, 1, 0 ); // $ExpectError
114
- gnansumors.ndarray( x.length, {}, 1, 0 ); // $ExpectError
115
- gnansumors.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
- gnansumors.ndarray( x.length, x, '10', 0 ); // $ExpectError
123
- gnansumors.ndarray( x.length, x, true, 0 ); // $ExpectError
124
- gnansumors.ndarray( x.length, x, false, 0 ); // $ExpectError
125
- gnansumors.ndarray( x.length, x, null, 0 ); // $ExpectError
126
- gnansumors.ndarray( x.length, x, undefined, 0 ); // $ExpectError
127
- gnansumors.ndarray( x.length, x, [], 0 ); // $ExpectError
128
- gnansumors.ndarray( x.length, x, {}, 0 ); // $ExpectError
129
- gnansumors.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
- gnansumors.ndarray( x.length, x, 1, '10' ); // $ExpectError
137
- gnansumors.ndarray( x.length, x, 1, true ); // $ExpectError
138
- gnansumors.ndarray( x.length, x, 1, false ); // $ExpectError
139
- gnansumors.ndarray( x.length, x, 1, null ); // $ExpectError
140
- gnansumors.ndarray( x.length, x, 1, undefined ); // $ExpectError
141
- gnansumors.ndarray( x.length, x, 1, [] ); // $ExpectError
142
- gnansumors.ndarray( x.length, x, 1, {} ); // $ExpectError
143
- gnansumors.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
- gnansumors.ndarray(); // $ExpectError
151
- gnansumors.ndarray( x.length ); // $ExpectError
152
- gnansumors.ndarray( x.length, x ); // $ExpectError
153
- gnansumors.ndarray( x.length, x, 1 ); // $ExpectError
154
- gnansumors.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError
155
- }