From 247ccf9651c3e2a2651e5845b0ff110fc2f20b23 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sun, 26 Jul 2026 22:38:45 -0700 Subject: [PATCH 1/3] feat: add `blas/ext/base/ndarray/zwxsa` --- 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/zwxsa/README.md | 133 ++++++ .../base/ndarray/zwxsa/benchmark/benchmark.js | 110 +++++ .../blas/ext/base/ndarray/zwxsa/docs/repl.txt | 38 ++ .../base/ndarray/zwxsa/docs/types/index.d.ts | 60 +++ .../ext/base/ndarray/zwxsa/docs/types/test.ts | 71 +++ .../ext/base/ndarray/zwxsa/examples/index.js | 45 ++ .../blas/ext/base/ndarray/zwxsa/lib/index.js | 50 ++ .../blas/ext/base/ndarray/zwxsa/lib/main.js | 80 ++++ .../blas/ext/base/ndarray/zwxsa/package.json | 74 +++ .../blas/ext/base/ndarray/zwxsa/test/test.js | 452 ++++++++++++++++++ 10 files changed, 1113 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md new file mode 100644 index 000000000000..b7ea1d363682 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md @@ -0,0 +1,133 @@ + + +# zwxsa + +> Subtract a scalar constant from each element in an input one-dimensional double-precision complex floating-point ndarray and assign the results to elements in a one-dimensional double-precision complex floating-point output ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var zwxsa = require( '@stdlib/blas/ext/base/ndarray/zwxsa' ); +``` + +#### zwxsa( arrays ) + +Subtracts a scalar constant from each element in an input one-dimensional double-precision complex floating-point ndarray and assigns the results to elements in a one-dimensional double-precision complex floating-point output ndarray. + +```javascript +var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = new Complex128Vector( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +var w = new Complex128Vector( 4 ); + +var alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' +}); + +zwxsa( [ x, w, alpha ] ); +// w => [ [ -7.0, 1.0 ], [ -2.0, -5.0 ], [ -1.0, 0.0 ], [ -6.0, -3.0 ] ] +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a one-dimensional output ndarray. + - a zero-dimensional ndarray containing the scalar constant to subtract. + +
+ + + +
+ +## Notes + +- The output ndarray is modified **in-place** (i.e., the output ndarray is **mutated**). + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zwxsa = require( '@stdlib/blas/ext/base/ndarray/zwxsa' ); + +var opts = { + 'dtype': 'float64' +}; + +var x = new Complex128Vector( discreteUniform( 20, -100, 100, opts ) ); +console.log( ndarray2array( x ) ); + +var w = new Complex128Vector( 10 ); +console.log( ndarray2array( w ) ); + +var alpha = scalar2ndarray( new Complex128( 5.0, -3.0 ), { + 'dtype': 'complex128' +}); +console.log( 'Alpha:', ndarraylike2scalar( alpha ) ); + +zwxsa( [ x, w, alpha ] ); +console.log( ndarray2array( w ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/benchmark/benchmark.js new file mode 100644 index 000000000000..d733acda986f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/benchmark/benchmark.js @@ -0,0 +1,110 @@ +/** +* @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 pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var zwxsa = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var alpha; + var xbuf; + var x; + var w; + + xbuf = uniform( len*2, -100.0, 100.0, { + 'dtype': 'float64' + }); + x = new Complex128Vector( xbuf.buffer ); + w = new Complex128Vector( len ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + 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 = zwxsa( [ x, w, 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/zwxsa/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt new file mode 100644 index 000000000000..f890c0bf222f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt @@ -0,0 +1,38 @@ + +{{alias}}( arrays ) + Subtracts a scalar constant from each element in an input one-dimensional + double-precision complex floating-point ndarray and assigns the results to + elements in a one-dimensional double-precision complex floating-point + output ndarray. + + The output ndarray is modified *in-place* (i.e., the output ndarray is + *mutated*). + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a one-dimensional output ndarray. + - a zero-dimensional ndarray containing the scalar constant to subtract. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var xbuf = [ -2.0, 1.0, 3.0, -5.0 ]; + > var x = new {{alias:@stdlib/ndarray/vector/complex128}}( xbuf ); + > var w = new {{alias:@stdlib/ndarray/vector/complex128}}( 2 ); + > var opts = { 'dtype': 'complex128' }; + > var a = new {{alias:@stdlib/complex/float64/ctor}}( 5.0, 0.0 ); + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( a, opts ); + > {{alias}}( [ x, w, alpha ] ) + [ [ -7.0, 1.0 ], [ -2.0, -5.0 ] ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/index.d.ts new file mode 100644 index 000000000000..e77798ed3dd6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/index.d.ts @@ -0,0 +1,60 @@ +/* +* @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 { complex128ndarray, typedndarray } from '@stdlib/types/ndarray'; +import { Complex128 } from '@stdlib/types/complex'; + +/** +* Subtracts a scalar constant from each element in an input one-dimensional double-precision complex floating-point ndarray and assigns the results to elements in a one-dimensional double-precision complex floating-point output ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a one-dimensional output ndarray. +* - a zero-dimensional ndarray containing the scalar constant to subtract. +* +* @param arrays - array-like object containing ndarrays +* @returns output ndarray +* +* @example +* var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Complex128Vector( [ -2.0, 1.0, 3.0, -5.0 ] ); +* var w = new Complex128Vector( 2 ); +* +* var alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var out = zwxsa( [ x, w, alpha ] ); +* // returns [ [ -7.0, 1.0 ], [ -2.0, -5.0 ] ] +*/ +declare function zwxsa( arrays: [ complex128ndarray, complex128ndarray, typedndarray ] ): complex128ndarray; + + +// EXPORTS // + +export = zwxsa; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/test.ts new file mode 100644 index 000000000000..b32fc3f54cf6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/types/test.ts @@ -0,0 +1,71 @@ +/* +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +import zwxsa = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'complex128' + }); + const w = zeros( [ 10 ], { + 'dtype': 'complex128' + }); + const alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + zwxsa( [ x, w, alpha ] ); // $ExpectType complex128ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + zwxsa( '10' ); // $ExpectError + zwxsa( 5 ); // $ExpectError + zwxsa( true ); // $ExpectError + zwxsa( false ); // $ExpectError + zwxsa( null ); // $ExpectError + zwxsa( undefined ); // $ExpectError + zwxsa( [] ); // $ExpectError + zwxsa( {} ); // $ExpectError + zwxsa( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'complex128' + }); + const w = zeros( [ 10 ], { + 'dtype': 'complex128' + }); + const alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + zwxsa(); // $ExpectError + zwxsa( [ x, w, alpha ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/examples/index.js new file mode 100644 index 000000000000..e19bde127246 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/examples/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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var zwxsa = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var x = new Complex128Vector( discreteUniform( 20, -100, 100, opts ) ); +console.log( ndarray2array( x ) ); + +var w = new Complex128Vector( 10 ); +console.log( ndarray2array( w ) ); + +var alpha = scalar2ndarray( new Complex128( 5.0, -3.0 ), { + 'dtype': 'complex128' +}); +console.log( 'Alpha:', ndarraylike2scalar( alpha ) ); + +zwxsa( [ x, w, alpha ] ); +console.log( ndarray2array( w ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/index.js new file mode 100644 index 000000000000..42884cceaaea --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/index.js @@ -0,0 +1,50 @@ +/** +* @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 an input one-dimensional double-precision complex floating-point ndarray and assign the results to elements in a one-dimensional double-precision complex floating-point output ndarray. +* +* @module @stdlib/blas/ext/base/ndarray/zwxsa +* +* @example +* var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var zwxsa = require( '@stdlib/blas/ext/base/ndarray/zwxsa' ); +* +* var x = new Complex128Vector( [ -2.0, 1.0, 3.0, -5.0 ] ); +* var w = new Complex128Vector( 2 ); +* +* var alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var out = zwxsa( [ x, w, alpha ] ); +* // returns [ [ -7.0, 1.0 ], [ -2.0, -5.0 ] ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/main.js new file mode 100644 index 000000000000..18e24cc722ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/lib/main.js @@ -0,0 +1,80 @@ +/** +* @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/zwxsa' ).ndarray; +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Subtracts a scalar constant from each element in an input one-dimensional double-precision complex floating-point ndarray and assigns the results to elements in a one-dimensional double-precision complex floating-point output ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a one-dimensional output ndarray. +* - a zero-dimensional ndarray containing the scalar constant to subtract. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarray} output ndarray +* +* @example +* var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Complex128Vector( [ -2.0, 1.0, 3.0, -5.0 ] ); +* var w = new Complex128Vector( 2 ); +* +* var alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var out = zwxsa( [ x, w, alpha ] ); +* // returns [ [ -7.0, 1.0 ], [ -2.0, -5.0 ] ] +* +* var bool = ( out === w ); +* // returns true +*/ +function zwxsa( arrays ) { + var alpha; + var x; + var w; + + x = arrays[ 0 ]; + w = arrays[ 1 ]; + alpha = ndarraylike2scalar( arrays[ 2 ] ); + strided( numelDimension( x, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ), getData( w ), getStride( w, 0 ), getOffset( w ) ); // eslint-disable-line max-len + return w; +} + + +// EXPORTS // + +module.exports = zwxsa; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/package.json new file mode 100644 index 000000000000..e6ca5d3a56e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/zwxsa", + "version": "0.0.0", + "description": "Subtract a scalar constant from each element in an input one-dimensional double-precision complex floating-point ndarray and assign the results to elements in a one-dimensional double-precision complex floating-point output 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", + "zwxsa", + "wxsa", + "subtract", + "scalar", + "constant", + "strided", + "array", + "ndarray", + "complex128", + "complex", + "double", + "double-precision", + "float64" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/test/test.js new file mode 100644 index 000000000000..b71ed03704b3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/test/test.js @@ -0,0 +1,452 @@ +/** +* @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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var zwxsa = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Complex128Array} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'complex128', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zwxsa, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( zwxsa.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function subtracts a scalar constant from each element and assigns results to an output ndarray', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var wbuf; + var x; + var w; + + xbuf = new Complex128Array([ + -2.0, // 0 + 1.0, // 0 + 3.0, // 1 + -5.0, // 1 + 4.0, // 2 + 0.0, // 2 + -1.0, // 3 + -3.0, // 3 + 2.0, // 4 + 1.0 // 4 + ]); + wbuf = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, // 4 + 0.0 // 4 + ]); + x = vector( xbuf, 5, 1, 0 ); + w = vector( wbuf, 5, 1, 0 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array([ + -7.0, // 0 + 1.0, // 0 + -2.0, // 1 + -5.0, // 1 + -1.0, // 2 + 0.0, // 2 + -6.0, // 3 + -3.0, // 3 + -3.0, // 4 + 1.0 // 4 + ]); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, '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 wbuf; + var x; + var w; + + xbuf = new Complex128Array([ + -2.0, // 0 + 1.0, // 0 + 0.0, + 0.0, + 4.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ]); + wbuf = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 + 0.0, // 1 + 0.0 // 1 + ]); + x = vector( xbuf, 2, 2, 0 ); + w = vector( wbuf, 2, 1, 0 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array([ + -7.0, // 0 + 1.0, // 0 + -1.0, // 1 + 0.0 // 1 + ]); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, '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 wbuf; + var x; + var w; + + xbuf = new Complex128Array([ + -2.0, // 4 + 1.0, // 4 + 3.0, // 3 + -5.0, // 3 + 4.0, // 2 + 0.0, // 2 + -1.0, // 1 + -3.0, // 1 + 2.0, // 0 + 1.0 // 0 + ]); + wbuf = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, // 4 + 0.0 // 4 + ]); + x = vector( xbuf, 5, -1, 4 ); + w = vector( wbuf, 5, 1, 0 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array([ + -3.0, // 0 + 1.0, // 0 + -6.0, // 1 + -3.0, // 1 + -1.0, // 2 + 0.0, // 2 + -2.0, // 3 + -5.0, // 3 + -7.0, // 4 + 1.0 // 4 + ]); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an output ndarray having a non-unit stride', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var wbuf; + var x; + var w; + + xbuf = new Complex128Array([ + -2.0, // 0 + 1.0, // 0 + 3.0, // 1 + -5.0 // 1 + ]); + wbuf = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ]); + x = vector( xbuf, 2, 1, 0 ); + w = vector( wbuf, 2, 2, 0 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array([ + -7.0, // 0 + 1.0, // 0 + 0.0, + 0.0, + -2.0, // 1 + -5.0, // 1 + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an output ndarray having a negative stride', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var wbuf; + var x; + var w; + + xbuf = new Complex128Array([ + -2.0, // 0 + 1.0, // 0 + 3.0, // 1 + -5.0, // 1 + 4.0, // 2 + 0.0 // 2 + ]); + wbuf = new Complex128Array([ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, // 0 + 0.0 // 0 + ]); + x = vector( xbuf, 3, 1, 0 ); + w = vector( wbuf, 3, -1, 2 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array([ + -1.0, // 2 + 0.0, // 2 + -2.0, // 1 + -5.0, // 1 + -7.0, // 0 + 1.0 // 0 + ]); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, '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 wbuf; + var x; + var w; + + xbuf = new Complex128Array([ + 0.0, + 0.0, + 0.0, + 0.0, + 3.0, // 0 + -5.0, // 0 + 4.0, // 1 + 0.0, // 1 + -1.0, // 2 + -3.0 // 2 + ]); + wbuf = new Complex128Array([ + 0.0, // 0 + 0.0, // 0 + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0 // 2 + ]); + x = vector( xbuf, 3, 1, 2 ); + w = vector( wbuf, 3, 1, 0 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array([ + -2.0, // 0 + -5.0, // 0 + -1.0, // 1 + 0.0, // 1 + -6.0, // 2 + -3.0 // 2 + ]); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an output ndarray having a non-zero offset', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var wbuf; + var x; + var w; + + xbuf = new Complex128Array([ + -2.0, // 0 + 1.0, // 0 + 3.0, // 1 + -5.0, // 1 + 4.0, // 2 + 0.0 // 2 + ]); + wbuf = new Complex128Array([ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, // 0 + 0.0, // 0 + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0 // 2 + ]); + x = vector( xbuf, 3, 1, 0 ); + w = vector( wbuf, 3, 1, 2 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 0.0, + 0.0, + -7.0, // 0 + 1.0, // 0 + -2.0, // 1 + -5.0, // 1 + -1.0, // 2 + 0.0 // 2 + ]); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the output ndarray unchanged when the input ndarray is empty', function test( t ) { + var expected; + var actual; + var alpha; + var xbuf; + var wbuf; + var x; + var w; + + xbuf = new Complex128Array( [] ); + wbuf = new Complex128Array( [] ); + x = vector( xbuf, 0, 1, 0 ); + w = vector( wbuf, 0, 1, 0 ); + alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), { + 'dtype': 'complex128' + }); + + actual = zwxsa( [ x, w, alpha ] ); + t.strictEqual( actual, w, 'returns expected value' ); + + expected = new Complex128Array( [] ); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); From f362d98e242e14a1cf6e87aa44b9f2a6433e4c34 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Sun, 26 Jul 2026 23:06:17 -0700 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- .../@stdlib/blas/ext/base/ndarray/zwxsa/README.md | 4 ---- .../@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt | 3 --- 2 files changed, 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md index b7ea1d363682..9b1e8456bfa4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/README.md @@ -70,10 +70,6 @@ The function has the following parameters:
-## Notes - -- The output ndarray is modified **in-place** (i.e., the output ndarray is **mutated**). -
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt index f890c0bf222f..a896f9057836 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt @@ -5,9 +5,6 @@ elements in a one-dimensional double-precision complex floating-point output ndarray. - The output ndarray is modified *in-place* (i.e., the output ndarray is - *mutated*). - Parameters ---------- arrays: ArrayLikeObject From d26ff5eafad3c692e31b325c7b8369c6f78a8029 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 27 Jul 2026 01:22:41 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt index a896f9057836..3b4dc6e23127 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zwxsa/docs/repl.txt @@ -2,8 +2,8 @@ {{alias}}( arrays ) Subtracts a scalar constant from each element in an input one-dimensional double-precision complex floating-point ndarray and assigns the results to - elements in a one-dimensional double-precision complex floating-point - output ndarray. + elements in a one-dimensional double-precision complex floating-point output + ndarray. Parameters ----------