Skip to content

test: add test cases for blas/base/strmv #6732

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 2 commits into from
Apr 25, 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
8 changes: 8 additions & 0 deletions lib/node_modules/@stdlib/blas/base/strmv/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var base = require( './base.js' );
* @throws {TypeError} second argument must be a valid transpose operation
* @throws {TypeError} third argument must be a valid diagonal type
* @throws {RangeError} fourth argument must be a nonnegative integer
* @throws {RangeError} sixth argument must be non-zero
* @throws {RangeError} seventh argument must be non-zero
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as PR #6733

* @throws {RangeError} tenth argument must be non-zero
* @returns {Float32Array} `x`
*
Expand All @@ -72,6 +74,12 @@ function strmv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
if ( N < 0 ) {
throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) );
}
if ( strideA1 === 0 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment. Why is A not allowed to have zero strides when it is only an input array, not an output array?

throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideA1 ) );
}
if ( strideA2 === 0 ) {
throw new RangeError( format( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideA2 ) );
}
if ( strideX === 0 ) {
throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) );
}
Expand Down
46 changes: 46 additions & 0 deletions lib/node_modules/@stdlib/blas/base/strmv/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,52 @@ 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 = rutu;

values = [
0
];

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() {
strmv( data.uplo, data.trans, data.diag, data.N, new Float32Array( data.A ), value, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX );
};
}
});

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

data = rutu;

values = [
0
];

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() {
strmv( data.uplo, data.trans, data.diag, data.N, new Float32Array( data.A ), data.strideA1, value, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX );
};
}
});

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