From 81f76a53d2f7bc0180c7d6afc87d2843ca4fd3e3 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 30 Mar 2026 01:56:40 +0530 Subject: [PATCH 1/6] feat: add blas/base/ndarray/dasum --- .../@stdlib/blas/base/ndarray/dasum/README.md | 127 +++++++++++++++ .../base/ndarray/dasum/benchmark/benchmark.js | 109 +++++++++++++ .../dasum/docs/img/equation_l1norm.svg | 44 +++++ .../blas/base/ndarray/dasum/docs/repl.txt | 32 ++++ .../base/ndarray/dasum/docs/types/index.d.ts | 46 ++++++ .../base/ndarray/dasum/docs/types/test.ts | 57 +++++++ .../blas/base/ndarray/dasum/examples/index.js | 35 ++++ .../blas/base/ndarray/dasum/lib/index.js | 45 +++++ .../blas/base/ndarray/dasum/lib/main.js | 55 +++++++ .../blas/base/ndarray/dasum/package.json | 71 ++++++++ .../blas/base/ndarray/dasum/test/test.js | 154 ++++++++++++++++++ 11 files changed, 775 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/img/equation_l1norm.svg create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md new file mode 100644 index 000000000000..20cd44a34c75 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md @@ -0,0 +1,127 @@ + + +# dasum + +> Calculate the sum of absolute values of one-dimensional double-precision floating-point ndarray. + +
+ +The [_L1_ norm][l1norm] is defined as + + + +```math +\|\mathbf{x}\|_1 = \sum_{i=0}^{n-1} \vert x_i \vert +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var dasum = require( '@stdlib/blas/base/ndarray/dasum' ); +``` + +#### dasum( arrays ) + +Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var xbuf = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0 ] ); +var x = new ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); + +var y = dasum( [ x ] ); +// returns 15.0 +``` + +The function has the following parameters: + +- **arrays**: array-like object containing one-dimensional input ndarray. + +
+ + + +
+ +
+ + + +
+ +## 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 dasum = require( '@stdlib/blas/base/ndarray/dasum' ); + +var opts = { + 'dtype': 'float64' +}; + +var xbuf = discreteUniform( 10, -500, 500, opts ); +var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var out = dasum( [ x ] ); +console.log( out ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/benchmark/benchmark.js new file mode 100644 index 000000000000..8a4ef4422fbc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/benchmark/benchmark.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dasum = 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, -100.0, 100.0, options ); + x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dasum( [ x ] ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + 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( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/img/equation_l1norm.svg b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/img/equation_l1norm.svg new file mode 100644 index 000000000000..4dbb928da546 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/img/equation_l1norm.svg @@ -0,0 +1,44 @@ + +double-vertical-bar bold x double-vertical-bar Subscript 1 Baseline equals sigma-summation Underscript i equals 0 Overscript n minus 1 Endscripts StartAbsoluteValue x Subscript i Baseline EndAbsoluteValue + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt new file mode 100644 index 000000000000..4e2bbadb62af --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( arrays ) + Computes the sum of absolute values of one-dimensional double-precision + floating-point ndarray. + + If provided an empty input ndarray, the function returns `0.0`. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing one-dimensional input ndarray. + + Returns + ------- + out: number + The sum of absolute values. + + Examples + -------- + > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0 ] ); + > var dt = 'float64'; + > var sh = [ xbuf.length ]; + > var st = [ 1 ]; + > var oo = 0; + > var ord = 'row-major'; + > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, st, oo, ord ); + > {{alias}}( [ x ] ) + 15.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts new file mode 100644 index 000000000000..5739e79955ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts @@ -0,0 +1,46 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 absolute values of one-dimensional double-precision floating-point ndarray. +* +* @param arrays - array-like object containing one-dimensional 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, 3.0, -4.0, 5.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* var y = dasum( [ x ] ); +* // returns 15.0 +*/ +declare function dasum( arrays: [ float64ndarray ] ): number; + + +// EXPORTS // + +export = dasum; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/test.ts new file mode 100644 index 000000000000..2a540fc412fa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/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 dasum = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + + dasum( [ x ] ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + dasum( '10' ); // $ExpectError + dasum( 10 ); // $ExpectError + dasum( true ); // $ExpectError + dasum( false ); // $ExpectError + dasum( null ); // $ExpectError + dasum( undefined ); // $ExpectError + dasum( [] ); // $ExpectError + dasum( {} ); // $ExpectError + dasum( ( 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' + }); + + dasum(); // $ExpectError + dasum( [ x ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/examples/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/examples/index.js new file mode 100644 index 000000000000..24eae860b500 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 dasum = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var xbuf = discreteUniform( 10, -500, 500, opts ); +var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var out = dasum( [ x ] ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js new file mode 100644 index 000000000000..504e010ce428 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* BLAS level 1 routine to compute the sum of absolute values of one-dimensional double-precision floating-point ndarray. +* +* @module @stdlib/blas/base/ndarray/dasum +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var dasum = require( '@stdlib/blas/base/ndarray/dasum' ); +* +* var xbuf = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* var y = dasum( [ x ] ); +* // returns 15.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js new file mode 100644 index 000000000000..dce7857bace5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/base/dasum' ).ndarray; + + +// MAIN // + +/** +* Computes the sum of absolute values of one-dimensional double-precision floating-point ndarray. +* +* @param {ArrayLikeObject} arrays - array-like object containing one-dimensional 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, 3.0, -4.0, 5.0 ] ); +* var x = new ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* var y = dasum( [ x ] ); +* // returns 15.0 +*/ +function dasum( arrays ) { + var x = arrays[ 0 ]; + return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); +} + + +// EXPORTS // + +module.exports = dasum; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json new file mode 100644 index 000000000000..33d7f36285ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/blas/base/ndarray/dasum", + "version": "0.0.0", + "description": "Compute the sum of absolute values of one-dimensional double-precision floating-point ndarray.", + "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", + "mathematics", + "math", + "blas", + "level 1", + "linear", + "algebra", + "subroutines", + "dasum", + "sasum", + "asum", + "sum", + "absolute", + "absolute value", + "norm", + "vector", + "ndarray" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js new file mode 100644 index 000000000000..0796f4d5ad59 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var dasum = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} 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 dasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( dasum.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function calculates the sum of absolute values of one-dimensional ndarray', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0 ] ); + x = vector( xbuf, 5, 1, 0 ); + y = dasum( [ x ] ); + + t.strictEqual( y, 15.0, 'returns expected value' ); + + xbuf = new Float64Array( [ -4.0, -2.0 ] ); + x = vector( xbuf, 2, 1, 0 ); + y = dasum( [ x ] ); + + t.strictEqual( y, 6.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an empty vector, the function returns `0.0`', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Float64Array( [] ); + x = vector( xbuf, 0, 1, 0 ); + + y = dasum( [ x ] ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Float64Array([ + 1.0, // 0 + -3.0, + -5.0, // 1 + 7.0, + 6.0 // 2 + ]); + x = vector( xbuf, 3, 2, 0 ); + + y = dasum( [ x ] ); + t.strictEqual( y, 12.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + x = vector( xbuf, 3, -2, 4 ); + + y = dasum( [ x ] ); + t.strictEqual( y, 9.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]); + x = vector( xbuf, 4, 2, 1 ); + + y = dasum( [ x ] ); + t.strictEqual( y, 9.0, 'returns expected value' ); + + t.end(); +}); From a4838b2228c29156734ff0999b18e4a20a383df0 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 30 Mar 2026 02:06:50 +0530 Subject: [PATCH 2/6] Add empty line before example --- .../@stdlib/blas/base/ndarray/dasum/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/test.ts index 2a540fc412fa..537c34ce200b 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js index dce7857bace5..279c6f10f585 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js @@ -34,6 +34,7 @@ var strided = require( '@stdlib/blas/base/dasum' ).ndarray; * * @param {ArrayLikeObject} arrays - array-like object containing one-dimensional input ndarray * @returns {number} sum +* * @example * var Float64Array = require( '@stdlib/array/float64' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); @@ -46,7 +47,7 @@ var strided = require( '@stdlib/blas/base/dasum' ).ndarray; */ function dasum( arrays ) { var x = arrays[ 0 ]; - return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); + return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len } From 84d6184cc0f38f7b01beb0d6962e5585f8d79e09 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 29 Mar 2026 13:44:31 -0700 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md | 4 ++-- .../@stdlib/blas/base/ndarray/dasum/docs/repl.txt | 4 ++-- .../@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js | 4 ++-- lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md index 20cd44a34c75..1b1537a96719 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md @@ -20,7 +20,7 @@ limitations under the License. # dasum -> Calculate the sum of absolute values of one-dimensional double-precision floating-point ndarray. +> Calculate the sum of absolute values of a one-dimensional double-precision floating-point ndarray.
@@ -68,7 +68,7 @@ var y = dasum( [ x ] ); The function has the following parameters: -- **arrays**: array-like object containing one-dimensional input ndarray. +- **arrays**: array-like object containing a one-dimensional input ndarray.
diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt index 4e2bbadb62af..c1d6da2c2b49 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( arrays ) - Computes the sum of absolute values of one-dimensional double-precision + Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. If provided an empty input ndarray, the function returns `0.0`. @@ -8,7 +8,7 @@ Parameters ---------- arrays: ArrayLikeObject - Array-like object containing one-dimensional input ndarray. + Array-like object containing a one-dimensional input ndarray. Returns ------- diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts index 5739e79955ae..37d88f291256 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts @@ -23,7 +23,7 @@ import { float64ndarray } from '@stdlib/types/ndarray'; /** -* Computes the sum of absolute values of one-dimensional double-precision floating-point ndarray. +* Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. * * @param arrays - array-like object containing one-dimensional input ndarray * @returns sum diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js index 504e010ce428..017748865012 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 1 routine to compute the sum of absolute values of one-dimensional double-precision floating-point ndarray. +* BLAS level 1 routine to compute the sum of absolute values of a one-dimensional double-precision floating-point ndarray. * * @module @stdlib/blas/base/ndarray/dasum * diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js index 279c6f10f585..cdebca02df98 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js @@ -30,9 +30,9 @@ var strided = require( '@stdlib/blas/base/dasum' ).ndarray; // MAIN // /** -* Computes the sum of absolute values of one-dimensional double-precision floating-point ndarray. +* Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. * -* @param {ArrayLikeObject} arrays - array-like object containing one-dimensional input ndarray +* @param {ArrayLikeObject} arrays - array-like object containing a one-dimensional input ndarray * @returns {number} sum * * @example diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json index 33d7f36285ae..f9e796a1cd5d 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/ndarray/dasum", "version": "0.0.0", - "description": "Compute the sum of absolute values of one-dimensional double-precision floating-point ndarray.", + "description": "Compute the sum of absolute values of a one-dimensional double-precision floating-point ndarray.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js index 0796f4d5ad59..7d9d53be821e 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js @@ -56,7 +56,7 @@ tape( 'the function has an arity of 1', function test( t ) { t.end(); }); -tape( 'the function calculates the sum of absolute values of one-dimensional ndarray', function test( t ) { +tape( 'the function calculates the sum of absolute values of a one-dimensional ndarray', function test( t ) { var xbuf; var x; var y; From 7beec8c681804c8b20bae611e04b499f8021abb1 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 29 Mar 2026 13:45:36 -0700 Subject: [PATCH 4/6] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts index 37d88f291256..6543531b21bc 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts @@ -25,7 +25,7 @@ import { float64ndarray } from '@stdlib/types/ndarray'; /** * Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. * -* @param arrays - array-like object containing one-dimensional input ndarray +* @param arrays - array-like object containing a one-dimensional input ndarray * @returns sum * * @example From d84d6eaa869124d769c5f455981e890dcde8876d Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 29 Mar 2026 13:55:13 -0700 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md | 4 ++-- .../@stdlib/blas/base/ndarray/dasum/docs/repl.txt | 4 ++-- .../@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json | 2 +- lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md index 1b1537a96719..9dc08c7c6dd4 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/README.md @@ -20,7 +20,7 @@ limitations under the License. # dasum -> Calculate the sum of absolute values of a one-dimensional double-precision floating-point ndarray. +> Calculate the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray.
@@ -53,7 +53,7 @@ var dasum = require( '@stdlib/blas/base/ndarray/dasum' ); #### dasum( arrays ) -Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. +Computes the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray. ```javascript var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt index c1d6da2c2b49..3ae9fff65a0d 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( arrays ) - Computes the sum of absolute values of a one-dimensional double-precision - floating-point ndarray. + Computes the sum of absolute values for all elements in a one-dimensional + double-precision floating-point ndarray. If provided an empty input ndarray, the function returns `0.0`. diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts index 6543531b21bc..ee11f1ec1fd8 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/docs/types/index.d.ts @@ -23,7 +23,7 @@ import { float64ndarray } from '@stdlib/types/ndarray'; /** -* Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. +* Computes the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray. * * @param arrays - array-like object containing a one-dimensional input ndarray * @returns sum diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js index 017748865012..38f71c43554d 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 1 routine to compute the sum of absolute values of a one-dimensional double-precision floating-point ndarray. +* BLAS level 1 routine to compute the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray. * * @module @stdlib/blas/base/ndarray/dasum * diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js index cdebca02df98..f36a3bda9be7 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/lib/main.js @@ -30,7 +30,7 @@ var strided = require( '@stdlib/blas/base/dasum' ).ndarray; // MAIN // /** -* Computes the sum of absolute values of a one-dimensional double-precision floating-point ndarray. +* Computes the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray. * * @param {ArrayLikeObject} arrays - array-like object containing a one-dimensional input ndarray * @returns {number} sum diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json index f9e796a1cd5d..6e1f3649fd48 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/ndarray/dasum", "version": "0.0.0", - "description": "Compute the sum of absolute values of a one-dimensional double-precision floating-point ndarray.", + "description": "Compute the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js index 7d9d53be821e..7fc11858829d 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js @@ -56,7 +56,7 @@ tape( 'the function has an arity of 1', function test( t ) { t.end(); }); -tape( 'the function calculates the sum of absolute values of a one-dimensional ndarray', function test( t ) { +tape( 'the function calculates the sum of absolute values for all elements in a one-dimensional ndarray', function test( t ) { var xbuf; var x; var y; From dd00c2fac2f5ec7b189691888bf7abd93c93bbcf Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 29 Mar 2026 13:57:58 -0700 Subject: [PATCH 6/6] Apply suggestion Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js index 7fc11858829d..d416ac8b809b 100644 --- a/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/ndarray/dasum/test/test.js @@ -76,7 +76,7 @@ tape( 'the function calculates the sum of absolute values for all elements in a t.end(); }); -tape( 'if provided an empty vector, the function returns `0.0`', function test( t ) { +tape( 'if provided an empty ndarray, the function returns `0.0`', function test( t ) { var xbuf; var x; var y;