Skip to content

test: add test cases for blas/base/ssyr2 #6730

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 22, 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/ssyr2/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 {RangeError} second argument must be a nonnegative integer
* @throws {RangeError} fifth argument must be non-zero
* @throws {RangeError} eighth argument must be non-zero
* @throws {RangeError} eleventh argument must be non-zero
* @throws {RangeError} twelfth argument must be non-zero
* @returns {Float32Array} `A`
*
* @example
Expand All @@ -72,6 +74,12 @@ function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str
if ( strideY === 0 ) {
throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) );
}
if ( strideA1 === 0 ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be non-zero. Value: `%d`.', strideA1 ) );
}
if ( strideA2 === 0 ) {
throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideA2 ) );
}
if ( N === 0 || alpha === 0.0 ) {
return A;
}
Expand Down
46 changes: 46 additions & 0 deletions lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,52 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun
}
});

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

data = ru;

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() {
ssyr2( data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), value, data.strideA2, data.offsetA );
};
}
});

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

data = ru;

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() {
ssyr2( data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, value, data.offsetA );
};
}
});

tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) {
var expected;
var data;
Expand Down