Skip to content

Commit 4bf2683

Browse files
authored
test: add test cases for blas/base/ssyr2
PR-URL: #6730 Reviewed-by: Athan Reines <[email protected]>
1 parent dae553b commit 4bf2683

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ var base = require( './base.js' );
4747
* @throws {RangeError} second argument must be a nonnegative integer
4848
* @throws {RangeError} fifth argument must be non-zero
4949
* @throws {RangeError} eighth argument must be non-zero
50+
* @throws {RangeError} eleventh argument must be non-zero
51+
* @throws {RangeError} twelfth argument must be non-zero
5052
* @returns {Float32Array} `A`
5153
*
5254
* @example
@@ -72,6 +74,12 @@ function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str
7274
if ( strideY === 0 ) {
7375
throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) );
7476
}
77+
if ( strideA1 === 0 ) {
78+
throw new RangeError( format( 'invalid argument. Eleventh argument must be non-zero. Value: `%d`.', strideA1 ) );
79+
}
80+
if ( strideA2 === 0 ) {
81+
throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideA2 ) );
82+
}
7583
if ( N === 0 || alpha === 0.0 ) {
7684
return A;
7785
}

lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js

+46
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,52 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun
168168
}
169169
});
170170

171+
tape( 'the function throws an error if provided an invalid eleventh argument', function test( t ) {
172+
var values;
173+
var data;
174+
var i;
175+
176+
data = ru;
177+
178+
values = [
179+
0
180+
];
181+
182+
for ( i = 0; i < values.length; i++ ) {
183+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
184+
}
185+
t.end();
186+
187+
function badValue( value ) {
188+
return function badValue() {
189+
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 );
190+
};
191+
}
192+
});
193+
194+
tape( 'the function throws an error if provided an invalid twelfth argument', function test( t ) {
195+
var values;
196+
var data;
197+
var i;
198+
199+
data = ru;
200+
201+
values = [
202+
0
203+
];
204+
205+
for ( i = 0; i < values.length; i++ ) {
206+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
207+
}
208+
t.end();
209+
210+
function badValue( value ) {
211+
return function badValue() {
212+
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 );
213+
};
214+
}
215+
});
216+
171217
tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) {
172218
var expected;
173219
var data;

0 commit comments

Comments
 (0)