From 725bf5108159567dcbe2030bd7a9e0897075ce10 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 3 Apr 2025 18:27:47 +0530 Subject: [PATCH 01/13] test: completes code coverage in blas/base/dnrm2 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/base/dnrm2/test/test.dnrm2.js | 24 +++++++++++++++++++ .../blas/base/dnrm2/test/test.dnrm2.native.js | 24 +++++++++++++++++++ .../blas/base/dnrm2/test/test.ndarray.js | 24 +++++++++++++++++++ .../base/dnrm2/test/test.ndarray.native.js | 24 +++++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index 22a6a4b1316c..0004c1897ece 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -56,6 +56,30 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { t.end(); }); +tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.0e147, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) { var x; var z; diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js index 9441031a1b28..5860917026d1 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js @@ -65,6 +65,30 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t t.end(); }); +tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.0e147, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { var x; var z; diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js index 1962dcf9419e..550a412e48f5 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js @@ -56,6 +56,30 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { t.end(); }); +tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.0e147, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) { var x; var z; diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js index 541af646c82e..4203c671a369 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js @@ -65,6 +65,30 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t t.end(); }); +tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.0e147, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { + var x; + var z; + + x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { var x; var z; From 83bec2a9c2e910de9a98f14187c9a0e6cccca54a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 3 Apr 2025 19:06:05 +0530 Subject: [PATCH 02/13] chore: add test cases --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dnrm2/test/test.dnrm2.js | 10 ++++++++++ .../@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js | 10 ++++++++++ .../@stdlib/blas/base/dnrm2/test/test.ndarray.js | 10 ++++++++++ .../blas/base/dnrm2/test/test.ndarray.native.js | 10 ++++++++++ 4 files changed, 40 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index 0004c1897ece..5853e7b7b7ae 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -65,6 +65,11 @@ tape( 'the function calculates the L2-norm of a vector ( large value ) ', functi z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e147, 'returns expected value' ); + x = new Float64Array( [ 2.5e146, 5.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.end(); }); @@ -77,6 +82,11 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + x = new Float64Array( [ 5.0, 1.0e155 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js index 5860917026d1..e87eb18f748a 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js @@ -74,6 +74,11 @@ tape( 'the function calculates the L2-norm of a vector ( large value ) ', functi z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e147, 'returns expected value' ); + x = new Float64Array( [ 2.5e146, 5.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.end(); }); @@ -86,6 +91,11 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + x = new Float64Array( [ 5.0, 1.0e155 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js index 550a412e48f5..f00a8ff58132 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js @@ -65,6 +65,11 @@ tape( 'the function calculates the L2-norm of a vector ( large value ) ', functi z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e147, 'returns expected value' ); + x = new Float64Array( [ 2.5e146, 5.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.end(); }); @@ -77,6 +82,11 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + x = new Float64Array( [ 5.0, 1.0e155 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js index 4203c671a369..e27696f25ddf 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js @@ -74,6 +74,11 @@ tape( 'the function calculates the L2-norm of a vector ( large value ) ', functi z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e147, 'returns expected value' ); + x = new Float64Array( [ 2.5e146, 5.0 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.end(); }); @@ -86,6 +91,11 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + x = new Float64Array( [ 5.0, 1.0e155 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.end(); }); From db172be516be6d39303574bf25a7f6cf442578d6 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 3 Apr 2025 19:13:37 +0530 Subject: [PATCH 03/13] chore: update test cases --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js | 4 ++-- .../@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js | 4 ++-- lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js | 4 ++-- .../@stdlib/blas/base/dnrm2/test/test.ndarray.native.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index 5853e7b7b7ae..eececee27055 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -82,10 +82,10 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); - x = new Float64Array( [ 5.0, 1.0e155 ] ); + x = new Float64Array( [ 5.0, 1.0e-155 ] ); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.strictEqual( z, 5.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js index e87eb18f748a..024617f4f00c 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js @@ -91,10 +91,10 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); - x = new Float64Array( [ 5.0, 1.0e155 ] ); + x = new Float64Array( [ 5.0, 1.0e-155 ] ); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.strictEqual( z, 5.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js index f00a8ff58132..95ad6e583c2d 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js @@ -82,10 +82,10 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); - x = new Float64Array( [ 5.0, 1.0e155 ] ); + x = new Float64Array( [ 5.0, 1.0e-155 ] ); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.strictEqual( z, 5.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js index e27696f25ddf..50697070cf26 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js @@ -91,10 +91,10 @@ tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', functio z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); - x = new Float64Array( [ 5.0, 1.0e155 ] ); + x = new Float64Array( [ 5.0, 1.0e-155 ] ); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 1.0e155, 'returns expected value' ); + t.strictEqual( z, 5.0, 'returns expected value' ); t.end(); }); From f2668cf0457f212743775bae226c6cb3962cb53f Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 4 Apr 2025 00:28:52 +0530 Subject: [PATCH 04/13] chore: add test cases --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/base/dnrm2/test/test.dnrm2.js | 70 ++++++++++++------- .../blas/base/dnrm2/test/test.dnrm2.native.js | 66 +++++++++++------ .../blas/base/dnrm2/test/test.ndarray.js | 62 ++++++++++------ .../base/dnrm2/test/test.ndarray.native.js | 62 ++++++++++------ 4 files changed, 174 insertions(+), 86 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index eececee27055..ec008a83642d 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -23,9 +23,40 @@ var tape = require( 'tape' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); var dnrm2 = require( './../lib/dnrm2.js' ); +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + // TESTS // tape( 'main export is a function', function test( t ) { @@ -34,8 +65,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 3', function test( t ) { - t.strictEqual( dnrm2.length, 3, 'returns expected value' ); +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( dnrm2.length, 4, 'returns expected value' ); t.end(); }); @@ -45,47 +76,38 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - z = dnrm2( x.length, x, 1 ); + z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 55.0 ), 'returns expected value' ); x = new Float64Array( [ -4.0 ] ); - z = dnrm2( x.length, x, 1 ); + z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { - var x; - var z; - - x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.0e147, 'returns expected value' ); + t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array( [ 2.5e146, 5.0 ] ); + x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.strictEqual( z, 2.0e-155, 'returns expected value' ); - t.end(); -}); + x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); -tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { - var x; - var z; + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array( [ 5.0, 1.0e-155 ] ); + x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 5.0, 'returns expected value' ); + isApprox( t, z, 2.483948e-154, 2.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js index 024617f4f00c..efe5fcfc7c33 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js @@ -24,6 +24,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -35,6 +37,35 @@ var opts = { }; +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + // TESTS // tape( 'main export is a function', opts, function test( t ) { @@ -54,47 +85,38 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - z = dnrm2( x.length, x, 1 ); + z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, sqrt( 55.0 ), 'returns expected value' ); x = new Float64Array( [ -4.0 ] ); - z = dnrm2( x.length, x, 1 ); + z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { - var x; - var z; - - x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.0e147, 'returns expected value' ); + t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array( [ 2.5e146, 5.0 ] ); + x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.strictEqual( z, 2.0e-155, 'returns expected value' ); - t.end(); -}); + x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); -tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { - var x; - var z; + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array( [ 5.0, 1.0e-155 ] ); + x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 5.0, 'returns expected value' ); + isApprox( t, z, 2.483948e-154, 2.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js index 95ad6e583c2d..7b42c79bd06a 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js @@ -23,9 +23,40 @@ var tape = require( 'tape' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); var dnrm2 = require( './../lib/ndarray.js' ); +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + // TESTS // tape( 'main export is a function', function test( t ) { @@ -53,39 +84,30 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { - var x; - var z; - - x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.0e147, 'returns expected value' ); + t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array( [ 2.5e146, 5.0 ] ); + x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.strictEqual( z, 2.0e-155, 'returns expected value' ); - t.end(); -}); + x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); -tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { - var x; - var z; + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array( [ 5.0, 1.0e-155 ] ); + x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 5.0, 'returns expected value' ); + isApprox( t, z, 2.483948e-154, 2.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js index 50697070cf26..19bbfa18e5b4 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js @@ -24,6 +24,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -35,6 +37,35 @@ var opts = { }; +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + // TESTS // tape( 'main export is a function', opts, function test( t ) { @@ -62,39 +93,30 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function calculates the L2-norm of a vector ( large value ) ', function test( t ) { - var x; - var z; - - x = new Float64Array( [ 1.0, 2.0e147, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.0e147, 'returns expected value' ); + t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array( [ 2.5e146, 5.0 ] ); + x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 2.5e146, 'returns expected value' ); + t.strictEqual( z, 2.0e-155, 'returns expected value' ); - t.end(); -}); + x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); -tape( 'the function calculates the L2-norm of a vector ( tiny value ) ', function test( t ) { - var x; - var z; + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array( [ 1.0, 3.0e-154, -4.0, 5.0, 0.0, 3.0 ] ); + x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, sqrt( 51.0 ), 'returns expected value' ); + isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array( [ 5.0, 1.0e-155 ] ); + x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); z = dnrm2( x.length, x, 1, 0 ); - t.strictEqual( z, 5.0, 'returns expected value' ); + isApprox( t, z, 2.483948e-154, 2.0 ); t.end(); }); From 86d7b551d822e864f8cd7dc6ad9e7f17feab2a68 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 4 Apr 2025 00:36:59 +0530 Subject: [PATCH 05/13] fix: update test cases --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index ec008a83642d..3ea1ac05175e 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -65,8 +65,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( dnrm2.length, 4, 'returns expected value' ); +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( dnrm2.length, 3, 'returns expected value' ); t.end(); }); From b84b8c8eeb0f4a3cd3436777460f370841767c1b Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 4 Apr 2025 10:39:53 +0530 Subject: [PATCH 06/13] fix: add decimal and remove offset Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../blas/base/dnrm2/test/test.dnrm2.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index 3ea1ac05175e..c6453939a654 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -76,37 +76,37 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, sqrt( 55.0 ), 'returns expected value' ); x = new Float64Array( [ -4.0 ] ); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); + x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); + x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); + x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); + x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e50, 2.0 ); x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); isApprox( t, z, 2.483948e-154, 2.0 ); t.end(); From 9586cf8d408786261d54d4bfdcfbc073ed8f9e4a Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 4 Apr 2025 10:52:33 +0530 Subject: [PATCH 07/13] fix: add decimal and remove offset Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../blas/base/dnrm2/test/test.dnrm2.native.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js index efe5fcfc7c33..4f73d72810f1 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js @@ -85,37 +85,37 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, sqrt( 55.0 ), 'returns expected value' ); x = new Float64Array( [ -4.0 ] ); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); + x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); + x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); + x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); + x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e50, 2.0 ); x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); - z = dnrm2( x.length, x, 1, 0 ); + z = dnrm2( x.length, x, 1 ); isApprox( t, z, 2.483948e-154, 2.0 ); t.end(); From b97be8ea1778af7001761aec07388869ef654f99 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 4 Apr 2025 10:56:11 +0530 Subject: [PATCH 08/13] fix: add decimals Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dnrm2/test/test.ndarray.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js index 7b42c79bd06a..2c4e5187d38a 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js @@ -84,22 +84,22 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); + x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); + x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); + x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); + x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e50, 2.0 ); From 51912f37518683aa76d5def3e52402c8f946ceb8 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 4 Apr 2025 10:58:13 +0530 Subject: [PATCH 09/13] fix: add decimals Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dnrm2/test/test.ndarray.native.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js index 19bbfa18e5b4..2e931cafbff6 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js @@ -93,22 +93,22 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e150, 1e150, 1e150 ]); + x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1e-155, 1e-155, 1e-155, 1e-155 ]); + x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1e150, 1e50, 1e150, 1e50 ]); + x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1e-155, 1e50, 1e-155, 1e50 ]); + x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e50, 2.0 ); From 1a67d216b27ff8454349847d4a3674ac7f22d2de Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 5 Apr 2025 14:02:51 +0530 Subject: [PATCH 10/13] fix: indentations Co-authored-by: Athan Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index c6453939a654..4c9440f62bec 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -84,7 +84,7 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); + x = new Float64Array( [ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ] ); z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); From 8743d1b5a8a1ea1c8a226ced168a18e2ea30a480 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 5 Apr 2025 15:18:35 +0530 Subject: [PATCH 11/13] fix: add indentations --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dnrm2/test/test.dnrm2.js | 8 ++++---- .../@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js | 10 +++++----- .../@stdlib/blas/base/dnrm2/test/test.ndarray.js | 10 +++++----- .../blas/base/dnrm2/test/test.ndarray.native.js | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index 4c9440f62bec..2235b169e0aa 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -89,22 +89,22 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); + x = new Float64Array( [ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ] ); z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); + x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); + x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); + x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); z = dnrm2( x.length, x, 1 ); isApprox( t, z, 2.483948e-154, 2.0 ); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js index 4f73d72810f1..bcb167103d15 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js @@ -93,27 +93,27 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); + x = new Float64Array( [ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ] ); z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); + x = new Float64Array( [ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ] ); z = dnrm2( x.length, x, 1 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); + x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); + x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); z = dnrm2( x.length, x, 1 ); isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); + x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); z = dnrm2( x.length, x, 1 ); isApprox( t, z, 2.483948e-154, 2.0 ); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js index 2c4e5187d38a..274fe0442544 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js @@ -84,27 +84,27 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); + x = new Float64Array( [ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ] ); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); + x = new Float64Array( [ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ] ); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); + x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); + x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); + x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 2.483948e-154, 2.0 ); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js index 2e931cafbff6..7e9588fb0976 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js @@ -93,27 +93,27 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 4.0, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ]); + x = new Float64Array( [ 1.0e150, 1.0e150, 1.0e150, 1.0e150 ] ); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e+150, 'returns expected value' ); - x = new Float64Array([ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ]); + x = new Float64Array( [ 1.0e-155, 1.0e-155, 1.0e-155, 1.0e-155 ] ); z = dnrm2( x.length, x, 1, 0 ); t.strictEqual( z, 2.0e-155, 'returns expected value' ); - x = new Float64Array([ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ]); + x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e150, 2.0 ); - x = new Float64Array([ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ]); + x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 1.41421e50, 2.0 ); - x = new Float64Array([ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ]); + x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); z = dnrm2( x.length, x, 1, 0 ); isApprox( t, z, 2.483948e-154, 2.0 ); From 5044c2290629194aa0af300e77980b1697a42551 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 13 Apr 2025 11:02:22 +0530 Subject: [PATCH 12/13] chore: increase test precision --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dnrm2/test/test.dnrm2.js | 14 ++++++++------ .../blas/base/dnrm2/test/test.dnrm2.native.js | 12 ++++++------ .../@stdlib/blas/base/dnrm2/test/test.ndarray.js | 6 +++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js index 2235b169e0aa..526169a16a72 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.js @@ -96,18 +96,20 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); - z = dnrm2( x.length, x, 1 ); - isApprox( t, z, 1.41421e150, 2.0 ); + x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); + + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.4142135623730951e150, 1.0 ); x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); - z = dnrm2( x.length, x, 1 ); - isApprox( t, z, 1.41421e50, 2.0 ); + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.4142135623730951e50, 1.0 ); x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); - z = dnrm2( x.length, x, 1 ); - isApprox( t, z, 2.483948e-154, 2.0 ); + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 2.4839480006885204e-154, 1.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js index bcb167103d15..0b265ce7667f 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.dnrm2.native.js @@ -105,18 +105,18 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); - z = dnrm2( x.length, x, 1 ); - isApprox( t, z, 1.41421e150, 2.0 ); + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.4142135623730951e150, 1.0 ); x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); - z = dnrm2( x.length, x, 1 ); - isApprox( t, z, 1.41421e50, 2.0 ); + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 1.4142135623730951e50, 1.0 ); x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); - z = dnrm2( x.length, x, 1 ); - isApprox( t, z, 2.483948e-154, 2.0 ); + z = dnrm2( x.length, x, 1, 0 ); + isApprox( t, z, 2.4839480006885204e-154, 1.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js index 274fe0442544..d006f32794ea 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.js @@ -97,17 +97,17 @@ tape( 'the function calculates the L2-norm of a vector', function test( t ) { x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); - isApprox( t, z, 1.41421e150, 2.0 ); + isApprox( t, z, 1.4142135623730951e150, 1.0 ); x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); - isApprox( t, z, 1.41421e50, 2.0 ); + isApprox( t, z, 1.4142135623730951e50, 1.0 ); x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); z = dnrm2( x.length, x, 1, 0 ); - isApprox( t, z, 2.483948e-154, 2.0 ); + isApprox( t, z, 2.4839480006885204e-154, 1.0 ); t.end(); }); From afbae6ca6c26900209ddb2f41225f9d64fb32c2e Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 14 Apr 2025 09:42:28 +0530 Subject: [PATCH 13/13] chore: update test case --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dnrm2/test/test.ndarray.native.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js index 7e9588fb0976..bef281bbf0ce 100644 --- a/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dnrm2/test/test.ndarray.native.js @@ -106,17 +106,17 @@ tape( 'the function calculates the L2-norm of a vector', opts, function test( t x = new Float64Array( [ 1.0e150, 1.0e50, 1.0e150, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); - isApprox( t, z, 1.41421e150, 2.0 ); + isApprox( t, z, 1.4142135623730951e150, 1.0 ); x = new Float64Array( [ 1.0e-155, 1.0e50, 1.0e-155, 1.0e50 ] ); z = dnrm2( x.length, x, 1, 0 ); - isApprox( t, z, 1.41421e50, 2.0 ); + isApprox( t, z, 1.4142135623730951e50, 1.0 ); x = new Float64Array( [ 1.4e-154, 1.5e-154, 1.4e-154, 0.0 ] ); z = dnrm2( x.length, x, 1, 0 ); - isApprox( t, z, 2.483948e-154, 2.0 ); + isApprox( t, z, 2.4839480006885204e-154, 1.0 ); t.end(); });