Skip to content

Commit

Permalink
test: clarify method to calculate expected value and adjust notation
Browse files Browse the repository at this point in the history
  • Loading branch information
gururaj1512 committed Oct 1, 2024
1 parent 489c656 commit 84bbad5
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 87 deletions.
92 changes: 48 additions & 44 deletions lib/node_modules/@stdlib/blas/base/dznrm2/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,81 +106,85 @@ 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
1e150, // 1
1e150, // 1
1e150, // 2
1e150, // 2
1e150, // 3
1e150, // 3
1e150, // 4
1e150 // 4
]);
expected = 2.828E+150;
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
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.828E-155;
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
1e150, // 1
1e50, // 1
1e150, // 2
1e50, // 2
1e150, // 3
1e50, // 3
1e150, // 4
1e50 // 4
]);
expected = 2e150;
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
1e-155, // 1
1e50, // 1
1e-155, // 2
1e50, // 2
1e-155, // 3
1e50, // 3
1e-155, // 4
1e50 // 4
]);
expected = 2E50;
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
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
1.4e-154, // 4
0 // 4
]);
expected = 3.51E-154;
expected = 3.51283e-154;

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

t.end();
});

Expand Down
91 changes: 48 additions & 43 deletions lib/node_modules/@stdlib/blas/base/scnrm2/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,77 +106,82 @@ 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
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 = 14142135623730950;
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
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.828427124E-20;
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
1e20, // 1
1e10, // 1
1e20, // 2
1e10, // 2
1e20, // 3
1e10, // 3
1e20, // 4
1e10 // 4
]);
expected = 2E20;
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
1e-20, // 1
1e10, // 1
1e-20, // 2
1e10, // 2
1e-20, // 3
1e10, // 3
1e-20, // 4
1e10 // 4
]);
expected = 2E10;
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
1e-19, // 1
1.08420217e-19, // 1
1e-19, // 2
1.08420217e-19, // 2
1e-19, // 3
0, // 3
1E-19, // 4
1e-19, // 4
0 // 4
]);
expected = 2.5207E-19;
expected = 2.52012e-19;

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

0 comments on commit 84bbad5

Please sign in to comment.