From e060a810f4991a5915bc721ac1674b5f0547ea47 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Fri, 5 Dec 2025 20:03:35 +0530 Subject: [PATCH 1/9] feat: add blas/ext/base/ndarray/dsumkbn2 --- .../blas/ext/base/ndarray/dsumkbn2/README.md | 126 +++++++++++++ .../ndarray/dsumkbn2/benchmark/benchmark.js | 102 +++++++++++ .../ext/base/ndarray/dsumkbn2/docs/repl.txt | 33 ++++ .../ndarray/dsumkbn2/docs/types/index.d.ts | 46 +++++ .../base/ndarray/dsumkbn2/docs/types/test.ts | 55 ++++++ .../base/ndarray/dsumkbn2/examples/index.js | 33 ++++ .../ext/base/ndarray/dsumkbn2/lib/index.js | 45 +++++ .../ext/base/ndarray/dsumkbn2/lib/main.js | 56 ++++++ .../ext/base/ndarray/dsumkbn2/package.json | 72 ++++++++ .../ext/base/ndarray/dsumkbn2/test/test.js | 173 ++++++++++++++++++ 10 files changed, 741 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md new file mode 100644 index 000000000000..f3ab2737e0e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md @@ -0,0 +1,126 @@ + + +# dsumkbn2 + +> Compute the sum of all elements in a one-dimensional double-precision +floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. + +
+ +
+ + + +
+ +## Usage + +```javascript +var dsumkbn2 = require( '@stdlib/blas/ext/base/ndarray/dsumkbn2' ); +``` + +#### dsumkbn2( arrays ) + +Computes the sum of all elements in a one-dimensional double-precision +floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var xbuf = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +var x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); + +var v = dsumkbn2( [ x ] ); +// returns 1.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`. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var dsumkbn2 = require( '@stdlib/blas/ext/base/ndarray/dsumkbn2' ); + +var xbuf = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); +var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var v = dsumkbn2( [ x ] ); +console.log( v ); +``` + +
+ + + +
+ +## References + +- Klein, Andreas. 2005. "A Generalized Kahan-Babuška-Summation-Algorithm." _Computing_ 76 (3): 279–93. doi:[10.1007/s00607-005-0139-x][@klein:2005a]. + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js new file mode 100644 index 000000000000..87cfd5e53f15 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js @@ -0,0 +1,102 @@ +/** +* @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 pow = require('@stdlib/math/base/special/pow'); +var ndarray = require('@stdlib/ndarray/base/ctor'); +var pkg = require('./../package.json').name; +var dsumkbn2 = require('./../lib'); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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, -10.0, 10.0, options); + x = new ndarray(options.dtype, 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 = dsumkbn2([x]); + if (isnan(v)) { + b.fail('should not return NaN'); + } + } + b.toc(); + if (isnan(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/dsumkbn2/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/repl.txt new file mode 100644 index 000000000000..5132274e9c41 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/repl.txt @@ -0,0 +1,33 @@ + +{{alias}}( arrays ) + Computes the sum of all elements in a one-dimensional double-precision + floating-point ndarray using a second-order iterative Kahan–Babuška + algorithm. + + If provided an empty ndarray, the function returns `0.0`. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing a one-dimensional input ndarray. + + Returns + ------- + out: number + Sum. + + Examples + -------- + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); + > var dt = 'float64'; + > 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 ] ) + 1.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts new file mode 100644 index 000000000000..a78ef61f60b2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts @@ -0,0 +1,46 @@ +/* +* @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 { float64ndarray } from '@stdlib/types/ndarray'; + +/** +* Computes the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. +* +* @param arrays - array-like object containing an input ndarray +* @returns sum +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); +* +* var v = dsumkbn2( [ x ] ); +* // returns 1.0 +*/ +declare function dsumkbn2(arrays: [float64ndarray]): number; + + +// EXPORTS // + +export = dsumkbn2; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts new file mode 100644 index 000000000000..ca83da5253ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts @@ -0,0 +1,55 @@ +/* +* @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. +*/ + +import zeros = require('@stdlib/ndarray/zeros'); +import dsumkbn2 = require('./index'); + + +// TESTS // + +// The function returns a number... +{ + const x = zeros([10], { + 'dtype': 'float64' + }); + + dsumkbn2([x]); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + dsumkbn2('10'); // $ExpectError + dsumkbn2(10); // $ExpectError + dsumkbn2(true); // $ExpectError + dsumkbn2(false); // $ExpectError + dsumkbn2(null); // $ExpectError + dsumkbn2(undefined); // $ExpectError + dsumkbn2([]); // $ExpectError + dsumkbn2({}); // $ExpectError + dsumkbn2((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': 'float64' + }); + + dsumkbn2(); // $ExpectError + dsumkbn2([x], {}); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js new file mode 100644 index 000000000000..e87ee3bccf77 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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 ndarray = require('@stdlib/ndarray/base/ctor'); +var ndarray2array = require('@stdlib/ndarray/to-array'); +var dsumkbn2 = require('./../lib'); + +var xbuf = discreteUniform(10, -50, 50, { + 'dtype': 'float64' +}); +var x = new ndarray('float64', xbuf, [xbuf.length], [1], 0, 'row-major'); +console.log(ndarray2array(x)); + +var v = dsumkbn2([x]); +console.log(v); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/index.js new file mode 100644 index 000000000000..aba08450df19 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/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 floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. +* +* @module @stdlib/blas/ext/base/ndarray/dsumkbn2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var dsumkbn2 = require( '@stdlib/blas/ext/base/ndarray/dsumkbn2' ); +* +* var xbuf = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); +* +* var v = dsumkbn2( [ x ] ); +* // returns 1.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js new file mode 100644 index 000000000000..9dd5dc9c4ec0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/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/dsumkbn2').ndarray; + + +// MAIN // + +/** +* Computes the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. +* +* @param {ArrayLikeObject} arrays - array-like object containing an input ndarray +* @returns {number} sum +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); +* +* var v = dsumkbn2( [ x ] ); +* // returns 1.0 +*/ +function dsumkbn2(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 = dsumkbn2; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json new file mode 100644 index 000000000000..25670bc83edb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/dsumkbn2", + "version": "0.0.0", + "description": "Compute the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative 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", + "kbn2", + "ndarray", + "float64", + "double", + "float64array" + ], + "__stdlib__": {} +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js new file mode 100644 index 000000000000..97418f20e971 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js @@ -0,0 +1,173 @@ +/** +* @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 isnan = require('@stdlib/math/base/assert/is-nan'); +var isPositiveZero = require('@stdlib/math/base/assert/is-positive-zero'); +var Float64Array = require('@stdlib/array/float64'); +var ndarray = require('@stdlib/ndarray/base/ctor'); +var dsumkbn2 = require('./../lib'); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Float64Array} 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('float64', buffer, [length], [stride], offset, 'row-major'); +} + + +// TESTS // + +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof dsumkbn2, 'function', 'main export is a function'); + t.end(); +}); + +tape('the function has an arity of 1', function test(t) { + t.strictEqual(dsumkbn2.length, 1, 'has expected arity'); + t.end(); +}); + +tape('the function computes the sum of all elements in a one-dimensional ndarray using a second-order iterative Kahan–Babuška algorithm', function test(t) { + var x; + var v; + + x = new Float64Array([1.0, -2.0, -4.0, 5.0, 0.0, 3.0]); + v = dsumkbn2([vector(x, 6, 1, 0)]); + t.strictEqual(v, 3.0, 'returns expected value'); + + x = new Float64Array([-4.0, -5.0]); + v = dsumkbn2([vector(x, 2, 1, 0)]); + t.strictEqual(v, -9.0, 'returns expected value'); + + x = new Float64Array([-0.0, 0.0, -0.0]); + v = dsumkbn2([vector(x, 3, 1, 0)]); + t.strictEqual(isPositiveZero(v), true, 'returns expected value'); + + x = new Float64Array([NaN]); + v = dsumkbn2([vector(x, 1, 1, 0)]); + t.strictEqual(isnan(v), true, 'returns expected value'); + + x = new Float64Array([NaN, NaN]); + v = dsumkbn2([vector(x, 2, 1, 0)]); + t.strictEqual(isnan(v), true, 'returns expected value'); + + t.end(); +}); + +tape('if provided an empty ndarray, the function returns `0.0`', function test(t) { + var x; + var v; + + x = new Float64Array([]); + + v = dsumkbn2([vector(x, 0, 1, 0)]); + t.strictEqual(isPositiveZero(v), 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 Float64Array([1.0]); + + v = dsumkbn2([vector(x, 1, 1, 0)]); + t.strictEqual(v, 1.0, '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 Float64Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]); + + v = dsumkbn2([vector(x, 4, 2, 0)]); + + t.strictEqual(v, 5.0, 'returns expected value'); + t.end(); +}); + +tape('the function supports one-dimensional ndarrays having negative strides', function test(t) { + var x; + var v; + + x = new Float64Array([ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]); + + v = dsumkbn2([vector(x, 4, -2, 6)]); + + t.strictEqual(v, 5.0, '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 Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]); + + v = dsumkbn2([vector(x, 4, 2, 1)]); + t.strictEqual(v, 5.0, 'returns expected value'); + + t.end(); +}); From 7f287b0672d4fe0f9afd71c886634e1b6c530290 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Fri, 5 Dec 2025 20:24:26 +0530 Subject: [PATCH 2/9] lint --- .../blas/ext/base/ndarray/dsumkbn2/README.md | 3 +- .../ndarray/dsumkbn2/benchmark/benchmark.js | 44 +++--- .../ndarray/dsumkbn2/docs/types/index.d.ts | 2 +- .../base/ndarray/dsumkbn2/examples/index.js | 18 +-- .../ext/base/ndarray/dsumkbn2/lib/main.js | 10 +- .../ext/base/ndarray/dsumkbn2/package.json | 142 +++++++++--------- .../ext/base/ndarray/dsumkbn2/test/test.js | 92 ++++++------ 7 files changed, 155 insertions(+), 156 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md index f3ab2737e0e8..bc221a7a3ca1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md @@ -20,8 +20,7 @@ limitations under the License. # dsumkbn2 -> Compute the sum of all elements in a one-dimensional double-precision -floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. +> Compute the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative Kahan–Babuška algorithm.
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js index 87cfd5e53f15..bbe214f3e9d1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js @@ -20,13 +20,13 @@ // MODULES // -var bench = require('@stdlib/bench'); -var uniform = require('@stdlib/random/array/uniform'); -var isnan = require('@stdlib/math/base/assert/is-nan'); -var pow = require('@stdlib/math/base/special/pow'); -var ndarray = require('@stdlib/ndarray/base/ctor'); -var pkg = require('./../package.json').name; -var dsumkbn2 = require('./../lib'); +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var pkg = require( './../package.json' ).name; +var dsumkbn2 = require( './../lib' ); // VARIABLES // @@ -45,31 +45,31 @@ var options = { * @param {PositiveInteger} len - array length * @returns {Function} benchmark function */ -function createBenchmark(len) { +function createBenchmark( len ) { var xbuf; var x; - xbuf = uniform(len, -10.0, 10.0, options); - x = new ndarray(options.dtype, xbuf, [len], [1], 0, 'row-major'); + xbuf = uniform( len, -10.0, 10.0, options ); + x = new ndarray( options.dtype, 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 = dsumkbn2([x]); - if (isnan(v)) { - b.fail('should not return NaN'); + for ( i = 0; i < b.iterations; i++ ) { + v = dsumkbn2( [x] ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); } } b.toc(); - if (isnan(v)) { - b.fail('should not return NaN'); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); } - b.pass('benchmark finished'); + b.pass( 'benchmark finished' ); b.end(); } } @@ -92,10 +92,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/dsumkbn2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts index a78ef61f60b2..74f1708972e1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts @@ -38,7 +38,7 @@ import { float64ndarray } from '@stdlib/types/ndarray'; * var v = dsumkbn2( [ x ] ); * // returns 1.0 */ -declare function dsumkbn2(arrays: [float64ndarray]): number; +declare function dsumkbn2( arrays: [float64ndarray] ): number; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js index e87ee3bccf77..92c9ec2f8e3d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js @@ -18,16 +18,16 @@ 'use strict'; -var discreteUniform = require('@stdlib/random/array/discrete-uniform'); -var ndarray = require('@stdlib/ndarray/base/ctor'); -var ndarray2array = require('@stdlib/ndarray/to-array'); -var dsumkbn2 = require('./../lib'); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var dsumkbn2 = require( './../lib' ); -var xbuf = discreteUniform(10, -50, 50, { +var xbuf = discreteUniform( 10, -50, 50, { 'dtype': 'float64' }); -var x = new ndarray('float64', xbuf, [xbuf.length], [1], 0, 'row-major'); -console.log(ndarray2array(x)); +var x = new ndarray( 'float64', xbuf, [xbuf.length], [1], 0, 'row-major' ); +console.log( ndarray2array( x ) ); -var v = dsumkbn2([x]); -console.log(v); +var v = dsumkbn2( [x] ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js index 9dd5dc9c4ec0..341480fe7dae 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js @@ -20,11 +20,11 @@ // 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/dsumkbn2').ndarray; +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/dsumkbn2' ).ndarray; // MAIN // diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json index 25670bc83edb..e4e87a169a25 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json @@ -1,72 +1,72 @@ { - "name": "@stdlib/blas/ext/base/ndarray/dsumkbn2", - "version": "0.0.0", - "description": "Compute the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative 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", - "kbn2", - "ndarray", - "float64", - "double", - "float64array" - ], - "__stdlib__": {} -} \ No newline at end of file + "name": "@stdlib/blas/ext/base/ndarray/dsumkbn2", + "version": "0.0.0", + "description": "Compute the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative 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", + "kbn2", + "ndarray", + "float64", + "double", + "float64array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js index 97418f20e971..b45e25f3b9d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js @@ -20,12 +20,12 @@ // MODULES // -var tape = require('tape'); -var isnan = require('@stdlib/math/base/assert/is-nan'); -var isPositiveZero = require('@stdlib/math/base/assert/is-positive-zero'); -var Float64Array = require('@stdlib/array/float64'); -var ndarray = require('@stdlib/ndarray/base/ctor'); -var dsumkbn2 = require('./../lib'); +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var dsumkbn2 = require( './../lib' ); // FUNCTIONS // @@ -40,76 +40,76 @@ var dsumkbn2 = require('./../lib'); * @param {NonNegativeInteger} offset - index offset * @returns {ndarray} one-dimensional ndarray */ -function vector(buffer, length, stride, offset) { - return new ndarray('float64', buffer, [length], [stride], offset, 'row-major'); +function vector( buffer, length, stride, offset ) { + return new ndarray( 'float64', buffer, [length], [stride], offset, 'row-major' ); } // TESTS // -tape('main export is a function', function test(t) { - t.ok(true, __filename); - t.strictEqual(typeof dsumkbn2, 'function', 'main export is a function'); +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dsumkbn2, 'function', 'main export is a function' ); t.end(); }); -tape('the function has an arity of 1', function test(t) { - t.strictEqual(dsumkbn2.length, 1, 'has expected arity'); +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( dsumkbn2.length, 1, 'has expected arity' ); t.end(); }); -tape('the function computes the sum of all elements in a one-dimensional ndarray using a second-order iterative Kahan–Babuška algorithm', function test(t) { +tape( 'the function computes the sum of all elements in a one-dimensional ndarray using a second-order iterative Kahan–Babuška algorithm', function test( t ) { var x; var v; - x = new Float64Array([1.0, -2.0, -4.0, 5.0, 0.0, 3.0]); - v = dsumkbn2([vector(x, 6, 1, 0)]); - t.strictEqual(v, 3.0, 'returns expected value'); + x = new Float64Array( [1.0, -2.0, -4.0, 5.0, 0.0, 3.0] ); + v = dsumkbn2( [vector( x, 6, 1, 0 )] ); + t.strictEqual( v, 3.0, 'returns expected value' ); - x = new Float64Array([-4.0, -5.0]); - v = dsumkbn2([vector(x, 2, 1, 0)]); - t.strictEqual(v, -9.0, 'returns expected value'); + x = new Float64Array( [-4.0, -5.0] ); + v = dsumkbn2( [vector( x, 2, 1, 0 )] ); + t.strictEqual( v, -9.0, 'returns expected value' ); - x = new Float64Array([-0.0, 0.0, -0.0]); - v = dsumkbn2([vector(x, 3, 1, 0)]); - t.strictEqual(isPositiveZero(v), true, 'returns expected value'); + x = new Float64Array( [-0.0, 0.0, -0.0] ); + v = dsumkbn2( [vector( x, 3, 1, 0 )] ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - x = new Float64Array([NaN]); - v = dsumkbn2([vector(x, 1, 1, 0)]); - t.strictEqual(isnan(v), true, 'returns expected value'); + x = new Float64Array( [NaN] ); + v = dsumkbn2( [vector( x, 1, 1, 0 )] ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Float64Array([NaN, NaN]); - v = dsumkbn2([vector(x, 2, 1, 0)]); - t.strictEqual(isnan(v), true, 'returns expected value'); + x = new Float64Array( [NaN, NaN] ); + v = dsumkbn2( [vector( x, 2, 1, 0 )] ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); -tape('if provided an empty ndarray, the function returns `0.0`', function test(t) { +tape( 'if provided an empty ndarray, the function returns `0.0`', function test( t ) { var x; var v; - x = new Float64Array([]); + x = new Float64Array( [] ); - v = dsumkbn2([vector(x, 0, 1, 0)]); - t.strictEqual(isPositiveZero(v), true, 'returns expected value'); + v = dsumkbn2( [vector( x, 0, 1, 0 )] ); + t.strictEqual( isPositiveZero( v ), 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 a ndarray containing a single element, the function returns that element', function test( t ) { var x; var v; - x = new Float64Array([1.0]); + x = new Float64Array( [1.0] ); - v = dsumkbn2([vector(x, 1, 1, 0)]); - t.strictEqual(v, 1.0, 'returns expected value'); + v = dsumkbn2( [vector( x, 1, 1, 0 )] ); + t.strictEqual( v, 1.0, '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; @@ -124,13 +124,13 @@ tape('the function supports one-dimensional ndarrays having non-unit strides', f 2.0 ]); - v = dsumkbn2([vector(x, 4, 2, 0)]); + v = dsumkbn2( [vector( x, 4, 2, 0 )] ); - t.strictEqual(v, 5.0, 'returns expected value'); + t.strictEqual( v, 5.0, '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; @@ -145,13 +145,13 @@ tape('the function supports one-dimensional ndarrays having negative strides', f 2.0 ]); - v = dsumkbn2([vector(x, 4, -2, 6)]); + v = dsumkbn2( [vector( x, 4, -2, 6 )] ); - t.strictEqual(v, 5.0, 'returns expected value'); + t.strictEqual( v, 5.0, '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; @@ -166,8 +166,8 @@ tape('the function supports one-dimensional ndarrays having non-zero offsets', f 4.0 // 3 ]); - v = dsumkbn2([vector(x, 4, 2, 1)]); - t.strictEqual(v, 5.0, 'returns expected value'); + v = dsumkbn2( [vector( x, 4, 2, 1 )] ); + t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); From 9616728bc0ef3b0cd15cb254f176c6b38f54bc60 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Fri, 5 Dec 2025 20:29:45 +0530 Subject: [PATCH 3/9] lint --- .../ext/base/ndarray/dsumkbn2/package.json | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json index e4e87a169a25..f394b02eb95d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/package.json @@ -1,72 +1,72 @@ { - "name": "@stdlib/blas/ext/base/ndarray/dsumkbn2", - "version": "0.0.0", - "description": "Compute the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative 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", - "kbn2", - "ndarray", - "float64", - "double", - "float64array" - ], - "__stdlib__": {} + "name": "@stdlib/blas/ext/base/ndarray/dsumkbn2", + "version": "0.0.0", + "description": "Compute the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative 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", + "kbn2", + "ndarray", + "float64", + "double", + "float64array" + ], + "__stdlib__": {} } From e0e50d621449741ff9d79c669d940fed1c3c167a Mon Sep 17 00:00:00 2001 From: kaustubh Date: Sun, 7 Dec 2025 18:22:51 +0530 Subject: [PATCH 4/9] feat: spacing changes --- .../ndarray/dsumkbn2/benchmark/benchmark.js | 4 +-- .../ndarray/dsumkbn2/docs/types/index.d.ts | 2 +- .../base/ndarray/dsumkbn2/docs/types/test.ts | 8 ++--- .../base/ndarray/dsumkbn2/examples/index.js | 4 +-- .../ext/base/ndarray/dsumkbn2/lib/main.js | 2 +- .../ext/base/ndarray/dsumkbn2/test/test.js | 34 +++++++++---------- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js index bbe214f3e9d1..ccdc87333fe5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/benchmark/benchmark.js @@ -50,7 +50,7 @@ function createBenchmark( len ) { var x; xbuf = uniform( len, -10.0, 10.0, options ); - x = new ndarray( options.dtype, xbuf, [len], [1], 0, 'row-major' ); + x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); return benchmark; @@ -60,7 +60,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = dsumkbn2( [x] ); + v = dsumkbn2( [ x ] ); if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts index 74f1708972e1..5f40a46003b4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/index.d.ts @@ -38,7 +38,7 @@ import { float64ndarray } from '@stdlib/types/ndarray'; * var v = dsumkbn2( [ x ] ); * // returns 1.0 */ -declare function dsumkbn2( arrays: [float64ndarray] ): number; +declare function dsumkbn2( arrays: [ float64ndarray ] ): number; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts index ca83da5253ad..c8d885ac784a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts @@ -24,11 +24,11 @@ import dsumkbn2 = require('./index'); // The function returns a number... { - const x = zeros([10], { + const x = zeros([ 10 ], { 'dtype': 'float64' }); - dsumkbn2([x]); // $ExpectType number + dsumkbn2([ x ]); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... @@ -46,10 +46,10 @@ import dsumkbn2 = 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': 'float64' }); dsumkbn2(); // $ExpectError - dsumkbn2([x], {}); // $ExpectError + dsumkbn2([ x ], {}); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js index 92c9ec2f8e3d..2c827cd7fbf2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/examples/index.js @@ -26,8 +26,8 @@ var dsumkbn2 = require( './../lib' ); var xbuf = discreteUniform( 10, -50, 50, { 'dtype': 'float64' }); -var x = new ndarray( 'float64', xbuf, [xbuf.length], [1], 0, 'row-major' ); +var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); console.log( ndarray2array( x ) ); -var v = dsumkbn2( [x] ); +var v = dsumkbn2( [ x ] ); console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js index 341480fe7dae..5b700733964f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js @@ -46,7 +46,7 @@ var strided = require( '@stdlib/blas/ext/base/dsumkbn2' ).ndarray; * // returns 1.0 */ function dsumkbn2(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/dsumkbn2/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js index b45e25f3b9d0..b0c90cab4e1a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/test/test.js @@ -41,7 +41,7 @@ var dsumkbn2 = require( './../lib' ); * @returns {ndarray} one-dimensional ndarray */ function vector( buffer, length, stride, offset ) { - return new ndarray( 'float64', buffer, [length], [stride], offset, 'row-major' ); + return new ndarray( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); } @@ -62,24 +62,24 @@ tape( 'the function computes the sum of all elements in a one-dimensional ndarra var x; var v; - x = new Float64Array( [1.0, -2.0, -4.0, 5.0, 0.0, 3.0] ); - v = dsumkbn2( [vector( x, 6, 1, 0 )] ); + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + v = dsumkbn2( [ vector( x, 6, 1, 0 ) ] ); t.strictEqual( v, 3.0, 'returns expected value' ); - x = new Float64Array( [-4.0, -5.0] ); - v = dsumkbn2( [vector( x, 2, 1, 0 )] ); + x = new Float64Array( [ -4.0, -5.0 ] ); + v = dsumkbn2( [ vector( x, 2, 1, 0 ) ] ); t.strictEqual( v, -9.0, 'returns expected value' ); - x = new Float64Array( [-0.0, 0.0, -0.0] ); - v = dsumkbn2( [vector( x, 3, 1, 0 )] ); + x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); + v = dsumkbn2( [ vector( x, 3, 1, 0 ) ] ); t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); - x = new Float64Array( [NaN] ); - v = dsumkbn2( [vector( x, 1, 1, 0 )] ); + x = new Float64Array( [ NaN ] ); + v = dsumkbn2( [ vector( x, 1, 1, 0 ) ] ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - x = new Float64Array( [NaN, NaN] ); - v = dsumkbn2( [vector( x, 2, 1, 0 )] ); + x = new Float64Array( [ NaN, NaN ] ); + v = dsumkbn2( [ vector( x, 2, 1, 0 ) ] ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -91,7 +91,7 @@ tape( 'if provided an empty ndarray, the function returns `0.0`', function test( x = new Float64Array( [] ); - v = dsumkbn2( [vector( x, 0, 1, 0 )] ); + v = dsumkbn2( [ vector( x, 0, 1, 0 ) ] ); t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); t.end(); @@ -101,9 +101,9 @@ tape( 'if provided a ndarray containing a single element, the function returns t var x; var v; - x = new Float64Array( [1.0] ); + x = new Float64Array( [ 1.0 ] ); - v = dsumkbn2( [vector( x, 1, 1, 0 )] ); + v = dsumkbn2( [ vector( x, 1, 1, 0 ) ] ); t.strictEqual( v, 1.0, 'returns expected value' ); t.end(); @@ -124,7 +124,7 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', 2.0 ]); - v = dsumkbn2( [vector( x, 4, 2, 0 )] ); + v = dsumkbn2( [ vector( x, 4, 2, 0 ) ] ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -145,7 +145,7 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', 2.0 ]); - v = dsumkbn2( [vector( x, 4, -2, 6 )] ); + v = dsumkbn2( [ vector( x, 4, -2, 6 ) ] ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -166,7 +166,7 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', 4.0 // 3 ]); - v = dsumkbn2( [vector( x, 4, 2, 1 )] ); + v = dsumkbn2( [ vector( x, 4, 2, 1 ) ] ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); From 4ec683082b14d2416581101a6da7312d334e9437 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 7 Dec 2025 17:23:06 -0800 Subject: [PATCH 5/9] docs: remove linebreak Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md index bc221a7a3ca1..e2a5296f57b9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md @@ -38,8 +38,7 @@ var dsumkbn2 = require( '@stdlib/blas/ext/base/ndarray/dsumkbn2' ); #### dsumkbn2( arrays ) -Computes the sum of all elements in a one-dimensional double-precision -floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. +Computes the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. ```javascript var Float64Array = require( '@stdlib/array/float64' ); From 3d8190247ebe9f2dc6cca5158a2b515a6f9d3322 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 8 Dec 2025 09:50:36 +0530 Subject: [PATCH 6/9] feat: spacing issues --- .../@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md | 3 ++- .../@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts | 4 ++-- .../@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md index e2a5296f57b9..9a62715f508e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md @@ -38,7 +38,8 @@ var dsumkbn2 = require( '@stdlib/blas/ext/base/ndarray/dsumkbn2' ); #### dsumkbn2( arrays ) -Computes the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. +Computes the sum of all elements in a one-dimensional double-precision floating-point +ndarray using a second-order iterative Kahan–Babuška algorithm. ```javascript var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts index c8d885ac784a..10df65417652 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts @@ -16,8 +16,8 @@ * limitations under the License. */ -import zeros = require('@stdlib/ndarray/zeros'); -import dsumkbn2 = require('./index'); +import zeros = require( '@stdlib/ndarray/zeros' ); +import dsumkbn2 = require( './index' ); // TESTS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js index 5b700733964f..0e38d048c3cd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js @@ -45,7 +45,7 @@ var strided = require( '@stdlib/blas/ext/base/dsumkbn2' ).ndarray; * var v = dsumkbn2( [ x ] ); * // returns 1.0 */ -function dsumkbn2(arrays) { +function dsumkbn2( arrays ) { var x = arrays[ 0 ]; return strided(numelDimension(x, 0), getData(x), getStride(x, 0), getOffset(x)); // eslint-disable-line max-len } From dd19b0466b9829eb4ed4ddec6d1ee8603a6ac9ed Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 7 Dec 2025 20:29:57 -0800 Subject: [PATCH 7/9] docs: fix desc Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md index 9a62715f508e..e2a5296f57b9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/README.md @@ -38,8 +38,7 @@ var dsumkbn2 = require( '@stdlib/blas/ext/base/ndarray/dsumkbn2' ); #### dsumkbn2( arrays ) -Computes the sum of all elements in a one-dimensional double-precision floating-point -ndarray using a second-order iterative Kahan–Babuška algorithm. +Computes the sum of all elements in a one-dimensional double-precision floating-point ndarray using a second-order iterative Kahan–Babuška algorithm. ```javascript var Float64Array = require( '@stdlib/array/float64' ); From e8e1a88b18f1fa41429a02af0ab6af23d021ec49 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 8 Dec 2025 10:22:11 +0530 Subject: [PATCH 8/9] spacing issues --- .../base/ndarray/dsumkbn2/docs/types/test.ts | 30 +++++++++---------- .../ext/base/ndarray/dsumkbn2/lib/main.js | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts index 10df65417652..667ff11b6483 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts @@ -24,32 +24,32 @@ import dsumkbn2 = require( './index' ); // The function returns a number... { - const x = zeros([ 10 ], { + const x = zeros( [ 10 ], { 'dtype': 'float64' - }); + } ); - dsumkbn2([ x ]); // $ExpectType number + dsumkbn2( [ x ] ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... { - dsumkbn2('10'); // $ExpectError - dsumkbn2(10); // $ExpectError - dsumkbn2(true); // $ExpectError - dsumkbn2(false); // $ExpectError - dsumkbn2(null); // $ExpectError - dsumkbn2(undefined); // $ExpectError - dsumkbn2([]); // $ExpectError - dsumkbn2({}); // $ExpectError - dsumkbn2((x: number): number => x); // $ExpectError + dsumkbn2( '10' ); // $ExpectError + dsumkbn2( 10 ); // $ExpectError + dsumkbn2( true ); // $ExpectError + dsumkbn2( false ); // $ExpectError + dsumkbn2( null ); // $ExpectError + dsumkbn2( undefined ); // $ExpectError + dsumkbn2( [] ); // $ExpectError + dsumkbn2( {} ); // $ExpectError + dsumkbn2( ( 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': 'float64' - }); + } ); dsumkbn2(); // $ExpectError - dsumkbn2([ x ], {}); // $ExpectError + dsumkbn2( [ x ], {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js index 0e38d048c3cd..f2ecc39ece86 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/lib/main.js @@ -47,7 +47,7 @@ var strided = require( '@stdlib/blas/ext/base/dsumkbn2' ).ndarray; */ function dsumkbn2( 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 } From 494a4f999c02dc088e0fe7629947953a9b3acebb Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 7 Dec 2025 21:33:39 -0800 Subject: [PATCH 9/9] style: adjust spacing Signed-off-by: Athan --- .../blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts index 667ff11b6483..3606635a2ef4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsumkbn2/docs/types/test.ts @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable space-in-parens */ + import zeros = require( '@stdlib/ndarray/zeros' ); import dsumkbn2 = require( './index' ); @@ -26,7 +28,7 @@ import dsumkbn2 = require( './index' ); { const x = zeros( [ 10 ], { 'dtype': 'float64' - } ); + }); dsumkbn2( [ x ] ); // $ExpectType number } @@ -48,7 +50,7 @@ import dsumkbn2 = require( './index' ); { const x = zeros( [ 10 ], { 'dtype': 'float64' - } ); + }); dsumkbn2(); // $ExpectError dsumkbn2( [ x ], {} ); // $ExpectError