From 82fdceea89030a7bf2f0197ebc93b8cbe16aab4a Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sun, 31 May 2026 21:04:34 -0700 Subject: [PATCH 1/2] feat: add `blas/ext/base/ndarray/gxsa` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../blas/ext/base/ndarray/gxsa/README.md | 123 ++++++++++ .../base/ndarray/gxsa/benchmark/benchmark.js | 107 +++++++++ .../blas/ext/base/ndarray/gxsa/docs/repl.txt | 32 +++ .../base/ndarray/gxsa/docs/types/index.d.ts | 56 +++++ .../ext/base/ndarray/gxsa/docs/types/test.ts | 64 +++++ .../ext/base/ndarray/gxsa/examples/index.js | 38 +++ .../blas/ext/base/ndarray/gxsa/lib/index.js | 48 ++++ .../blas/ext/base/ndarray/gxsa/lib/main.js | 72 ++++++ .../blas/ext/base/ndarray/gxsa/package.json | 70 ++++++ .../blas/ext/base/ndarray/gxsa/test/test.js | 218 ++++++++++++++++++ 10 files changed, 828 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/README.md new file mode 100644 index 000000000000..c6e7b622a4e3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/README.md @@ -0,0 +1,123 @@ + + +# gxsa + +> Subtract a scalar constant from each element in a one-dimensional ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var gxsa = require( '@stdlib/blas/ext/base/ndarray/gxsa' ); +``` + +#### gxsa( arrays ) + +Subtracts a scalar constant from each element in a one-dimensional ndarray. + +```javascript +var vector = require( '@stdlib/ndarray/vector/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = vector( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ], 'generic' ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' +}); + +gxsa( [ x, alpha ] ); +// x => [ -7.0, -4.0, -2.0, -10.0, -1.0, -5.0, -6.0, -8.0 ] +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the scalar constant to subtract. + +
+ + + +
+ +## Notes + +- The input ndarray is modified **in-place** (i.e., the input ndarray is **mutated**). + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var gxsa = require( '@stdlib/blas/ext/base/ndarray/gxsa' ); + +var opts = { + 'dtype': 'generic' +}; + +var x = discreteUniform( [ 10 ], -100, 100, opts ); +console.log( ndarray2array( x ) ); + +var alpha = scalar2ndarray( 5.0, opts ); +console.log( 'Alpha: %d', ndarraylike2scalar( alpha ) ); + +gxsa( [ x, alpha ] ); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/benchmark/benchmark.js new file mode 100644 index 000000000000..c47400646f5e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @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/uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gxsa = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var alpha; + var x; + + x = uniform( [ len ], -100.0, 100.0, options ); + alpha = scalar2ndarray( 5.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = gxsa( [ x, alpha ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + 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/ext/base/ndarray/gxsa/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/repl.txt new file mode 100644 index 000000000000..503376e18321 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( arrays ) + Subtracts a scalar constant from each element in a one-dimensional ndarray. + + The input ndarray is modified *in-place* (i.e., the input ndarray is + *mutated*). + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the scalar constant to subtract. + + Returns + ------- + out: ndarray + Input ndarray. + + Examples + -------- + > var buf = [ -2.0, 1.0, 3.0, -5.0 ]; + > var x = {{alias:@stdlib/ndarray/vector/ctor}}( buf, 'generic' ); + > var opts = { 'dtype': 'generic' }; + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 5.0, opts ); + > {{alias}}( [ x, alpha ] ) + [ -7.0, -4.0, -2.0, -10.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/index.d.ts new file mode 100644 index 000000000000..fa765ed5db80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/index.d.ts @@ -0,0 +1,56 @@ +/* +* @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 { typedndarray } from '@stdlib/types/ndarray'; + +/** +* Subtracts a scalar constant from each element in a one-dimensional ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the scalar constant to subtract. +* +* @param arrays - array-like object containing ndarrays +* @returns input ndarray +* +* @example +* var vector = require( '@stdlib/ndarray/vector/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = vector( [ -2.0, 1.0, 3.0, -5.0 ], 'generic' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'generic' +* }); +* +* var out = gxsa( [ x, alpha ] ); +* // returns [ -7.0, -4.0, -2.0, -10.0 ] +*/ +declare function gxsa = typedndarray>( arrays: [ T, typedndarray ] ): T; + + +// EXPORTS // + +export = gxsa; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/test.ts new file mode 100644 index 000000000000..d2b199628299 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/docs/types/test.ts @@ -0,0 +1,64 @@ +/* +* @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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import gxsa = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'generic' + }); + const alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' + }); + + gxsa( [ x, alpha ] ); // $ExpectType genericndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + gxsa( '10' ); // $ExpectError + gxsa( 5 ); // $ExpectError + gxsa( true ); // $ExpectError + gxsa( false ); // $ExpectError + gxsa( null ); // $ExpectError + gxsa( undefined ); // $ExpectError + gxsa( [] ); // $ExpectError + gxsa( {} ); // $ExpectError + gxsa( ( 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': 'generic' + }); + const alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' + }); + + gxsa(); // $ExpectError + gxsa( [ x, alpha ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/examples/index.js new file mode 100644 index 000000000000..1aa94d33ffba --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/examples/index.js @@ -0,0 +1,38 @@ +/** +* @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/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var gxsa = require( './../lib' ); + +var opts = { + 'dtype': 'generic' +}; + +var x = discreteUniform( [ 10 ], -100, 100, opts ); +console.log( ndarray2array( x ) ); + +var alpha = scalar2ndarray( 5.0, opts ); +console.log( 'Alpha: %d', ndarraylike2scalar( alpha ) ); + +gxsa( [ x, alpha ] ); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/index.js new file mode 100644 index 000000000000..f77a42a26e5d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/index.js @@ -0,0 +1,48 @@ +/** +* @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'; + +/** +* Subtract a scalar constant from each element in a one-dimensional ndarray. +* +* @module @stdlib/blas/ext/base/ndarray/gxsa +* +* @example +* var vector = require( '@stdlib/ndarray/vector/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var gxsa = require( '@stdlib/blas/ext/base/ndarray/gxsa' ); +* +* var x = vector( [ -2.0, 1.0, 3.0, -5.0 ], 'generic' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'generic' +* }); +* +* var out = gxsa( [ x, alpha ] ); +* // returns [ -7.0, -4.0, -2.0, -10.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/main.js new file mode 100644 index 000000000000..e270a732b164 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/lib/main.js @@ -0,0 +1,72 @@ +/** +* @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/ext/base/gxsa' ).ndarray; +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Subtracts a scalar constant from each element in a one-dimensional ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the scalar constant to subtract. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarray} input ndarray +* +* @example +* var vector = require( '@stdlib/ndarray/vector/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = vector( [ -2.0, 1.0, 3.0, -5.0 ], 'generic' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'generic' +* }); +* +* var out = gxsa( [ x, alpha ] ); +* // returns [ -7.0, -4.0, -2.0, -10.0 ] +*/ +function gxsa( arrays ) { + var alpha; + var x; + + x = arrays[ 0 ]; + alpha = ndarraylike2scalar( arrays[ 1 ] ); + strided( numelDimension( x, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len + return x; +} + + +// EXPORTS // + +module.exports = gxsa; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/package.json new file mode 100644 index 000000000000..2370b163ac87 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/gxsa", + "version": "0.0.0", + "description": "Subtract a scalar constant from each element in a one-dimensional 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", + "extended", + "ext", + "gxsa", + "xsa", + "subtract", + "scalar", + "constant", + "strided", + "array", + "ndarray", + "generic" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js new file mode 100644 index 000000000000..501f01fc28aa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js @@ -0,0 +1,218 @@ +/** +* @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 scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var gxsa = 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( 'generic', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gxsa, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function subtracts a scalar constant from each element', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = [ + -2.0, // 0 + 1.0, // 1 + 3.0, // 2 + -5.0, // 3 + 4.0 // 4 + ]; + x = vector( xbuf, 5, 1, 0 ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' + }); + + actual = gxsa( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = [ + -7.0, // 0 + -4.0, // 1 + -2.0, // 2 + -10.0, // 3 + -1.0 // 4 + ]; + t.deepEqual( xbuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an input ndarray having a non-unit stride', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = [ + -2.0, // 0 + 1.0, + 3.0, // 1 + -5.0, + 4.0, // 2 + 0.0, + -1.0, // 3 + -3.0 + ]; + x = vector( xbuf, 4, 2, 0 ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' + }); + + actual = gxsa( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = [ + -7.0, // 0 + 1.0, + -2.0, // 1 + -5.0, + -1.0, // 2 + 0.0, + -6.0, // 3 + -3.0 + ]; + t.deepEqual( xbuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an input ndarray having a negative stride', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = [ + -2.0, // 4 + 1.0, // 3 + 3.0, // 2 + -5.0, // 1 + 4.0 // 0 + ]; + x = vector( xbuf, 5, -1, 4 ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' + }); + + actual = gxsa( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = [ + -7.0, // 4 + -4.0, // 3 + -2.0, // 2 + -10.0, // 1 + -1.0 // 0 + ]; + t.deepEqual( xbuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an input ndarray having a non-zero offset', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = [ + 1.0, + -2.0, + 3.0, // 0 + -5.0, // 1 + 4.0, // 2 + 0.0 + ]; + x = vector( xbuf, 3, 1, 2 ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' + }); + + actual = gxsa( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = [ + 1.0, + -2.0, + -2.0, // 0 + -10.0, // 1 + -1.0, // 2 + 0.0 + ]; + t.deepEqual( xbuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the input ndarray unchanged when the input ndarray is empty', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var x; + + xbuf = []; + x = vector( xbuf, 0, 1, 0 ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'generic' + }); + + actual = gxsa( [ x, alpha ] ); + t.strictEqual( actual, x, 'returns expected value' ); + + expected = []; + t.deepEqual( xbuf, expected, 'returns expected value' ); + + t.end(); +}); From 212b06c945cb8c2cc169e5970f875b5f12720233 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sun, 31 May 2026 21:24:34 -0700 Subject: [PATCH 2/2] test: update comments --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/ndarray/gxsa/test/test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js index 501f01fc28aa..b16099dd8983 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/gxsa/test/test.js @@ -74,11 +74,11 @@ tape( 'the function subtracts a scalar constant from each element', function tes t.strictEqual( actual, x, 'returns expected value' ); expected = [ - -7.0, // 0 - -4.0, // 1 - -2.0, // 2 - -10.0, // 3 - -1.0 // 4 + -7.0, // -2.0 - 5.0 + -4.0, // 1.0 - 5.0 + -2.0, // 3.0 - 5.0 + -10.0, // -5.0 - 5.0 + -1.0 // 4.0 - 5.0 ]; t.deepEqual( xbuf, expected, 'returns expected value' );