From 067e428451925ef8ecd092aff87a679c841ccc99 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Sun, 7 Dec 2025 09:28:34 +0530 Subject: [PATCH 1/9] feat: add blas/ext/base/ndarray/zsumkbn --- .../blas/ext/base/ndarray/zsumkbn/README.md | 129 ++++++++++++ .../ndarray/zsumkbn/benchmark/benchmark.js | 107 ++++++++++ .../ext/base/ndarray/zsumkbn/docs/repl.txt | 32 +++ .../ndarray/zsumkbn/docs/types/index.d.ts | 47 +++++ .../base/ndarray/zsumkbn/docs/types/test.ts | 57 +++++ .../base/ndarray/zsumkbn/examples/index.js | 36 ++++ .../ext/base/ndarray/zsumkbn/lib/index.js | 45 ++++ .../blas/ext/base/ndarray/zsumkbn/lib/main.js | 56 +++++ .../ext/base/ndarray/zsumkbn/package.json | 71 +++++++ .../ext/base/ndarray/zsumkbn/test/test.js | 199 ++++++++++++++++++ 10 files changed, 779 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md new file mode 100644 index 000000000000..e0ef43b27a43 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md @@ -0,0 +1,129 @@ + + +# zsumkbn + +> Compute the sum of all elements in a one-dimensional double-precision complex +floating-point ndarray using an improved Kahan–Babuška algorithm. + +
+ +
+ + + +
+ +## Usage + +```javascript +var zsumkbn = require( '@stdlib/blas/ext/base/ndarray/zsumkbn' ); +``` + +#### zsumkbn( arrays ) + +Computes the sum of all elements in a one-dimensional double-precision complex +floating-point ndarray using an improved Kahan–Babuška algorithm. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var xbuf = new Complex128Array( [ 1.0, 3.0, 4.0, 2.0 ] ); +var x = new ndarray( 'complex128', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); + +var v = zsumkbn( [ x ] ); +// returns [ 5.0, 5.0 ] +``` + +The function has the following parameters: + +- **arrays**: array-like object containing a one-dimensional input ndarray. + +
+ + + +
+ +## Notes + +- If provided an empty one-dimensional ndarray, the function returns `0.0 + 0.0i`. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zsumkbn = require( '@stdlib/blas/ext/base/ndarray/zsumkbn' ); + +var xbuf = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); +xbuf = new Complex128Array( xbuf ); + +var x = new ndarray( 'complex128', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var v = zsumkbn( [ x ] ); +console.log( v ); +``` + +
+ + + +
+ +## References + +- Neumaier, Arnold. 1974. "Rounding Error Analysis of Some Methods for Summing Finite Sums." _Zeitschrift Für Angewandte Mathematik Und Mechanik_ 54 (1): 39–51. doi:[10.1002/zamm.19740540106][@neumaier:1974a]. + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js new file mode 100644 index 000000000000..35ba82cc5d1b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var pkg = require( './../package.json' ).name; +var zsumkbn = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'complex128' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark(len) { + var xbuf; + var x; + + xbuf = uniform(len * 2, -10.0, 10.0, { + 'dtype': 'float64' + }); + x = new ndarray(options.dtype, new Complex128Array(xbuf), [len], [1], 0, 'row-major'); + + return benchmark; + + function benchmark(b) { + var v; + var i; + + b.tic(); + for (i = 0; i < b.iterations; i++) { + v = zsumkbn([x]); + if (isnan(real(v))) { + b.fail('should not return NaN'); + } + } + b.toc(); + if (isnan(imag(v))) { + b.fail('should not return NaN'); + } + b.pass('benchmark finished'); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for (i = min; i <= max; i++) { + len = pow(10, i); + f = createBenchmark(len); + bench(pkg + ':len=' + len, f); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt new file mode 100644 index 000000000000..805cd283a867 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( arrays ) + Computes the sum of all elements in a one-dimensional double-precision + complex floating-point ndarray using an improved Kahan–Babuška algorithm. + + If provided an empty ndarray, the function returns `0.0 + 0.0i`. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing a one-dimensional input ndarray. + + Returns + ------- + out: Complex128 + Sum. + + Examples + -------- + > var xbuf = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var dt = 'complex128'; + > var sh = [ xbuf.length ]; + > var sx = [ 1 ]; + > var ox = 0; + > var ord = 'row-major'; + > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); + > {{alias}}( [ x ] ) + [ 4.0, 6.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts new file mode 100644 index 000000000000..8a436a5999fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts @@ -0,0 +1,47 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { complex128ndarray } from '@stdlib/types/ndarray'; +import { Complex128 } from '@stdlib/types/complex'; + +/** +* Computes the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm. +* +* @param arrays - array-like object containing an input ndarray +* @returns sum +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Complex128Array( [ 1.0, 3.0, 4.0, 2.0 ] ); +* var x = new ndarray( 'complex128', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); +* +* var v = zsumkbn( [ x ] ); +* // returns [ 5.0, 5.0 ] +*/ +declare function zsumkbn(arrays: [complex128ndarray]): Complex128; + + +// EXPORTS // + +export = zsumkbn; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts new file mode 100644 index 000000000000..f76175ef25a3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts @@ -0,0 +1,57 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import zsumkbn = require( './index' ); + + +// TESTS // + +// The function returns a complex number... +{ + const x = zeros([10], { + 'dtype': 'complex128' + }); + + zsumkbn([x]); // $ExpectType Complex128 +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + zsumkbn('10'); // $ExpectError + zsumkbn(10); // $ExpectError + zsumkbn(true); // $ExpectError + zsumkbn(false); // $ExpectError + zsumkbn(null); // $ExpectError + zsumkbn(undefined); // $ExpectError + zsumkbn([]); // $ExpectError + zsumkbn({}); // $ExpectError + zsumkbn((x: number): number => x); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros([10], { + 'dtype': 'complex128' + }); + + zsumkbn(); // $ExpectError + zsumkbn([x], {}); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js new file mode 100644 index 000000000000..0e19d7efdd10 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zsumkbn = require( './../lib' ); + +var xbuf = discreteUniform(10, -50, 50, { + 'dtype': 'float64' +}); +xbuf = new Complex128Array(xbuf); + +var x = new ndarray('complex128', xbuf, [xbuf.length], [1], 0, 'row-major'); +console.log(ndarray2array(x)); + +var v = zsumkbn([x]); +console.log(v); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/index.js new file mode 100644 index 000000000000..c25cbefd4bb8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm. +* +* @module @stdlib/blas/ext/base/ndarray/zsumkbn +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var zsumkbn = require( '@stdlib/blas/ext/base/ndarray/zsumkbn' ); +* +* var xbuf = new Complex128Array( [ 1.0, 3.0, 4.0, 2.0 ] ); +* var x = new ndarray( 'complex128', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); +* +* var v = zsumkbn( [ x ] ); +* // returns [ 5.0, 5.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js new file mode 100644 index 000000000000..75e7c9a6060d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/blas/ext/base/zsumkbn' ).ndarray; + + +// MAIN // + +/** +* Computes the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm. +* +* @param {ArrayLikeObject} arrays - array-like object containing an input ndarray +* @returns {Complex128} sum +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Complex128Array( [ 1.0, 3.0, 4.0, 2.0 ] ); +* var x = new ndarray( 'complex128', xbuf, [ 2 ], [ 1 ], 0, 'row-major' ); +* +* var v = zsumkbn( [ x ] ); +* // returns [ 5.0, 5.0 ] +*/ +function zsumkbn(arrays) { + var x = arrays[0]; + return strided(numelDimension(x, 0), getData(x), getStride(x, 0), getOffset(x)); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = zsumkbn; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/package.json new file mode 100644 index 000000000000..f7b0f35d5303 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/zsumkbn", + "version": "0.0.0", + "description": "Compute the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "blas", + "extended", + "sum", + "total", + "summation", + "compensated", + "kahan", + "kbn", + "complex128", + "complex", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js new file mode 100644 index 000000000000..de17a9ddee32 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js @@ -0,0 +1,199 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameComplex128 = require( '@stdlib/assert/is-same-complex128' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var zsumkbn = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Complex128Array} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector(buffer, length, stride, offset) { + return new ndarray('complex128', buffer, [length], [stride], offset, 'row-major'); +} + + +// TESTS // + +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof zsumkbn, 'function', 'main export is a function'); + t.end(); +}); + +tape('the function has an arity of 1', function test(t) { + t.strictEqual(zsumkbn.length, 1, 'has expected arity'); + t.end(); +}); + +tape('the function computes the sum of all elements in a one-dimensional ndarray using an improved Kahan–Babuška algorithm', function test(t) { + var x; + var v; + + x = new Complex128Array([1.0, -2.0, -4.0, 5.0, 0.0, 3.0]); + v = zsumkbn([vector(x, 3, 1, 0)]); + t.strictEqual(isSameComplex128(v, new Complex128(-3.0, 6.0)), true, 'returns expected value'); + + x = new Complex128Array([-4.0, -5.0, -4.0, -5.0]); + v = zsumkbn([vector(x, 2, 1, 0)]); + t.strictEqual(isSameComplex128(v, new Complex128(-8.0, -10.0)), true, 'returns expected value'); + + x = new Complex128Array([-0.0, 0.0, -0.0, -0.0]); + v = zsumkbn([vector(x, 2, 1, 0)]); + t.strictEqual(isSameComplex128(v, new Complex128(-0.0, 0.0)), true, 'returns expected value'); + + x = new Complex128Array([NaN, NaN]); + v = zsumkbn([vector(x, 1, 1, 0)]); + t.strictEqual(isSameComplex128(v, new Complex128(NaN, NaN)), true, 'returns expected value'); + + x = new Complex128Array([NaN, NaN, NaN, NaN]); + v = zsumkbn([vector(x, 2, 1, 0)]); + t.strictEqual(isSameComplex128(v, new Complex128(NaN, NaN)), true, 'returns expected value'); + + t.end(); +}); + +tape('if provided an empty ndarray, the function returns `0.0 + 0.0i`', function test(t) { + var x; + var v; + + x = new Complex128Array([]); + + v = zsumkbn([vector(x, 0, 1, 0)]); + t.strictEqual(isSameComplex128(v, new Complex128(0.0, 0.0)), true, 'returns expected value'); + + t.end(); +}); + +tape('if provided a ndarray containing a single element, the function returns that element', function test(t) { + var x; + var v; + + x = new Complex128Array([1.0, 2.0]); + + v = zsumkbn([vector(x, 1, 1, 0)]); + t.strictEqual(isSameComplex128(v, new Complex128(1.0, 2.0)), true, 'returns expected value'); + + t.end(); +}); + +tape('the function supports one-dimensional ndarrays having non-unit strides', function test(t) { + var x; + var v; + + x = new Complex128Array([ + 1.0, // 0 + 1.0, // 0 + 2.0, + 2.0, + 2.0, // 1 + 2.0, // 1 + -7.0, + -7.0, + -2.0, // 2 + -2.0, // 2 + 3.0, + 3.0, + 4.0, // 3 + 4.0, // 3 + 2.0, + 2.0 + ]); + + v = zsumkbn([vector(x, 4, 2, 0)]); + + t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); + t.end(); +}); + +tape('the function supports one-dimensional ndarrays having negative strides', function test(t) { + var x; + var v; + + x = new Complex128Array([ + 1.0, // 3 + 1.0, // 3 + 2.0, + 2.0, + 2.0, // 2 + 2.0, // 2 + -7.0, + -7.0, + -2.0, // 1 + -2.0, // 1 + 3.0, + 3.0, + 4.0, // 0 + 4.0, // 0 + 2.0, + 2.0 + ]); + + v = zsumkbn([vector(x, 4, -2, 6)]); + + t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); + t.end(); +}); + +tape('the function supports one-dimensional ndarrays having non-zero offsets', function test(t) { + var x; + var v; + + x = new Complex128Array([ + -9.0, + -9.0, + 1.0, // 3 + 1.0, // 3 + 2.0, + 2.0, + 2.0, // 2 + 2.0, // 2 + -7.0, + -7.0, + -2.0, // 1 + -2.0, // 1 + 3.0, + 3.0, + 4.0, // 0 + 4.0, // 0 + 2.0, + 2.0 + ]); + + v = zsumkbn([vector(x, 4, 2, 1)]); + t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); + + t.end(); +}); From 740a8aa414546d88b6dcb439951a4f1a4f229643 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Sun, 7 Dec 2025 09:36:57 +0530 Subject: [PATCH 2/9] lint --- .../@stdlib/blas/ext/base/ndarray/zsumkbn/README.md | 2 +- .../@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md index e0ef43b27a43..4348e00e09f0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md @@ -21,7 +21,7 @@ limitations under the License. # zsumkbn > Compute the sum of all elements in a one-dimensional double-precision complex -floating-point ndarray using an improved Kahan–Babuška algorithm. +> floating-point ndarray using an improved Kahan–Babuška algorithm.
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts index 8a436a5999fe..4526da0bc0a0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts @@ -39,7 +39,7 @@ import { Complex128 } from '@stdlib/types/complex'; * var v = zsumkbn( [ x ] ); * // returns [ 5.0, 5.0 ] */ -declare function zsumkbn(arrays: [complex128ndarray]): Complex128; +declare function zsumkbn( arrays: [complex128ndarray] ): Complex128; // EXPORTS // From cea1abdc7dd81a1a5b8cd772f229abaf17b3de9d Mon Sep 17 00:00:00 2001 From: kaustubh Date: Sun, 7 Dec 2025 17:51:44 +0530 Subject: [PATCH 3/9] feat: added proper spacing --- .../ndarray/zsumkbn/benchmark/benchmark.js | 4 +- .../ndarray/zsumkbn/docs/types/index.d.ts | 2 +- .../base/ndarray/zsumkbn/docs/types/test.ts | 8 ++-- .../base/ndarray/zsumkbn/examples/index.js | 4 +- .../blas/ext/base/ndarray/zsumkbn/lib/main.js | 2 +- .../ext/base/ndarray/zsumkbn/test/test.js | 38 +++++++++---------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js index 35ba82cc5d1b..453904cbc8c7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js @@ -55,7 +55,7 @@ function createBenchmark(len) { xbuf = uniform(len * 2, -10.0, 10.0, { 'dtype': 'float64' }); - x = new ndarray(options.dtype, new Complex128Array(xbuf), [len], [1], 0, 'row-major'); + x = new ndarray(options.dtype, new Complex128Array(xbuf), [ len ], [ 1 ], 0, 'row-major'); return benchmark; @@ -65,7 +65,7 @@ function createBenchmark(len) { b.tic(); for (i = 0; i < b.iterations; i++) { - v = zsumkbn([x]); + v = zsumkbn([ x ]); if (isnan(real(v))) { b.fail('should not return NaN'); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts index 4526da0bc0a0..55801ca4a522 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/index.d.ts @@ -39,7 +39,7 @@ import { Complex128 } from '@stdlib/types/complex'; * var v = zsumkbn( [ x ] ); * // returns [ 5.0, 5.0 ] */ -declare function zsumkbn( arrays: [complex128ndarray] ): Complex128; +declare function zsumkbn( arrays: [ complex128ndarray ] ): Complex128; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts index f76175ef25a3..725bd0e2129a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts @@ -26,11 +26,11 @@ import zsumkbn = require( './index' ); // The function returns a complex number... { - const x = zeros([10], { + const x = zeros([ 10 ], { 'dtype': 'complex128' }); - zsumkbn([x]); // $ExpectType Complex128 + zsumkbn([ x ]); // $ExpectType Complex128 } // The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... @@ -48,10 +48,10 @@ import zsumkbn = require( './index' ); // The compiler throws an error if the function is provided an unsupported number of arguments... { - const x = zeros([10], { + const x = zeros([ 10 ], { 'dtype': 'complex128' }); zsumkbn(); // $ExpectError - zsumkbn([x], {}); // $ExpectError + zsumkbn([ x ], {}); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js index 0e19d7efdd10..98ee370ec7ed 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js @@ -29,8 +29,8 @@ var xbuf = discreteUniform(10, -50, 50, { }); xbuf = new Complex128Array(xbuf); -var x = new ndarray('complex128', xbuf, [xbuf.length], [1], 0, 'row-major'); +var x = new ndarray('complex128', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major'); console.log(ndarray2array(x)); -var v = zsumkbn([x]); +var v = zsumkbn([ x ]); console.log(v); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js index 75e7c9a6060d..ce813653e874 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js @@ -46,7 +46,7 @@ var strided = require( '@stdlib/blas/ext/base/zsumkbn' ).ndarray; * // returns [ 5.0, 5.0 ] */ function zsumkbn(arrays) { - var x = arrays[0]; + var x = arrays[ 0 ]; return strided(numelDimension(x, 0), getData(x), getStride(x, 0), getOffset(x)); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js index de17a9ddee32..b54b645df9a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js @@ -41,7 +41,7 @@ var zsumkbn = require( './../lib' ); * @returns {ndarray} one-dimensional ndarray */ function vector(buffer, length, stride, offset) { - return new ndarray('complex128', buffer, [length], [stride], offset, 'row-major'); + return new ndarray('complex128', buffer, [ length ], [ stride ], offset, 'row-major'); } @@ -62,48 +62,48 @@ tape('the function computes the sum of all elements in a one-dimensional ndarray var x; var v; - x = new Complex128Array([1.0, -2.0, -4.0, 5.0, 0.0, 3.0]); - v = zsumkbn([vector(x, 3, 1, 0)]); + x = new Complex128Array([ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]); + v = zsumkbn([ vector(x, 3, 1, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(-3.0, 6.0)), true, 'returns expected value'); - x = new Complex128Array([-4.0, -5.0, -4.0, -5.0]); - v = zsumkbn([vector(x, 2, 1, 0)]); + x = new Complex128Array([ -4.0, -5.0, -4.0, -5.0 ]); + v = zsumkbn([ vector(x, 2, 1, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(-8.0, -10.0)), true, 'returns expected value'); - x = new Complex128Array([-0.0, 0.0, -0.0, -0.0]); - v = zsumkbn([vector(x, 2, 1, 0)]); + x = new Complex128Array([ -0.0, 0.0, -0.0, -0.0 ]); + v = zsumkbn([ vector(x, 2, 1, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(-0.0, 0.0)), true, 'returns expected value'); - x = new Complex128Array([NaN, NaN]); - v = zsumkbn([vector(x, 1, 1, 0)]); + x = new Complex128Array([ NaN, NaN ]); + v = zsumkbn([ vector(x, 1, 1, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(NaN, NaN)), true, 'returns expected value'); - x = new Complex128Array([NaN, NaN, NaN, NaN]); - v = zsumkbn([vector(x, 2, 1, 0)]); + x = new Complex128Array([ NaN, NaN, NaN, NaN ]); + v = zsumkbn([ vector(x, 2, 1, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(NaN, NaN)), true, 'returns expected value'); t.end(); }); -tape('if provided an empty ndarray, the function returns `0.0 + 0.0i`', function test(t) { +tape('if provided an empty ndarray, the function returns `0.0+0.0j`', function test(t) { var x; var v; x = new Complex128Array([]); - v = zsumkbn([vector(x, 0, 1, 0)]); + v = zsumkbn([ vector(x, 0, 1, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(0.0, 0.0)), true, 'returns expected value'); t.end(); }); -tape('if provided a ndarray containing a single element, the function returns that element', function test(t) { +tape('if provided an ndarray containing a single element, the function returns that element', function test(t) { var x; var v; - x = new Complex128Array([1.0, 2.0]); + x = new Complex128Array([ 1.0, 2.0 ]); - v = zsumkbn([vector(x, 1, 1, 0)]); + v = zsumkbn([ vector(x, 1, 1, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(1.0, 2.0)), true, 'returns expected value'); t.end(); @@ -132,7 +132,7 @@ tape('the function supports one-dimensional ndarrays having non-unit strides', f 2.0 ]); - v = zsumkbn([vector(x, 4, 2, 0)]); + v = zsumkbn([ vector(x, 4, 2, 0) ]); t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); t.end(); @@ -161,7 +161,7 @@ tape('the function supports one-dimensional ndarrays having negative strides', f 2.0 ]); - v = zsumkbn([vector(x, 4, -2, 6)]); + v = zsumkbn([ vector(x, 4, -2, 6) ]); t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); t.end(); @@ -192,7 +192,7 @@ tape('the function supports one-dimensional ndarrays having non-zero offsets', f 2.0 ]); - v = zsumkbn([vector(x, 4, 2, 1)]); + v = zsumkbn([ vector(x, 4, 2, 1) ]); t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); t.end(); From b857e695e70f6335572b06ffa2ca0def593f3c40 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 8 Dec 2025 11:06:20 +0530 Subject: [PATCH 4/9] spacing issues --- .../ndarray/zsumkbn/benchmark/benchmark.js | 32 +++---- .../base/ndarray/zsumkbn/docs/types/test.ts | 30 +++--- .../base/ndarray/zsumkbn/examples/index.js | 14 +-- .../blas/ext/base/ndarray/zsumkbn/lib/main.js | 4 +- .../ext/base/ndarray/zsumkbn/test/test.js | 92 +++++++++---------- 5 files changed, 86 insertions(+), 86 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js index 453904cbc8c7..8d73525e8947 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js @@ -48,33 +48,33 @@ var options = { * @param {PositiveInteger} len - array length * @returns {Function} benchmark function */ -function createBenchmark(len) { +function createBenchmark( len ) { var xbuf; var x; - xbuf = uniform(len * 2, -10.0, 10.0, { + xbuf = uniform( len * 2, -10.0, 10.0, { 'dtype': 'float64' - }); - x = new ndarray(options.dtype, new Complex128Array(xbuf), [ len ], [ 1 ], 0, 'row-major'); + } ); + x = new ndarray( options.dtype, new Complex128Array( xbuf ), [ len ], [ 1 ], 0, 'row-major' ); return benchmark; - function benchmark(b) { + function benchmark( b ) { var v; var i; b.tic(); - for (i = 0; i < b.iterations; i++) { - v = zsumkbn([ x ]); - if (isnan(real(v))) { - b.fail('should not return NaN'); + for ( i = 0; i < b.iterations; i++ ) { + v = zsumkbn( [ x ] ); + if ( isnan( real( v ) ) ) { + b.fail( 'should not return NaN' ); } } b.toc(); - if (isnan(imag(v))) { - b.fail('should not return NaN'); + if ( isnan( imag( v ) ) ) { + b.fail( 'should not return NaN' ); } - b.pass('benchmark finished'); + b.pass( 'benchmark finished' ); b.end(); } } @@ -97,10 +97,10 @@ function main() { min = 1; // 10^min max = 6; // 10^max - for (i = min; i <= max; i++) { - len = pow(10, i); - f = createBenchmark(len); - bench(pkg + ':len=' + len, f); + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg + ':len=' + len, f ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts index 725bd0e2129a..fb0222b8440a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts @@ -26,32 +26,32 @@ import zsumkbn = require( './index' ); // The function returns a complex number... { - const x = zeros([ 10 ], { + const x = zeros( [ 10 ], { 'dtype': 'complex128' - }); + } ); - zsumkbn([ x ]); // $ExpectType Complex128 + zsumkbn( [ x ] ); // $ExpectType Complex128 } // The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... { - zsumkbn('10'); // $ExpectError - zsumkbn(10); // $ExpectError - zsumkbn(true); // $ExpectError - zsumkbn(false); // $ExpectError - zsumkbn(null); // $ExpectError - zsumkbn(undefined); // $ExpectError - zsumkbn([]); // $ExpectError - zsumkbn({}); // $ExpectError - zsumkbn((x: number): number => x); // $ExpectError + zsumkbn( '10' ); // $ExpectError + zsumkbn( 10 ); // $ExpectError + zsumkbn( true ); // $ExpectError + zsumkbn( false ); // $ExpectError + zsumkbn( null ); // $ExpectError + zsumkbn( undefined ); // $ExpectError + zsumkbn( [] ); // $ExpectError + zsumkbn( {} ); // $ExpectError + zsumkbn( ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { - const x = zeros([ 10 ], { + const x = zeros( [ 10 ], { 'dtype': 'complex128' - }); + } ); zsumkbn(); // $ExpectError - zsumkbn([ x ], {}); // $ExpectError + zsumkbn( [ x ], {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js index 98ee370ec7ed..31ef937c8002 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js @@ -24,13 +24,13 @@ var ndarray = require( '@stdlib/ndarray/base/ctor' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); var zsumkbn = require( './../lib' ); -var xbuf = discreteUniform(10, -50, 50, { +var xbuf = discreteUniform( 10, -50, 50, { 'dtype': 'float64' -}); -xbuf = new Complex128Array(xbuf); +} ); +xbuf = new Complex128Array( xbuf ); -var x = new ndarray('complex128', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major'); -console.log(ndarray2array(x)); +var x = new ndarray( 'complex128', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); -var v = zsumkbn([ x ]); -console.log(v); +var v = zsumkbn( [ x ] ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js index ce813653e874..ac8f2bef55d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/lib/main.js @@ -45,9 +45,9 @@ var strided = require( '@stdlib/blas/ext/base/zsumkbn' ).ndarray; * var v = zsumkbn( [ x ] ); * // returns [ 5.0, 5.0 ] */ -function zsumkbn(arrays) { +function zsumkbn( arrays ) { var x = arrays[ 0 ]; - return strided(numelDimension(x, 0), getData(x), getStride(x, 0), getOffset(x)); // eslint-disable-line max-len + return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js index b54b645df9a5..ded70c8c5543 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js @@ -40,80 +40,80 @@ var zsumkbn = require( './../lib' ); * @param {NonNegativeInteger} offset - index offset * @returns {ndarray} one-dimensional ndarray */ -function vector(buffer, length, stride, offset) { - return new ndarray('complex128', buffer, [ length ], [ stride ], offset, 'row-major'); +function vector( buffer, length, stride, offset ) { + return new ndarray( 'complex128', buffer, [ length ], [ stride ], offset, 'row-major' ); } // TESTS // -tape('main export is a function', function test(t) { - t.ok(true, __filename); - t.strictEqual(typeof zsumkbn, 'function', 'main export is a function'); +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zsumkbn, 'function', 'main export is a function' ); t.end(); }); -tape('the function has an arity of 1', function test(t) { - t.strictEqual(zsumkbn.length, 1, 'has expected arity'); +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( zsumkbn.length, 1, 'has expected arity' ); t.end(); }); -tape('the function computes the sum of all elements in a one-dimensional ndarray using an improved Kahan–Babuška algorithm', function test(t) { +tape( 'the function computes the sum of all elements in a one-dimensional ndarray using an improved Kahan–Babuška algorithm', function test( t ) { var x; var v; - x = new Complex128Array([ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ]); - v = zsumkbn([ vector(x, 3, 1, 0) ]); - t.strictEqual(isSameComplex128(v, new Complex128(-3.0, 6.0)), true, 'returns expected value'); + x = new Complex128Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + v = zsumkbn( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( -3.0, 6.0 ) ), true, 'returns expected value' ); - x = new Complex128Array([ -4.0, -5.0, -4.0, -5.0 ]); - v = zsumkbn([ vector(x, 2, 1, 0) ]); - t.strictEqual(isSameComplex128(v, new Complex128(-8.0, -10.0)), true, 'returns expected value'); + x = new Complex128Array( [ -4.0, -5.0, -4.0, -5.0 ] ); + v = zsumkbn( [ vector( x, 2, 1, 0 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( -8.0, -10.0 ) ), true, 'returns expected value' ); - x = new Complex128Array([ -0.0, 0.0, -0.0, -0.0 ]); - v = zsumkbn([ vector(x, 2, 1, 0) ]); - t.strictEqual(isSameComplex128(v, new Complex128(-0.0, 0.0)), true, 'returns expected value'); + x = new Complex128Array( [ -0.0, 0.0, -0.0, -0.0 ] ); + v = zsumkbn( [ vector( x, 2, 1, 0 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( -0.0, 0.0 ) ), true, 'returns expected value' ); - x = new Complex128Array([ NaN, NaN ]); - v = zsumkbn([ vector(x, 1, 1, 0) ]); - t.strictEqual(isSameComplex128(v, new Complex128(NaN, NaN)), true, 'returns expected value'); + x = new Complex128Array( [ NaN, NaN ] ); + v = zsumkbn( [ vector( x, 1, 1, 0 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( NaN, NaN ) ), true, 'returns expected value' ); - x = new Complex128Array([ NaN, NaN, NaN, NaN ]); - v = zsumkbn([ vector(x, 2, 1, 0) ]); - t.strictEqual(isSameComplex128(v, new Complex128(NaN, NaN)), true, 'returns expected value'); + x = new Complex128Array( [ NaN, NaN, NaN, NaN ] ); + v = zsumkbn( [ vector( x, 2, 1, 0 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( NaN, NaN ) ), true, 'returns expected value' ); t.end(); }); -tape('if provided an empty ndarray, the function returns `0.0+0.0j`', function test(t) { +tape( 'if provided an empty ndarray, the function returns `0.0+0.0j`', function test( t ) { var x; var v; - x = new Complex128Array([]); + x = new Complex128Array( [] ); - v = zsumkbn([ vector(x, 0, 1, 0) ]); - t.strictEqual(isSameComplex128(v, new Complex128(0.0, 0.0)), true, 'returns expected value'); + v = zsumkbn( [ vector( x, 0, 1, 0 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( 0.0, 0.0 ) ), true, 'returns expected value' ); t.end(); }); -tape('if provided an ndarray containing a single element, the function returns that element', function test(t) { +tape( 'if provided an ndarray containing a single element, the function returns that element', function test( t ) { var x; var v; - x = new Complex128Array([ 1.0, 2.0 ]); + x = new Complex128Array( [ 1.0, 2.0 ] ); - v = zsumkbn([ vector(x, 1, 1, 0) ]); - t.strictEqual(isSameComplex128(v, new Complex128(1.0, 2.0)), true, 'returns expected value'); + v = zsumkbn( [ vector( x, 1, 1, 0 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( 1.0, 2.0 ) ), true, 'returns expected value' ); t.end(); }); -tape('the function supports one-dimensional ndarrays having non-unit strides', function test(t) { +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { var x; var v; - x = new Complex128Array([ + x = new Complex128Array( [ 1.0, // 0 1.0, // 0 2.0, @@ -130,19 +130,19 @@ tape('the function supports one-dimensional ndarrays having non-unit strides', f 4.0, // 3 2.0, 2.0 - ]); + ] ); - v = zsumkbn([ vector(x, 4, 2, 0) ]); + v = zsumkbn( [ vector( x, 4, 2, 0 ) ] ); - t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); + t.strictEqual( isSameComplex128( v, new Complex128( 5.0, 5.0 ) ), true, 'returns expected value' ); t.end(); }); -tape('the function supports one-dimensional ndarrays having negative strides', function test(t) { +tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { var x; var v; - x = new Complex128Array([ + x = new Complex128Array( [ 1.0, // 3 1.0, // 3 2.0, @@ -159,19 +159,19 @@ tape('the function supports one-dimensional ndarrays having negative strides', f 4.0, // 0 2.0, 2.0 - ]); + ] ); - v = zsumkbn([ vector(x, 4, -2, 6) ]); + v = zsumkbn( [ vector( x, 4, -2, 6 ) ] ); - t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); + t.strictEqual( isSameComplex128( v, new Complex128( 5.0, 5.0 ) ), true, 'returns expected value' ); t.end(); }); -tape('the function supports one-dimensional ndarrays having non-zero offsets', function test(t) { +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { var x; var v; - x = new Complex128Array([ + x = new Complex128Array( [ -9.0, -9.0, 1.0, // 3 @@ -190,10 +190,10 @@ tape('the function supports one-dimensional ndarrays having non-zero offsets', f 4.0, // 0 2.0, 2.0 - ]); + ] ); - v = zsumkbn([ vector(x, 4, 2, 1) ]); - t.strictEqual(isSameComplex128(v, new Complex128(5.0, 5.0)), true, 'returns expected value'); + v = zsumkbn( [ vector( x, 4, 2, 1 ) ] ); + t.strictEqual( isSameComplex128( v, new Complex128( 5.0, 5.0 ) ), true, 'returns expected value' ); t.end(); }); From b5bafb07872b3bb21d264244cd79c1063ccc25ac Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 8 Dec 2025 11:13:06 +0530 Subject: [PATCH 5/9] lint --- .../blas/ext/base/ndarray/zsumkbn/examples/index.js | 2 +- .../blas/ext/base/ndarray/zsumkbn/test/test.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js index 31ef937c8002..2cb00d2b4d3e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/examples/index.js @@ -26,7 +26,7 @@ var zsumkbn = require( './../lib' ); var xbuf = discreteUniform( 10, -50, 50, { 'dtype': 'float64' -} ); +}); xbuf = new Complex128Array( xbuf ); var x = new ndarray( 'complex128', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js index ded70c8c5543..044e65ff2bfa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js @@ -113,7 +113,7 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', var x; var v; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, // 0 1.0, // 0 2.0, @@ -130,7 +130,7 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', 4.0, // 3 2.0, 2.0 - ] ); + ]); v = zsumkbn( [ vector( x, 4, 2, 0 ) ] ); @@ -142,7 +142,7 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', var x; var v; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, // 3 1.0, // 3 2.0, @@ -159,7 +159,7 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', 4.0, // 0 2.0, 2.0 - ] ); + ]); v = zsumkbn( [ vector( x, 4, -2, 6 ) ] ); @@ -171,7 +171,7 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', var x; var v; - x = new Complex128Array( [ + x = new Complex128Array([ -9.0, -9.0, 1.0, // 3 @@ -190,7 +190,7 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', 4.0, // 0 2.0, 2.0 - ] ); + ]); v = zsumkbn( [ vector( x, 4, 2, 1 ) ] ); t.strictEqual( isSameComplex128( v, new Complex128( 5.0, 5.0 ) ), true, 'returns expected value' ); From 50b235623ce47d87bbfc12bdef4fd48c0ceaf56c Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 8 Dec 2025 11:36:14 +0530 Subject: [PATCH 6/9] formating --- .../blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js | 2 +- .../@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js index 8d73525e8947..2d4c1630cd1d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js @@ -54,7 +54,7 @@ function createBenchmark( len ) { xbuf = uniform( len * 2, -10.0, 10.0, { 'dtype': 'float64' - } ); + }); x = new ndarray( options.dtype, new Complex128Array( xbuf ), [ len ], [ 1 ], 0, 'row-major' ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts index fb0222b8440a..a1d55aa2470a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/types/test.ts @@ -28,7 +28,7 @@ import zsumkbn = require( './index' ); { const x = zeros( [ 10 ], { 'dtype': 'complex128' - } ); + }); zsumkbn( [ x ] ); // $ExpectType Complex128 } @@ -50,7 +50,7 @@ import zsumkbn = require( './index' ); { const x = zeros( [ 10 ], { 'dtype': 'complex128' - } ); + }); zsumkbn(); // $ExpectError zsumkbn( [ x ], {} ); // $ExpectError From 080e9cd0cb1104dda41c8810b452528df74f58b8 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 8 Dec 2025 11:58:31 +0530 Subject: [PATCH 7/9] formating and spacing --- .../@stdlib/blas/ext/base/ndarray/zsumkbn/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md index 4348e00e09f0..cfe8f4df8330 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/README.md @@ -20,8 +20,7 @@ limitations under the License. # zsumkbn -> Compute the sum of all elements in a one-dimensional double-precision complex -> floating-point ndarray using an improved Kahan–Babuška algorithm. +> Compute the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm.
@@ -39,8 +38,7 @@ var zsumkbn = require( '@stdlib/blas/ext/base/ndarray/zsumkbn' ); #### zsumkbn( arrays ) -Computes the sum of all elements in a one-dimensional double-precision complex -floating-point ndarray using an improved Kahan–Babuška algorithm. +Computes the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); From 76e9a0d2d13067a16ac6de63373c631ec347ce2b Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 8 Dec 2025 21:56:35 +0530 Subject: [PATCH 8/9] Reviewed Changes --- .../blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js | 4 ++-- .../@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt | 2 +- .../@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js index 2d4c1630cd1d..5544c4317e88 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/benchmark/benchmark.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { var xbuf; var x; - xbuf = uniform( len * 2, -10.0, 10.0, { + xbuf = uniform( len*2, -10.0, 10.0, { 'dtype': 'float64' }); x = new ndarray( options.dtype, new Complex128Array( xbuf ), [ len ], [ 1 ], 0, 'row-major' ); @@ -100,7 +100,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg + ':len=' + len, f ); + bench( pkg+':len='+len, f ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt index 805cd283a867..805e910a3be6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt @@ -3,7 +3,7 @@ Computes the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm. - If provided an empty ndarray, the function returns `0.0 + 0.0i`. + If provided an empty ndarray, the function returns `0.0`. Parameters ---------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js index 044e65ff2bfa..80dccd2e2d90 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/test/test.js @@ -85,7 +85,7 @@ tape( 'the function computes the sum of all elements in a one-dimensional ndarra t.end(); }); -tape( 'if provided an empty ndarray, the function returns `0.0+0.0j`', function test( t ) { +tape( 'if provided an empty ndarray, the function returns `0.0`', function test( t ) { var x; var v; From 8a0a0eb91c031062d8f4c907d6589c3175f11c9c Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 8 Dec 2025 19:38:09 -0800 Subject: [PATCH 9/9] docs: update note Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt index 805e910a3be6..805cd283a867 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zsumkbn/docs/repl.txt @@ -3,7 +3,7 @@ Computes the sum of all elements in a one-dimensional double-precision complex floating-point ndarray using an improved Kahan–Babuška algorithm. - If provided an empty ndarray, the function returns `0.0`. + If provided an empty ndarray, the function returns `0.0 + 0.0i`. Parameters ----------