Skip to content

Commit

Permalink
test: add test cases to blas/base/srotm
Browse files Browse the repository at this point in the history
PR-URL: #2455
Reviewed-by: Athan Reines <kgryte@gmail.com>
  • Loading branch information
aman-095 authored Jun 25, 2024
1 parent c04e29b commit 4d45aa2
Show file tree
Hide file tree
Showing 4 changed files with 1,240 additions and 224 deletions.
356 changes: 300 additions & 56 deletions lib/node_modules/@stdlib/blas/base/srotm/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,88 @@ tape( 'the function applies a plane rotation (sx=-1, sy=-2)', function test( t )
t.end();
});

tape( 'the function applies a plane rotation', function test( t ) {
var param;
var xe;
var ye;
var x;
var y;

x = new Float32Array([
1.0, // 0
2.0,
3.0, // 1
4.0,
5.0 // 2
]);
y = new Float32Array([
6.0, // 0
7.0,
8.0, // 1
9.0,
10.0 // 2
]);
param = new Float32Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 3, x, 2, 0, y, 2, 0, param );

xe = new Float32Array( [
-18.0, // 0
2.0,
-24.0, // 1
4.0,
-30.0 // 2
] );
ye = new Float32Array( [
2.0, // 0
7.0,
6.0, // 1
9.0,
10.0 // 2
] );

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );

x = new Float32Array([
1.0, // 0
2.0,
3.0,
4.0, // 1
5.0
]);
y = new Float32Array([
6.0, // 0
7.0,
8.0,
9.0, // 1
10.0
]);
param = new Float32Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] );

srotm( 2, x, 3, 0, y, 3, 0, param );

xe = new Float32Array( [
6.0, // 0
2.0,
3.0,
9.0, // 1
5.0
] );
ye = new Float32Array( [
-1.0, // 0
7.0,
8.0,
-4.0, // 1
10.0
] );

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );

t.end();
});

tape( 'the function supports an `x` stride', function test( t ) {
var param;
var xe;
Expand Down Expand Up @@ -306,6 +388,42 @@ tape( 'the function supports an `x` stride', function test( t ) {
isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );

x = new Float32Array([
1.0, // 0
2.0,
3.0,
4.0, // 1
5.0
]);
y = new Float32Array([
6.0, // 0
7.0, // 1
8.0,
9.0,
10.0
]);
param = new Float32Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 2, x, 3, 0, y, 1, 0, param );

xe = new Float32Array( [
-18.0, // 0
2.0,
3.0,
-21.0, // 1
5.0
] );
ye = new Float32Array( [
2.0, // 0
8.0, // 1
8.0,
9.0,
10.0
] );

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );

t.end();
});

Expand Down Expand Up @@ -341,6 +459,78 @@ tape( 'the function supports an `x` offset', function test( t ) {
isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );

x = new Float32Array([
1.0, // 1
2.0,
3.0, // 0
4.0,
5.0
]);
y = new Float32Array([
6.0, // 0
7.0, // 1
8.0,
9.0,
10.0
]);
param = new Float32Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 2, x, -2, 2, y, 1, 0, param );

xe = new Float32Array( [
-21.0, // 1
2.0,
-18.0, // 0
4.0,
5.0
] );
ye = new Float32Array( [
6.0, // 0
2.0, // 1
8.0,
9.0,
10.0
] );

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );

x = new Float32Array([
1.0, // 2
2.0,
3.0, // 1
4.0,
5.0 // 0
]);
y = new Float32Array([
6.0, // 0
7.0, // 1
8.0, // 2
9.0,
10.0
]);
param = new Float32Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 3, x, -2, 4, y, 1, 0, param );

xe = new Float32Array( [
8.0, // 2
2.0,
7.0, // 1
4.0,
6.0 // 0
] );
ye = new Float32Array( [
-5.0, // 0
-3.0, // 1
-1.0, // 2
9.0,
10.0
] );

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );

t.end();
});

Expand Down Expand Up @@ -384,8 +574,44 @@ tape( 'the function supports a `y` stride', function test( t ) {
16.0 // 2
] );

t.deepEqual( x, xe, 'returns expected value' );
t.deepEqual( y, ye, 'returns expected value' );
isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );

x = new Float32Array([
1.0, // 0
2.0, // 1
3.0,
4.0,
5.0
]);
y = new Float32Array([
6.0, // 0
7.0,
8.0,
9.0, // 1
10.0
]);
param = new Float32Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 2, x, 1, 0, y, 3, 0, param );

xe = new Float32Array( [
-18.0, // 0
-27.0, // 1
3.0,
4.0,
5.0
] );
ye = new Float32Array( [
2.0, // 0
7.0,
8.0,
4.0, // 1
10.0
] );

isApprox( t, x, xe, 1.0 );
isApprox( t, y, ye, 1.0 );

t.end();
});
Expand Down Expand Up @@ -422,6 +648,78 @@ tape( 'the function supports a `y` offset', function test( t ) {
isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );

x = new Float32Array([
1.0, // 0
2.0, // 1
3.0,
4.0,
5.0
]);
y = new Float32Array([
6.0, // 1
7.0,
8.0, // 0
9.0,
10.0
]);
param = new Float32Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 2, x, 1, 0, y, -2, 2, param );

xe = new Float32Array( [
8.0, // 0
6.0, // 1
3.0,
4.0,
5.0
] );
ye = new Float32Array( [
-2.0, // 1
7.0,
-1.0, // 0
9.0,
10.0
] );

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );

x = new Float32Array([
1.0, // 0
2.0, // 1
3.0, // 2
4.0,
5.0
]);
y = new Float32Array([
6.0, // 2
7.0,
8.0, // 1
9.0,
10.0 // 0
]);
param = new Float32Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 3, x, 1, 0, y, -2, 4, param );

xe = new Float32Array( [
-30.0, // 0
-24.0, // 1
-18.0, // 2
4.0,
5.0
] );
ye = new Float32Array( [
6.0, // 2
7.0,
4.0, // 1
9.0,
2.0 // 0
] );

isApprox( t, x, xe, 2.0 );
isApprox( t, y, ye, 2.0 );

t.end();
});

Expand Down Expand Up @@ -469,60 +767,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function leav
t.end();
});

tape( 'the function supports negative strides', function test( t ) {
var param;
var xe;
var ye;
var x;
var y;

x = new Float32Array([
0.6, // 1
0.1,
-0.5, // 0
0.8,
0.9,
-0.3,
-0.4
]);
y = new Float32Array([
0.5, // 0
-0.9, // 1
0.3,
0.7,
-0.6,
0.2,
0.8
]);
param = new Float32Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] );

srotm( 2, x, -2, 2, y, 1, 0, param );

xe = new Float32Array( [
3.3, // 1
0.1,
-2.0, // 0
0.8,
0.9,
-0.3,
-0.4
] );
ye = new Float32Array( [
-0.5, // 0
0.3, // 1
0.3,
0.7,
-0.6,
0.2,
0.8
] );

isApprox( t, x, xe, 10.0 );
isApprox( t, y, ye, 10.0 );

t.end();
});

tape( 'the function supports complex access patterns', function test( t ) {
var param;
var xe;
Expand Down
Loading

1 comment on commit 4d45aa2

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverage Report

Package Statements Branches Functions Lines
blas/base/srotm $\color{green}584/584$
$\color{green}+100.00\%$
$\color{green}61/61$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}584/584$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please # to comment.