Skip to content
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

test: increase code coverage in blas/base/ssyr2 #6544

Merged
merged 10 commits into from
Apr 5, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"order": "column-major",
"uplo": "lower",
"N": 3,
"alpha": 2.0,
"x": [ 0.0, 0.0, 0.0 ],
"strideX": 1,
"offsetX": 0,
"y": [ 1.0, 2.0, 3.0 ],
"strideY": 1,
"offsetY": 0,
"A": [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ],
"lda": 3,
"strideA1": 1,
"strideA2": 3,
"offsetA": 0,
"A_out": [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"order": "row-major",
"uplo": "lower",
"N": 3,
"alpha": 2.0,
"x": [ 0.0, 0.0, 0.0 ],
"strideX": 1,
"offsetX": 0,
"y": [ 1.0, 2.0, 3.0 ],
"strideY": 1,
"offsetY": 0,
"A": [ 1.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0 ],
"lda": 3,
"strideA1": 3,
"strideA2": 1,
"offsetA": 0,
"A_out": [ 1.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0 ]
}
50 changes: 49 additions & 1 deletion lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var ssyr2 = require( './../lib/ndarray.js' );

var ru = require( './fixtures/row_major_u.json' );
var rl = require( './fixtures/row_major_l.json' );
var rx0 = require( './fixtures/row_major_x0.json' );
var rxpyp = require( './fixtures/row_major_xpyp.json' );
var rxnyp = require( './fixtures/row_major_xnyp.json' );
var rxpyn = require( './fixtures/row_major_xpyn.json' );
Expand All @@ -44,6 +45,7 @@ var rcap = require( './fixtures/row_major_complex_access_pattern.json' );

var cu = require( './fixtures/column_major_u.json' );
var cl = require( './fixtures/column_major_l.json' );
var cx0 = require( './fixtures/column_major_x0.json' );
var cxpyp = require( './fixtures/column_major_xpyp.json' );
var cxnyp = require( './fixtures/column_major_xnyp.json' );
var cxpyn = require( './fixtures/column_major_xpyn.json' );
Expand Down Expand Up @@ -161,7 +163,7 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun

function badValue( value ) {
return function badValue() {
ssyr2( data.uplo, data.N, data.alpha, new Float32Array( data.x ), value, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA );
ssyr2( data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), value, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA );
};
}
});
Expand Down Expand Up @@ -258,6 +260,52 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y
t.end();
});

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

data = rx0;

a = new Float32Array( data.A );
x = new Float32Array( data.x );
y = new Float32Array( data.y );

expected = new Float32Array( data.A_out );

out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA );
t.strictEqual( out, a, 'returns expected value' );
t.deepEqual( out, expected, 'returns expected value' );

t.end();
});

tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, zero-vector)', function test( t ) {
var expected;
var data;
var out;
var a;
var x;
var y;

data = cx0;

a = new Float32Array( data.A );
x = new Float32Array( data.x );
y = new Float32Array( data.y );

expected = new Float32Array( data.A_out );

out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA );
t.strictEqual( out, a, 'returns expected value' );
t.deepEqual( out, expected, 'returns expected value' );

t.end();
});

tape( 'the function returns a reference to the input matrix `A`', function test( t ) {
var data;
var out;
Expand Down
48 changes: 48 additions & 0 deletions lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ var ssyr2 = require( './../lib/ssyr2.js' );

var ru = require( './fixtures/row_major_u.json' );
var rl = require( './fixtures/row_major_l.json' );
var rx0 = require( './fixtures/row_major_x0.json' );
var rxpyp = require( './fixtures/row_major_xpyp.json' );
var rxnyp = require( './fixtures/row_major_xnyp.json' );
var rxpyn = require( './fixtures/row_major_xpyn.json' );
var rxnyn = require( './fixtures/row_major_xnyn.json' );

var cu = require( './fixtures/column_major_u.json' );
var cl = require( './fixtures/column_major_l.json' );
var cx0 = require( './fixtures/column_major_x0.json' );
var cxpyp = require( './fixtures/column_major_xpyp.json' );
var cxnyp = require( './fixtures/column_major_xnyp.json' );
var cxpyn = require( './fixtures/column_major_xpyn.json' );
Expand Down Expand Up @@ -300,6 +302,52 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y
t.end();
});

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

data = rx0;

a = new Float32Array( data.A );
x = new Float32Array( data.x );
y = new Float32Array( data.y );

expected = new Float32Array( data.A_out );

out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda );
t.strictEqual( out, a, 'returns expected value' );
t.deepEqual( out, expected, 'returns expected value' );

t.end();
});

tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, zero-vector)', function test( t ) {
var expected;
var data;
var out;
var a;
var x;
var y;

data = cx0;

a = new Float32Array( data.A );
x = new Float32Array( data.x );
y = new Float32Array( data.y );

expected = new Float32Array( data.A_out );

out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda );
t.strictEqual( out, a, 'returns expected value' );
t.deepEqual( out, expected, 'returns expected value' );

t.end();
});

tape( 'the function returns a reference to the input matrix `A`', function test( t ) {
var data;
var out;
Expand Down