Skip to content

Commit

Permalink
test: achieve complete code coverage in blas/base/dznrm2 and `blas/…
Browse files Browse the repository at this point in the history
…base/scnrm2`

PR-URL: #2977
Closes: #2543

Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Reviewed-by: Athan Reines <kgryte@gmail.com>
  • Loading branch information
gururaj1512 authored Oct 12, 2024
1 parent 43e7a33 commit c0a5dbe
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 0 deletions.
80 changes: 80 additions & 0 deletions lib/node_modules/@stdlib/blas/base/dznrm2/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,86 @@ tape( 'the function computes the L2-norm', function test( t ) {

actual = dznrm2( 3, zx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
zx = new Complex128Array([
1e150, // 1
1e150, // 1
1e150, // 2
1e150, // 2
1e150, // 3
1e150, // 3
1e150, // 4
1e150 // 4
]);
expected = 2.82842e+150;

actual = dznrm2( 4, zx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
zx = new Complex128Array([
1e-155, // 1
1e-155, // 1
1e-155, // 2
1e-155, // 2
1e-155, // 3
1e-155, // 3
1e-155, // 4
1e-155 // 4
]);
expected = 2.82843e-155;

actual = dznrm2( 4, zx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
zx = new Complex128Array([
1e150, // 1
1e50, // 1
1e150, // 2
1e50, // 2
1e150, // 3
1e50, // 3
1e150, // 4
1e50 // 4
]);
expected = 2.00000e150;

actual = dznrm2( 4, zx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
zx = new Complex128Array([
1e-155, // 1
1e50, // 1
1e-155, // 2
1e50, // 2
1e-155, // 3
1e50, // 3
1e-155, // 4
1e50 // 4
]);
expected = 2.00000e50;

actual = dznrm2( 4, zx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
zx = new Complex128Array([
1.4e-154, // 1
1.5e-154, // 1
1.4e-154, // 2
1.5e-154, // 2
1.4e-154, // 3
0, // 3
1.4e-154, // 4
0 // 4
]);
expected = 3.51283e-154;

actual = dznrm2( 4, zx, 1, 0 );
isApprox( t, actual, expected, 2.0 );
t.end();
});

Expand Down
80 changes: 80 additions & 0 deletions lib/node_modules/@stdlib/blas/base/scnrm2/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,86 @@ tape( 'the function computes the L2-norm', function test( t ) {

actual = scnrm2( 3, cx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
cx = new Complex64Array([
5e+15, // 1
5e+15, // 1
5e+15, // 2
5e+15, // 2
5e+15, // 3
5e+15, // 3
5e+15, // 4
5e+15 // 4
]);
expected = 14142135623730952;

actual = scnrm2( 4, cx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
cx = new Complex64Array([
1e-20, // 1
1e-20, // 1
1e-20, // 2
1e-20, // 2
1e-20, // 3
1e-20, // 3
1e-20, // 4
1e-20 // 4
]);
expected = 2.82843e-20;

actual = scnrm2( 4, cx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
cx = new Complex64Array([
1e20, // 1
1e10, // 1
1e20, // 2
1e10, // 2
1e20, // 3
1e10, // 3
1e20, // 4
1e10 // 4
]);
expected = 200000000000000000000;

actual = scnrm2( 4, cx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
cx = new Complex64Array([
1e-20, // 1
1e10, // 1
1e-20, // 2
1e10, // 2
1e-20, // 3
1e10, // 3
1e-20, // 4
1e10 // 4
]);
expected = 20000000000;

actual = scnrm2( 4, cx, 1, 0 );
isApprox( t, actual, expected, 2.0 );

// Checked on Wolfram Alpha:
cx = new Complex64Array([
1e-19, // 1
1.08420217e-19, // 1
1e-19, // 2
1.08420217e-19, // 2
1e-19, // 3
0, // 3
1e-19, // 4
0 // 4
]);
expected = 2.52012e-19;

actual = scnrm2( 4, cx, 1, 0 );
isApprox( t, actual, expected, 2.0 );
t.end();
});

Expand Down

1 comment on commit c0a5dbe

@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/dznrm2 $\color{green}455/455$
$\color{green}+100.00\%$
$\color{green}37/37$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}455/455$
$\color{green}+100.00\%$
blas/base/scnrm2 $\color{green}456/456$
$\color{green}+100.00\%$
$\color{green}37/37$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}456/456$
$\color{green}+100.00\%$

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

Please sign in to comment.