Skip to content

test: add test cases for blas/base/dgemv #7124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/node_modules/@stdlib/blas/base/dgemv/lib/dgemv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -65,13 +66,16 @@ var base = require( './base.js' );
* // y => <Float64Array>[ 7.0, 16.0 ]
*/
function dgemv( 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;
var sa2;
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 ) );
}
Expand All @@ -84,6 +88,14 @@ function dgemv( 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. 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.' ) );
}
Expand All @@ -103,7 +115,7 @@ function dgemv( 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'
Expand Down
27 changes: 27 additions & 0 deletions lib/node_modules/@stdlib/blas/base/dgemv/test/test.dgemv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 seventh 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() {
dgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float64Array( data.A ), value, new Float64Array( data.x ), data.strideX, data.beta, new Float64Array( data.y ), data.strideY );
};
}
});

tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) {
var values;
var data;
Expand Down