From 27e9be88ad0d436c3b45e32fe5f6335a931ef418 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Wed, 17 Dec 2025 16:02:52 +0530 Subject: [PATCH 1/5] feat: add blas/ext/base/ndarray/dnansumors --- .../ext/base/ndarray/dnansumors/README.md | 126 ++++++++++++ .../ndarray/dnansumors/benchmark/benchmark.js | 117 +++++++++++ .../ext/base/ndarray/dnansumors/docs/repl.txt | 32 +++ .../ndarray/dnansumors/docs/types/index.d.ts | 46 +++++ .../ndarray/dnansumors/docs/types/test.ts | 57 ++++++ .../base/ndarray/dnansumors/examples/index.js | 40 ++++ .../ext/base/ndarray/dnansumors/lib/index.js | 45 +++++ .../ext/base/ndarray/dnansumors/lib/main.js | 56 ++++++ .../ext/base/ndarray/dnansumors/package.json | 72 +++++++ .../ext/base/ndarray/dnansumors/test/test.js | 188 ++++++++++++++++++ 10 files changed, 779 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/README.md new file mode 100644 index 000000000000..1e9f0d7dd36b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/README.md @@ -0,0 +1,126 @@ + + +# dnansumors + +> Compute the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. + +
+ +
+ + + +
+ +## Usage + +```javascript +var dnansumors = require( '@stdlib/blas/ext/base/ndarray/dnansumors' ); +``` + +#### dnansumors( arrays ) + +Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var xbuf = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); +var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); + +var v = dnansumors( [ 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`. +- Ordinary recursive summation (i.e., a "simple" sum) is performant, but can incur significant numerical error. If performance is paramount and error tolerated, using ordinary recursive summation is acceptable; in all other cases, exercise due caution. + +
+ + + +
+ +## Examples + + + +```javascript +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var dnansumors = require( '@stdlib/blas/ext/base/ndarray/dnansumors' ); + +function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( 0, 100 ); + } + return NaN; +} + +var xbuf = filledarrayBy( 10, 'float64', clbk ); +var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var v = dnansumors( [ x ] ); +console.log( v ); +``` + +
+ + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/benchmark/benchmark.js new file mode 100644 index 000000000000..e0a4eea23064 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/benchmark/benchmark.js @@ -0,0 +1,117 @@ +/** +* @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/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +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 dnansumors = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Returns a random number or NaN. +* +* @private +* @returns {number} random number or NaN +*/ +function rand() { + if ( bernoulli( 0.8 ) > 0 ) { + return uniform( -10.0, 10.0 ); + } + return NaN; +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var x; + + xbuf = filledarrayBy( len, options.dtype, rand ); + 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 = dnansumors( [ 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/dnansumors/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/repl.txt new file mode 100644 index 000000000000..49f94cf10834 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( arrays ) + Computes the sum of a one-dimensional double-precision floating-point + ndarray, ignoring `NaN` values and using ordinary recursive summation. + + 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, NaN, 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/dnansumors/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/index.d.ts new file mode 100644 index 000000000000..6e90274fb809 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/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 a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +* +* @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, NaN, 2.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var v = dnansumors( [ x ] ); +* // returns 1.0 +*/ +declare function dnansumors( arrays: [ float64ndarray ] ): number; + + +// EXPORTS // + +export = dnansumors; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/test.ts new file mode 100644 index 000000000000..973f99c23e0e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/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 dnansumors = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + + dnansumors( [ x ] ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + dnansumors( '10' ); // $ExpectError + dnansumors( 10 ); // $ExpectError + dnansumors( true ); // $ExpectError + dnansumors( false ); // $ExpectError + dnansumors( null ); // $ExpectError + dnansumors( undefined ); // $ExpectError + dnansumors( [] ); // $ExpectError + dnansumors( {} ); // $ExpectError + dnansumors( ( 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' + }); + + dnansumors(); // $ExpectError + dnansumors( [ x ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/examples/index.js new file mode 100644 index 000000000000..dc63bb18c626 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/examples/index.js @@ -0,0 +1,40 @@ +/** +* @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 bernoulli = require( '@stdlib/random/base/bernoulli' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var dnansumors = require( './../lib' ); + +function clbk() { + if ( bernoulli( 0.7 ) > 0 ) { + return discreteUniform( 0, 100 ); + } + return NaN; +} + +var xbuf = filledarrayBy( 10, 'float64', clbk ); +var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var v = dnansumors( [ x ] ); +console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/index.js new file mode 100644 index 000000000000..43bbcd460fad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/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 a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +* +* @module @stdlib/blas/ext/base/ndarray/dnansumors +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var dnansumors = require( '@stdlib/blas/ext/base/ndarray/dnansumors' ); +* +* var xbuf = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var v = dnansumors( [ 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/dnansumors/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/main.js new file mode 100644 index 000000000000..66d28a382dc1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/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/dnansumors' ).ndarray; + + +// MAIN // + +/** +* Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +* +* @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, NaN, 2.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var v = dnansumors( [ x ] ); +* // returns 1.0 +*/ +function dnansumors( 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 = dnansumors; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/package.json new file mode 100644 index 000000000000..845185426018 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/dnansumors", + "version": "0.0.0", + "description": "Compute the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation.", + "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", + "ordinary", + "recursive", + "ndarray", + "float64", + "double", + "float64array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/test/test.js new file mode 100644 index 000000000000..57ae2ddd64f4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/test/test.js @@ -0,0 +1,188 @@ +/** +* @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 isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var dnansumors = 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 dnansumors, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( dnansumors.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function computes the sum of a one-dimensional ndarray, ignoring `NaN` values and using ordinary recursive summation', function test( t ) { + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, NaN, 3.0, 0.0, -3.0, 3.0, NaN ] ); // eslint-disable-line max-len + v = dnansumors( [ vector( x, 11, 1, 0 ) ] ); + t.strictEqual( v, 3.0, 'returns expected value' ); + + x = new Float64Array( [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, 3.0, NaN ] ); + v = dnansumors( [ vector( x, 8, 1, 0 ) ] ); + t.strictEqual( v, 3.0, 'returns expected value' ); + + x = new Float64Array( [ -4.0, NaN, -4.0 ] ); + v = dnansumors( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( v, -8.0, 'returns expected value' ); + + x = new Float64Array( [ NaN, 4.0 ] ); + v = dnansumors( [ vector( x, 2, 1, 0 ) ] ); + t.strictEqual( v, 4.0, 'returns expected value' ); + + x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); + v = dnansumors( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + x = new Float64Array( [ NaN, NaN ] ); + v = dnansumors( [ vector( x, 2, 1, 0 ) ] ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Float64Array( [ NaN ] ); + v = dnansumors( [ vector( x, 1, 1, 0 ) ] ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + x = new Float64Array( [ 4.0 ] ); + v = dnansumors( [ vector( x, 1, 1, 0 ) ] ); + t.strictEqual( v, 4.0, 'returns expected value' ); + + x = new Float64Array( [ 1.0, 1.0e100, 1.0, -1.0e100 ] ); + v = dnansumors( [ vector( x, 4, 1, 0 ) ] ); + t.strictEqual( v, 2.0, '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 = dnansumors( [ 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 = dnansumors( [ 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 = dnansumors( [ 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 = dnansumors( [ 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 = dnansumors( [ vector( x, 4, 2, 1 ) ] ); + t.strictEqual( v, 5.0, 'returns expected value' ); + + t.end(); +}); From 4a709fb5a6550cddbe2f5bfaac19d3675465226a Mon Sep 17 00:00:00 2001 From: kaustubh Date: Thu, 18 Dec 2025 21:17:52 +0530 Subject: [PATCH 2/5] feat: add blas/ext/base/ndarray/snansumors --- .../{dnansumors => snansumors}/README.md | 26 +++---- .../benchmark/benchmark.js | 13 ++-- .../{dnansumors => snansumors}/docs/repl.txt | 6 +- .../docs/types/index.d.ts | 16 ++-- .../docs/types/test.ts | 31 ++++---- .../examples/index.js | 8 +- .../{dnansumors => snansumors}/lib/index.js | 15 ++-- .../{dnansumors => snansumors}/lib/main.js | 16 ++-- .../{dnansumors => snansumors}/package.json | 10 +-- .../{dnansumors => snansumors}/test/test.js | 75 +++++++++---------- 10 files changed, 106 insertions(+), 110 deletions(-) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/README.md (80%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/benchmark/benchmark.js (91%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/docs/repl.txt (80%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/docs/types/index.d.ts (70%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/docs/types/test.ts (65%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/examples/index.js (85%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/lib/index.js (70%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/lib/main.js (77%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/package.json (89%) rename lib/node_modules/@stdlib/blas/ext/base/ndarray/{dnansumors => snansumors}/test/test.js (63%) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/README.md similarity index 80% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/README.md rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/README.md index 1e9f0d7dd36b..436710c54dd2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/README.md @@ -18,9 +18,9 @@ limitations under the License. --> -# dnansumors +# snansumors -> Compute the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +> Compute the sum of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation.
@@ -33,21 +33,21 @@ limitations under the License. ## Usage ```javascript -var dnansumors = require( '@stdlib/blas/ext/base/ndarray/dnansumors' ); +var snansumors = require( '@stdlib/blas/ext/base/ndarray/snansumors' ); ``` -#### dnansumors( arrays ) +#### snansumors( arrays ) -Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +Computes the sum of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. ```javascript -var Float64Array = require( '@stdlib/array/float64' ); +var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var xbuf = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +var xbuf = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); +var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); -var v = dnansumors( [ x ] ); +var v = snansumors( [ x ] ); // returns 1.0 ``` @@ -82,7 +82,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); -var dnansumors = require( '@stdlib/blas/ext/base/ndarray/dnansumors' ); +var snansumors = require( '@stdlib/blas/ext/base/ndarray/snansumors' ); function clbk() { if ( bernoulli( 0.7 ) > 0 ) { @@ -91,11 +91,11 @@ function clbk() { return NaN; } -var xbuf = filledarrayBy( 10, 'float64', clbk ); -var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +var xbuf = filledarrayBy( 10, 'float32', clbk ); +var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); console.log( ndarray2array( x ) ); -var v = dnansumors( [ x ] ); +var v = snansumors( [ x ] ); console.log( v ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/benchmark/benchmark.js similarity index 91% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/benchmark/benchmark.js rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/benchmark/benchmark.js index e0a4eea23064..b0b56c23b4f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/benchmark/benchmark.js @@ -24,17 +24,16 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/base/uniform' ); var bernoulli = require( '@stdlib/random/base/bernoulli' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var pkg = require( './../package.json' ).name; -var dnansumors = require( './../lib' ); - +var snansumors = require( './../lib' ); // VARIABLES // var options = { - 'dtype': 'float64' + 'dtype': 'float32' }; @@ -75,13 +74,13 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = dnansumors( [ x ] ); - if ( isnan( v ) ) { + v = snansumors( [ x ] ); + if ( isnanf( v ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( v ) ) { + if ( isnanf( v ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/repl.txt similarity index 80% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/repl.txt rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/repl.txt index 49f94cf10834..da3f88829ce9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( arrays ) - Computes the sum of a one-dimensional double-precision floating-point + Computes the sum of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. If provided an empty ndarray, the function returns `0.0`. @@ -17,8 +17,8 @@ Examples -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] ); - > var dt = 'float64'; + > var xbuf = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, NaN, 2.0 ] ); + > var dt = 'float32'; > var sh = [ xbuf.length ]; > var sx = [ 1 ]; > var ox = 0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/types/index.d.ts similarity index 70% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/index.d.ts rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/types/index.d.ts index 6e90274fb809..b112601bcbd4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/types/index.d.ts @@ -20,27 +20,27 @@ /// -import { float64ndarray } from '@stdlib/types/ndarray'; +import { float32ndarray } from '@stdlib/types/ndarray'; /** -* Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +* Computes the sum of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. * * @param arrays - array-like object containing an input ndarray * @returns sum * * @example -* var Float64Array = require( '@stdlib/array/float64' ); +* var Float32Array = require( '@stdlib/array/float32' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * -* var xbuf = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* var xbuf = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); * -* var v = dnansumors( [ x ] ); +* var v = snansumors( [ x ] ); * // returns 1.0 */ -declare function dnansumors( arrays: [ float64ndarray ] ): number; +declare function snansumors( arrays: [ float32ndarray ] ): number; // EXPORTS // -export = dnansumors; +export = snansumors; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/types/test.ts similarity index 65% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/test.ts rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/types/test.ts index 973f99c23e0e..4d88794eaed3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/docs/types/test.ts @@ -19,39 +19,38 @@ /* eslint-disable space-in-parens */ import zeros = require( '@stdlib/ndarray/zeros' ); -import dnansumors = require( './index' ); - +import snansumors = require( './index' ); // TESTS // // The function returns a number... { const x = zeros( [ 10 ], { - 'dtype': 'float64' + 'dtype': 'float32' }); - dnansumors( [ x ] ); // $ExpectType number + snansumors( [ x ] ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... { - dnansumors( '10' ); // $ExpectError - dnansumors( 10 ); // $ExpectError - dnansumors( true ); // $ExpectError - dnansumors( false ); // $ExpectError - dnansumors( null ); // $ExpectError - dnansumors( undefined ); // $ExpectError - dnansumors( [] ); // $ExpectError - dnansumors( {} ); // $ExpectError - dnansumors( ( x: number ): number => x ); // $ExpectError + snansumors( '10' ); // $ExpectError + snansumors( 10 ); // $ExpectError + snansumors( true ); // $ExpectError + snansumors( false ); // $ExpectError + snansumors( null ); // $ExpectError + snansumors( undefined ); // $ExpectError + snansumors( [] ); // $ExpectError + snansumors( {} ); // $ExpectError + snansumors( ( 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' + 'dtype': 'float32' }); - dnansumors(); // $ExpectError - dnansumors( [ x ], {} ); // $ExpectError + snansumors(); // $ExpectError + snansumors( [ x ], {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/examples/index.js similarity index 85% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/examples/index.js rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/examples/index.js index dc63bb18c626..946107b0d30b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/examples/index.js @@ -23,7 +23,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); -var dnansumors = require( './../lib' ); +var snansumors = require( './../lib' ); function clbk() { if ( bernoulli( 0.7 ) > 0 ) { @@ -32,9 +32,9 @@ function clbk() { return NaN; } -var xbuf = filledarrayBy( 10, 'float64', clbk ); -var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +var xbuf = filledarrayBy( 10, 'float32', clbk ); +var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); console.log( ndarray2array( x ) ); -var v = dnansumors( [ x ] ); +var v = snansumors( [ x ] ); console.log( v ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js similarity index 70% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/index.js rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js index 43bbcd460fad..933dc6233d3b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js @@ -19,19 +19,19 @@ 'use strict'; /** -* Compute the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +* Compute the sum of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. * -* @module @stdlib/blas/ext/base/ndarray/dnansumors +* @module @stdlib/blas/ext/base/ndarray/snansumors * * @example -* var Float64Array = require( '@stdlib/array/float64' ); +* var Float32Array = require( '@stdlib/array/float32' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); -* var dnansumors = require( '@stdlib/blas/ext/base/ndarray/dnansumors' ); +* var snansumors = require( '@stdlib/blas/ext/base/ndarray/snansumors' ); * -* var xbuf = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* var xbuf = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); * -* var v = dnansumors( [ x ] ); +* var v = snansumors( [ x ] ); * // returns 1.0 */ @@ -39,7 +39,6 @@ var main = require( './main.js' ); - // EXPORTS // module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/main.js similarity index 77% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/main.js rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/main.js index 66d28a382dc1..2a11e6a12eea 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/main.js @@ -24,28 +24,28 @@ 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/dnansumors' ).ndarray; +var strided = require( '@stdlib/blas/ext/base/snansumors' ).ndarray; // MAIN // /** -* Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. +* Computes the sum of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation. * * @param {ArrayLikeObject} arrays - array-like object containing an input ndarray * @returns {number} sum * * @example -* var Float64Array = require( '@stdlib/array/float64' ); +* var Float32Array = require( '@stdlib/array/float32' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * -* var xbuf = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); +* var xbuf = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' ); * -* var v = dnansumors( [ x ] ); +* var v = snansumors( [ x ] ); * // returns 1.0 */ -function dnansumors( arrays ) { +function snansumors( arrays ) { var x = arrays[ 0 ]; return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len } @@ -53,4 +53,4 @@ function dnansumors( arrays ) { // EXPORTS // -module.exports = dnansumors; +module.exports = snansumors; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/package.json similarity index 89% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/package.json rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/package.json index 845185426018..5c9fb9c66dd1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/package.json @@ -1,7 +1,7 @@ { - "name": "@stdlib/blas/ext/base/ndarray/dnansumors", + "name": "@stdlib/blas/ext/base/ndarray/snansumors", "version": "0.0.0", - "description": "Compute the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation.", + "description": "Compute the sum of a one-dimensional single-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -64,9 +64,9 @@ "ordinary", "recursive", "ndarray", - "float64", - "double", - "float64array" + "float32", + "single", + "float32array" ], "__stdlib__": {} } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js similarity index 63% rename from lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/test/test.js rename to lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js index 57ae2ddd64f4..2ad232405a95 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansumors/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js @@ -21,11 +21,10 @@ // MODULES // var tape = require( 'tape' ); -var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); -var Float64Array = require( '@stdlib/array/float64' ); +var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); +var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var dnansumors = require( './../lib' ); - +var snansumors = require( './../lib' ); // FUNCTIONS // @@ -33,14 +32,14 @@ var dnansumors = require( './../lib' ); * Returns a one-dimensional ndarray. * * @private -* @param {Float64Array} buffer - underlying data buffer +* @param {Float32Array} 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' ); + return new ndarray( 'float32', buffer, [ length ], [ stride ], offset, 'row-major' ); } @@ -48,12 +47,12 @@ function vector( buffer, length, stride, offset ) { tape( 'main export is a function', function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof dnansumors, 'function', 'main export is a function' ); + t.strictEqual( typeof snansumors, 'function', 'main export is a function' ); t.end(); }); tape( 'the function has an arity of 1', function test( t ) { - t.strictEqual( dnansumors.length, 1, 'has expected arity' ); + t.strictEqual( snansumors.length, 1, 'has expected arity' ); t.end(); }); @@ -61,40 +60,40 @@ tape( 'the function computes the sum of a one-dimensional ndarray, ignoring `NaN var x; var v; - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, NaN, 3.0, 0.0, -3.0, 3.0, NaN ] ); // eslint-disable-line max-len - v = dnansumors( [ vector( x, 11, 1, 0 ) ] ); + x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, NaN, 3.0, 0.0, -3.0, 3.0, NaN ] ); // eslint-disable-line max-len + v = snansumors( [ vector( x, 11, 1, 0 ) ] ); t.strictEqual( v, 3.0, 'returns expected value' ); - x = new Float64Array( [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, 3.0, NaN ] ); - v = dnansumors( [ vector( x, 8, 1, 0 ) ] ); + x = new Float32Array( [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, 3.0, NaN ] ); + v = snansumors( [ vector( x, 8, 1, 0 ) ] ); t.strictEqual( v, 3.0, 'returns expected value' ); - x = new Float64Array( [ -4.0, NaN, -4.0 ] ); - v = dnansumors( [ vector( x, 3, 1, 0 ) ] ); + x = new Float32Array( [ -4.0, NaN, -4.0 ] ); + v = snansumors( [ vector( x, 3, 1, 0 ) ] ); t.strictEqual( v, -8.0, 'returns expected value' ); - x = new Float64Array( [ NaN, 4.0 ] ); - v = dnansumors( [ vector( x, 2, 1, 0 ) ] ); + x = new Float32Array( [ NaN, 4.0 ] ); + v = snansumors( [ vector( x, 2, 1, 0 ) ] ); t.strictEqual( v, 4.0, 'returns expected value' ); - x = new Float64Array( [ -0.0, 0.0, -0.0 ] ); - v = dnansumors( [ vector( x, 3, 1, 0 ) ] ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + x = new Float32Array( [ -0.0, 0.0, -0.0 ] ); + v = snansumors( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( isPositiveZerof( v ), true, 'returns expected value' ); - x = new Float64Array( [ NaN, NaN ] ); - v = dnansumors( [ vector( x, 2, 1, 0 ) ] ); + x = new Float32Array( [ NaN, NaN ] ); + v = snansumors( [ vector( x, 2, 1, 0 ) ] ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Float64Array( [ NaN ] ); - v = dnansumors( [ vector( x, 1, 1, 0 ) ] ); + x = new Float32Array( [ NaN ] ); + v = snansumors( [ vector( x, 1, 1, 0 ) ] ); t.strictEqual( v, 0.0, 'returns expected value' ); - x = new Float64Array( [ 4.0 ] ); - v = dnansumors( [ vector( x, 1, 1, 0 ) ] ); + x = new Float32Array( [ 4.0 ] ); + v = snansumors( [ vector( x, 1, 1, 0 ) ] ); t.strictEqual( v, 4.0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0e100, 1.0, -1.0e100 ] ); - v = dnansumors( [ vector( x, 4, 1, 0 ) ] ); + x = new Float32Array( [ 1.0, 1.0e38, 1.0, -1.0e38 ] ); + v = snansumors( [ vector( x, 4, 1, 0 ) ] ); t.strictEqual( v, 2.0, 'returns expected value' ); t.end(); @@ -104,10 +103,10 @@ tape( 'if provided an empty ndarray, the function returns `0.0`', function test( var x; var v; - x = new Float64Array( [] ); + x = new Float32Array( [] ); - v = dnansumors( [ vector( x, 0, 1, 0 ) ] ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + v = snansumors( [ vector( x, 0, 1, 0 ) ] ); + t.strictEqual( isPositiveZerof( v ), true, 'returns expected value' ); t.end(); }); @@ -116,9 +115,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 Float32Array( [ 1.0 ] ); - v = dnansumors( [ vector( x, 1, 1, 0 ) ] ); + v = snansumors( [ vector( x, 1, 1, 0 ) ] ); t.strictEqual( v, 1.0, 'returns expected value' ); t.end(); @@ -128,7 +127,7 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', var x; var v; - x = new Float64Array([ + x = new Float32Array([ 1.0, // 0 2.0, 2.0, // 1 @@ -139,7 +138,7 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', 2.0 ]); - v = dnansumors( [ vector( x, 4, 2, 0 ) ] ); + v = snansumors( [ vector( x, 4, 2, 0 ) ] ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -149,7 +148,7 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', var x; var v; - x = new Float64Array([ + x = new Float32Array([ 1.0, // 3 2.0, 2.0, // 2 @@ -160,7 +159,7 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', 2.0 ]); - v = dnansumors( [ vector( x, 4, -2, 6 ) ] ); + v = snansumors( [ vector( x, 4, -2, 6 ) ] ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -170,7 +169,7 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', var x; var v; - x = new Float64Array([ + x = new Float32Array([ 2.0, 1.0, // 0 2.0, @@ -181,7 +180,7 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', 4.0 // 3 ]); - v = dnansumors( [ vector( x, 4, 2, 1 ) ] ); + v = snansumors( [ vector( x, 4, 2, 1 ) ] ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); From 80f9ecfb2b81f949e8a53a1200cfe623713fbeac Mon Sep 17 00:00:00 2001 From: kaustubh Date: Thu, 18 Dec 2025 21:44:02 +0530 Subject: [PATCH 3/5] lint --- .../@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js | 1 + .../@stdlib/blas/ext/base/ndarray/snansumors/test/test.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js index 933dc6233d3b..54d7f5c19c76 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/lib/index.js @@ -39,6 +39,7 @@ var main = require( './main.js' ); + // EXPORTS // module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js index 2ad232405a95..511a18b461be 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js @@ -94,7 +94,7 @@ tape( 'the function computes the sum of a one-dimensional ndarray, ignoring `NaN x = new Float32Array( [ 1.0, 1.0e38, 1.0, -1.0e38 ] ); v = snansumors( [ vector( x, 4, 1, 0 ) ] ); - t.strictEqual( v, 2.0, 'returns expected value' ); + t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); }); From 0be9cc9b0e36f622fed7db6a5e818bebc3ccaaf8 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Thu, 18 Dec 2025 21:48:51 +0530 Subject: [PATCH 4/5] fix: add missing empty line before section header --- .../@stdlib/blas/ext/base/ndarray/snansumors/test/test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js index 511a18b461be..45d0fdf5f77a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/test/test.js @@ -26,6 +26,7 @@ var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var snansumors = require( './../lib' ); + // FUNCTIONS // /** From e3eb6d4b80ae74c77eb65e9fb7f45ef275362baa Mon Sep 17 00:00:00 2001 From: kaustubh Date: Thu, 18 Dec 2025 21:50:48 +0530 Subject: [PATCH 5/5] fix: add missing empty line before section header --- .../blas/ext/base/ndarray/snansumors/benchmark/benchmark.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/benchmark/benchmark.js index b0b56c23b4f2..907063a05b34 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansumors/benchmark/benchmark.js @@ -30,6 +30,7 @@ var ndarray = require( '@stdlib/ndarray/base/ctor' ); var pkg = require( './../package.json' ).name; var snansumors = require( './../lib' ); + // VARIABLES // var options = {