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/dsyr2 #6546

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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 ]
}
48 changes: 48 additions & 0 deletions lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ var dsyr2 = require( './../lib/dsyr2.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 Float64Array( data.A );
x = new Float64Array( data.x );
y = new Float64Array( data.y );

expected = new Float64Array( data.A_out );

out = dsyr2( 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 Float64Array( data.A );
x = new Float64Array( data.x );
y = new Float64Array( data.y );

expected = new Float64Array( data.A_out );

out = dsyr2( 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
52 changes: 50 additions & 2 deletions lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var dsyr2 = 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 @@ -138,7 +140,7 @@ tape( 'the function throws an error if provided an invalid fifth argument', func

function badValue( value ) {
return function badValue() {
dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA );
dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.y ), data.strideX, data.offsetY, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA );
};
}
});
Expand All @@ -161,7 +163,7 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun

function badValue( value ) {
return function badValue() {
dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA );
dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), value, data.offsetY, new Float64Array( 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 Float64Array( data.A );
x = new Float64Array( data.x );
y = new Float64Array( data.y );

expected = new Float64Array( data.A_out );

out = dsyr2( 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 Float64Array( data.A );
x = new Float64Array( data.x );
y = new Float64Array( data.y );

expected = new Float64Array( data.A_out );

out = dsyr2( 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