From 219751622df9b585530020d3589b6b46b323be30 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 30 May 2025 16:25:54 +0530 Subject: [PATCH 1/3] test: add test cases for blas/base/sgemv --- 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/sgemv/lib/sgemv.js | 14 +++++++++- .../blas/base/sgemv/test/test.sgemv.js | 27 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js index 9c0989ada6c3..1b6023b304eb 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js @@ -20,6 +20,7 @@ // MODULES // +var max = require( '@stdlib/math/base/special/fast/max' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); @@ -65,6 +66,8 @@ var base = require( './base.js' ); * // y => [ 7.0, 16.0 ] */ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params, max-len + var iscm; + var vala; var xlen; var ylen; var sa1; @@ -72,6 +75,7 @@ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY var ox; var oy; + iscm = isColumnMajor( order ); if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } @@ -84,6 +88,14 @@ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); } + if ( iscm ) { + vala = M; + } else { + vala = N; + } + if ( LDA < max( 1, vala ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, LDA ) ); + } if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero.' ) ); } @@ -103,7 +115,7 @@ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY } ox = stride2offset( xlen, strideX ); oy = stride2offset( ylen, strideY ); - if ( isColumnMajor( order ) ) { + if ( iscm ) { sa1 = 1; sa2 = LDA; } else { // order === 'row-major' diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js index c7f363f1b434..e66e610d31ab 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js @@ -159,6 +159,33 @@ tape( 'the function throws an error if provided an invalid fourth argument', fun } }); +tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 1, + 0, + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), value, new Float32Array( data.x ), data.strideX, data.beta, new Float32Array( data.y ), data.strideY ); + }; + } +}); + tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) { var values; var data; From 5d19e0f325a32ce2fd85a0bc730676594b19201f Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 6 Jun 2025 23:14:16 -0700 Subject: [PATCH 2/3] fix: update error message Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js index 1b6023b304eb..2b963fbb3a96 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js @@ -94,7 +94,7 @@ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY vala = N; } if ( LDA < max( 1, vala ) ) { - throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, LDA ) ); + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, LDA ) ); } if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero.' ) ); From e50de44382e2141f48288fd9b8e0054bade4491b Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 6 Jun 2025 23:14:26 -0700 Subject: [PATCH 3/3] test: fix description Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js index e66e610d31ab..4d0fcfea67c9 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js @@ -159,7 +159,7 @@ tape( 'the function throws an error if provided an invalid fourth argument', fun } }); -tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { +tape( 'the function throws an error if provided an invalid seventh argument', function test( t ) { var values; var data; var i;