From a76777e9be952b8dd460083b6e66899b29a353a7 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 15 Jan 2026 23:33:12 +0530 Subject: [PATCH 1/3] feat: add ndarray interface for blas/base/cgemv --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - 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/base/cgemv/lib/ndarray.js | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js new file mode 100644 index 000000000000..f3ef6379320b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js @@ -0,0 +1,93 @@ +/** +* @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 isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are complex scalars, `x` and `y` are complex vectors, and `A` is an `M` by `N` complex matrix. +* +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {Complex64} alpha - scalar constant +* @param {Complex64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Complex64Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Complex64} beta - scalar constant +* @param {Complex64Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @throws {TypeError} first argument must be a valid transpose operation +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} tenth argument must be non-zero +* @throws {RangeError} fourteenth argument must be non-zero +* @returns {Complex64Array} `y` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.02 ] ); +* var x = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); +* var y = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); +* var alpha = new Complex64( 1.0, 0.0 ); +* var beta = new Complex64( 1.0, 0.0 ); +* +* cgemv( 'no-transpose', 2, 3, alpha, A, 3, 1, 0, x, 1, 0, beta, y, 1, 0 ); +* +* // y => [ 10.0, 12.0, 28.0, 30.0 ] +*/ +function cgemv(trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY) { // eslint-disable-line max-params, max-len + if (!isMatrixTranspose(trans)) { + throw new TypeError( format( 'invalid argument. First argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if (M < 0) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if (N < 0) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if (strideX === 0) { + throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if (strideY === 0) { + throw new RangeError( format( 'invalid argument. Fourteenth argument must be non-zero. Value: `%d`.', strideY ) ); + } + // Check if we can early return... + if (M === 0 || N === 0) { + return y; + } + + return base( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = cgemv; From 0c2f85f4127d23a77c78b6bf6905cf120f4baa43 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sat, 17 Jan 2026 22:13:09 +0530 Subject: [PATCH 2/3] feat: add base implementation for blas/base/cgemv --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - 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/base/cgemv/lib/base.js | 198 ++++++++++++++++++ .../@stdlib/blas/base/cgemv/lib/ndarray.js | 3 +- 2 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/cgemv/lib/base.js diff --git a/lib/node_modules/@stdlib/blas/base/cgemv/lib/base.js b/lib/node_modules/@stdlib/blas/base/cgemv/lib/base.js new file mode 100644 index 000000000000..bc98706b97bd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cgemv/lib/base.js @@ -0,0 +1,198 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var scabs1 = require( '@stdlib/blas/base/scabs1' ); +var cmulf = require( '@stdlib/complex/float32/base/mul' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); +var conjf = require( '@stdlib/complex/float32/conj' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var cfill = require( '@stdlib/blas/ext/base/cfill' ).ndarray; +var cscal = require( '@stdlib/blas/base/cscal' ).ndarray; + + +// FUNCTIONS // + +/** +* Tests whether a provided string indicates to transpose a matrix. +* +* @private +* @param {string} str - input string +* @returns {boolean} boolean indicating whether to transpose a matrix +* +* @example +* var bool = isTransposed( 'transpose' ); +* // returns true +* +* @example +* var bool = isTransposed( 'conjugate-transpose' ); +* // returns true +* +* @example +* var bool = isTransposed( 'no-transpose' ); +* // returns false +*/ +function isTransposed( str ) { // NOTE: consider moving to a separate helper utility package + return ( str !== 'no-transpose' ); +} + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are complex scalars, `x` and `y` are complex vectors, and `A` is an `M` by `N` complex matrix. +* +* @private +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {Complex64} alpha - scalar constant +* @param {Complex64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Complex64Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Complex64} beta - scalar constant +* @param {Complex64Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @returns {Complex64Array} `y` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* var x = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); +* var y = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); +* var alpha = new Complex64( 1.0, 0.0 ); +* var beta = new Complex64( 1.0, 0.0 ); +* +* cgemv( 'no-transpose', 2, 3, alpha, A, 3, 1, 0, x, 1, 0, beta, y, 1, 0 ); +* // y => [ 10.0, 12.0, 28.0, 30.0 ] +*/ +function cgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len + var isrm; + var xlen; + var ylen; + var tmp; + var da0; + var da1; + var aij; + var ix; + var iy; + var ia; + var i1; + var i0; + + isrm = isRowMajor( [ strideA1, strideA2 ] ); + if ( isTransposed( trans ) ) { + xlen = M; + ylen = N; + } else { + xlen = N; + ylen = M; + } + // y = beta*y + if ( scabs1( beta ) === 0.0 ) { + cfill( ylen, 0.0, y, strideY, offsetY ); + } else if ( scabs1( beta ) !== 1.0 ) { + cscal( ylen, beta, y, strideY, offsetY ); + } + if ( scabs1( alpha ) === 0.0 ) { + return y; + } + // Form: y = α*A*x + y + if ( + ( !isrm && !isTransposed( trans ) ) || + ( isrm && isTransposed( trans ) ) + ) { + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( ylen*strideA2 ); // offset increment for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( ylen*strideA1 ); // offset increment for outermost loop + } + ia = offsetA; + ix = offsetX; + for ( i1 = 0; i1 < xlen; i1++ ) { + tmp = cmulf( alpha, x.get( ix ) ); + if ( scabs1( tmp ) === 0.0 ) { + ia += da0 * ylen; + } else { + iy = offsetY; + for ( i0 = 0; i0 < ylen; i0++ ) { + aij = A.get( ia ); + if ( trans === 'conjugate-transpose' ) { + aij = conjf( aij ); + } + y.set( caddf( y.get( iy ), cmulf( aij, tmp ) ), iy ); + iy += strideY; + ia += da0; + } + } + ix += strideX; + ia += da1; + } + return y; + } + // Form: y = α*A^T*x + y + + // ( !isrm && isTransposed( trans ) ) || ( isrm && !isTransposed( trans ) ) + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( xlen*strideA2 ); // offset increment for outermost loop + } else { // isColMajor + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( xlen*strideA1 ); // offset increment for outermost loop + } + ia = offsetA; + iy = offsetY; + for ( i1 = 0; i1 < ylen; i1++ ) { + ix = offsetX; + tmp = new Complex64( 0.0, 0.0 ); + for ( i0 = 0; i0 < xlen; i0++ ) { + aij = A.get( ia ); + if ( trans === 'conjugate-transpose' ) { + aij = conjf( aij ); + } + tmp = caddf( tmp, cmulf( aij, x.get( ix ) ) ); + ix += strideX; + ia += da0; + } + y.set( caddf( y.get( iy ), cmulf( alpha, tmp ) ), iy ); + iy += strideY; + ia += da1; + } + return y; +} + + +// EXPORTS // + +module.exports = cgemv; diff --git a/lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js index f3ef6379320b..bc85b0f8e583 100644 --- a/lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/cgemv/lib/ndarray.js @@ -53,14 +53,13 @@ var base = require( './base.js' ); * var Complex64Array = require( '@stdlib/array/complex64' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * -* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.02 ] ); +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); * var x = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); * var y = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); * var alpha = new Complex64( 1.0, 0.0 ); * var beta = new Complex64( 1.0, 0.0 ); * * cgemv( 'no-transpose', 2, 3, alpha, A, 3, 1, 0, x, 1, 0, beta, y, 1, 0 ); -* * // y => [ 10.0, 12.0, 28.0, 30.0 ] */ function cgemv(trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY) { // eslint-disable-line max-params, max-len From 3de6c02c74b8b926eb36739ade32077bb92ea714 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 20 Jan 2026 16:27:34 +0530 Subject: [PATCH 3/3] switching device --- .../@stdlib/blas/base/cgemv/README.md | 0 .../@stdlib/blas/base/cgemv/lib/cgemv.js | 71 +++++++++++++++++++ .../@stdlib/blas/base/cgemv/lib/index.js | 0 .../@stdlib/blas/base/cgemv/lib/main.js | 0 4 files changed, 71 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/cgemv/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/cgemv/lib/cgemv.js create mode 100644 lib/node_modules/@stdlib/blas/base/cgemv/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/cgemv/lib/main.js diff --git a/lib/node_modules/@stdlib/blas/base/cgemv/README.md b/lib/node_modules/@stdlib/blas/base/cgemv/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lib/node_modules/@stdlib/blas/base/cgemv/lib/cgemv.js b/lib/node_modules/@stdlib/blas/base/cgemv/lib/cgemv.js new file mode 100644 index 000000000000..9b9d6b8d26e4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cgemv/lib/cgemv.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var scabs1 = require( '@stdlib/blas/base/scabs1' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are complex scalars, `x` and `y` are complex vectors, and `A` is an `M` by `N` complex matrix. +* +* @param {string} order - storage layout +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {Complex64} alpha - scalar constant +* @param {Complex64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` +* @param {Complex64Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {Complex64} beta - scalar constant +* @param {Complex64Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid transpose operation +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be a valid stride +* @throws {RangeError} ninth argument must be non-zero +* @throws {RangeError} twelfth argument must be non-zero +* @returns {Complex64Array} `y` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +* var x = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); +* var y = new Complex64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); +* var alpha = new Complex64( 1.0, 0.0 ); +* var beta = new Complex64( 1.0, 0.0 ); +* +* cgemv( 'no-transpose', 2, 3, alpha, A, 3, 1, 0, x, 1, 0, beta, y, 1, 0 ); +* // y => [ 10.0, 12.0, 28.0, 30.0 ] +*/ diff --git a/lib/node_modules/@stdlib/blas/base/cgemv/lib/index.js b/lib/node_modules/@stdlib/blas/base/cgemv/lib/index.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lib/node_modules/@stdlib/blas/base/cgemv/lib/main.js b/lib/node_modules/@stdlib/blas/base/cgemv/lib/main.js new file mode 100644 index 000000000000..e69de29bb2d1