From f12537419371301a035ca53565064fb585c98177 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 3 Apr 2025 14:41:39 +0530 Subject: [PATCH 1/3] test: completes code coverage in blas/base/caxpy --- 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/caxpy/test/test.caxpy.js | 95 ++++++++------ .../blas/base/caxpy/test/test.caxpy.native.js | 95 ++++++++------ .../blas/base/caxpy/test/test.ndarray.js | 119 +++++++++++------- .../base/caxpy/test/test.ndarray.native.js | 119 +++++++++++------- 4 files changed, 260 insertions(+), 168 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.js b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.js index 941e9004be22..c38510e38750 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.js +++ b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.js @@ -78,7 +78,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -93,8 +93,8 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -109,13 +109,13 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, cy, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.55, // 2 @@ -130,7 +130,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -142,7 +142,7 @@ tape( 'the function supports a `cx` stride', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -157,8 +157,8 @@ tape( 'the function supports a `cx` stride', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -173,13 +173,13 @@ tape( 'the function supports a `cx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, cy, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.57, // 2 @@ -194,7 +194,7 @@ tape( 'the function supports a `cx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -206,7 +206,7 @@ tape( 'the function supports a `cy` stride', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -221,8 +221,8 @@ tape( 'the function supports a `cy` stride', function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, @@ -237,13 +237,13 @@ tape( 'the function supports a `cy` stride', function test( t ) { -0.3, 0.8, // 4 -0.7 // 4 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, cy, 2 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -0.9, @@ -258,7 +258,7 @@ tape( 'the function supports a `cy` stride', function test( t ) { -0.3, 0.32, // 4 -1.16 // 4 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -279,6 +279,29 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); +tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { + var expected; + var viewY; + var ca; + var cx; + var cy; + + cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + ca = new Complex64( 0.0, 0.0 ); + + viewY = new Float32Array( cy.buffer ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + caxpy( -1, ca, cx, 1, 0, cy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + caxpy( 0, ca, cx, 1, 0, cy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the second input array unchanged', function test( t ) { var expected; var viewY; @@ -309,7 +332,7 @@ tape( 'the function supports negative `cx` strides', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, @@ -324,8 +347,8 @@ tape( 'the function supports negative `cx` strides', function test( t ) { 0.4, -0.6, // 1 0.6 // 1 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -340,13 +363,13 @@ tape( 'the function supports negative `cx` strides', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -2, cy, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 1 0.06, // 1 -1.54, // 2 @@ -361,7 +384,7 @@ tape( 'the function supports negative `cx` strides', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -373,7 +396,7 @@ tape( 'the function supports negative `cy` strides', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -388,8 +411,8 @@ tape( 'the function supports negative `cy` strides', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -404,13 +427,13 @@ tape( 'the function supports negative `cy` strides', function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, cy, -2 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 4 0.06, // 4 -0.9, @@ -425,7 +448,7 @@ tape( 'the function supports negative `cy` strides', function test( t ) { -0.3, 0.52, // 1 -1.51 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -437,7 +460,7 @@ tape( 'the function supports complex access patterns', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, // 3 @@ -452,8 +475,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -468,13 +491,13 @@ tape( 'the function supports complex access patterns', function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -1, cy, -2 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 4 -1.41, // 4 -0.9, @@ -489,7 +512,7 @@ tape( 'the function supports complex access patterns', function test( t ) { -0.3, 0.32, // 1 -1.16 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js index 2ff1902df663..a21f684a678c 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js +++ b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js @@ -87,7 +87,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -102,8 +102,8 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -118,13 +118,13 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, cy, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.55, // 2 @@ -139,7 +139,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -151,7 +151,7 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -166,8 +166,8 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -182,13 +182,13 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, cy, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.57, // 2 @@ -203,7 +203,7 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -215,7 +215,7 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -230,8 +230,8 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, @@ -246,13 +246,13 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { -0.3, 0.8, // 4 -0.7 // 4 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, cy, 2 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -0.9, @@ -267,7 +267,7 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { -0.3, 0.32, // 4 -1.16 // 4 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -288,6 +288,29 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); +tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { + var expected; + var viewY; + var ca; + var cx; + var cy; + + cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + ca = new Complex64( 0.0, 0.0 ); + + viewY = new Float32Array( cy.buffer ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + caxpy( -1, ca, cx, 1, cy, 1 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + caxpy( 0, ca, cx, 1, cy, 1 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the second input array unchanged', opts, function test( t ) { var expected; var viewY; @@ -318,7 +341,7 @@ tape( 'the function supports negative `cx` strides', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, @@ -333,8 +356,8 @@ tape( 'the function supports negative `cx` strides', opts, function test( t ) { 0.4, -0.6, // 1 0.6 // 1 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -349,13 +372,13 @@ tape( 'the function supports negative `cx` strides', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -2, cy, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 1 0.06, // 1 -1.54, // 2 @@ -370,7 +393,7 @@ tape( 'the function supports negative `cx` strides', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -382,7 +405,7 @@ tape( 'the function supports negative `cy` strides', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -397,8 +420,8 @@ tape( 'the function supports negative `cy` strides', opts, function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -413,13 +436,13 @@ tape( 'the function supports negative `cy` strides', opts, function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, cy, -2 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 4 0.06, // 4 -0.9, @@ -434,7 +457,7 @@ tape( 'the function supports negative `cy` strides', opts, function test( t ) { -0.3, 0.52, // 1 -1.51 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -446,7 +469,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, // 3 @@ -461,8 +484,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -477,13 +500,13 @@ tape( 'the function supports complex access patterns', opts, function test( t ) -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -1, cy, -2 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 4 -1.41, // 4 -0.9, @@ -498,7 +521,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) -0.3, 0.32, // 1 -1.16 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.js index 4a8e411efd9e..9cc06fcac38e 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.js @@ -78,7 +78,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -93,8 +93,8 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -109,13 +109,13 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, 0, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.55, // 2 @@ -130,7 +130,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -142,7 +142,7 @@ tape( 'the function supports a `cx` stride', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -157,8 +157,8 @@ tape( 'the function supports a `cx` stride', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -173,13 +173,13 @@ tape( 'the function supports a `cx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, 0, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.57, // 2 @@ -194,7 +194,7 @@ tape( 'the function supports a `cx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -206,7 +206,7 @@ tape( 'the function supports a `cx` offset', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, -0.8, -0.4, // 1 @@ -221,8 +221,8 @@ tape( 'the function supports a `cx` offset', function test( t ) { 0.4, // 3 -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -237,13 +237,13 @@ tape( 'the function supports a `cx` offset', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 3, ca, cx, 2, 1, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ -0.05, // 1 -0.6, // 1 -1.38, // 2 @@ -258,7 +258,7 @@ tape( 'the function supports a `cx` offset', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -270,7 +270,7 @@ tape( 'the function supports a `cy` stride', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -285,8 +285,8 @@ tape( 'the function supports a `cy` stride', function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, @@ -301,13 +301,13 @@ tape( 'the function supports a `cy` stride', function test( t ) { -0.3, 0.8, // 4 -0.7 // 4 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, 0, cy, 2, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -0.9, @@ -322,7 +322,7 @@ tape( 'the function supports a `cy` stride', function test( t ) { -0.3, 0.32, // 4 -1.16 // 4 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -334,7 +334,7 @@ tape( 'the function supports a `cy` offset', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -349,8 +349,8 @@ tape( 'the function supports a `cy` offset', function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, -0.6, -0.9, // 1 @@ -365,13 +365,13 @@ tape( 'the function supports a `cy` offset', function test( t ) { -0.3, // 3 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 3, ca, cx, 1, 0, cy, 2, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.6, -0.6, -1.18, // 1 @@ -386,7 +386,7 @@ tape( 'the function supports a `cy` offset', function test( t ) { -0.59, // 3 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -407,6 +407,29 @@ tape( 'the function returns a reference to the output array', function test( t ) t.end(); }); +tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { + var expected; + var viewY; + var ca; + var cx; + var cy; + + cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + ca = new Complex64( 0.0, 0.0 ); + + viewY = new Float32Array( cy.buffer ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + caxpy( -1, ca, cx, 1, 0, cy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + caxpy( 0, ca, cx, 1, 0, cy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the second input array unchanged', function test( t ) { var expected; var viewY; @@ -437,7 +460,7 @@ tape( 'the function supports a negative `cx` stride', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, @@ -452,8 +475,8 @@ tape( 'the function supports a negative `cx` stride', function test( t ) { 0.4, -0.6, // 1 0.6 // 1 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -468,13 +491,13 @@ tape( 'the function supports a negative `cx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -2, 6, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 1 0.06, // 1 -1.54, // 2 @@ -489,7 +512,7 @@ tape( 'the function supports a negative `cx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -501,7 +524,7 @@ tape( 'the function supports a negative `cy` stride', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -516,8 +539,8 @@ tape( 'the function supports a negative `cy` stride', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -532,13 +555,13 @@ tape( 'the function supports a negative `cy` stride', function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, 0, cy, -2, 6 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 4 0.06, // 4 -0.9, @@ -553,7 +576,7 @@ tape( 'the function supports a negative `cy` stride', function test( t ) { -0.3, 0.52, // 1 -1.51 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -565,7 +588,7 @@ tape( 'the function supports complex access patterns', function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, // 3 @@ -580,8 +603,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -596,13 +619,13 @@ tape( 'the function supports complex access patterns', function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -1, 3, cy, -2, 6 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 4 -1.41, // 4 -0.9, @@ -617,7 +640,7 @@ tape( 'the function supports complex access patterns', function test( t ) { -0.3, 0.32, // 1 -1.16 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js index 9b2832ee4b2d..93a836e83be1 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js @@ -87,7 +87,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -102,8 +102,8 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -118,13 +118,13 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, 0, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.55, // 2 @@ -139,7 +139,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -151,7 +151,7 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -166,8 +166,8 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -182,13 +182,13 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, 0, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -1.57, // 2 @@ -203,7 +203,7 @@ tape( 'the function supports a `cx` stride', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -215,7 +215,7 @@ tape( 'the function supports a `cx` offset', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, -0.8, -0.4, // 1 @@ -230,8 +230,8 @@ tape( 'the function supports a `cx` offset', opts, function test( t ) { 0.4, // 3 -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -246,13 +246,13 @@ tape( 'the function supports a `cx` offset', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 3, ca, cx, 2, 1, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ -0.05, // 1 -0.6, // 1 -1.38, // 2 @@ -267,7 +267,7 @@ tape( 'the function supports a `cx` offset', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -279,7 +279,7 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -294,8 +294,8 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, @@ -310,13 +310,13 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { -0.3, 0.8, // 4 -0.7 // 4 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 1, 0, cy, 2, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 1 -1.41, // 1 -0.9, @@ -331,7 +331,7 @@ tape( 'the function supports a `cy` stride', opts, function test( t ) { -0.3, 0.32, // 4 -1.16 // 4 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -343,7 +343,7 @@ tape( 'the function supports a `cy` offset', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -358,8 +358,8 @@ tape( 'the function supports a `cy` offset', opts, function test( t ) { 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, -0.6, -0.9, // 1 @@ -374,13 +374,13 @@ tape( 'the function supports a `cy` offset', opts, function test( t ) { -0.3, // 3 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 3, ca, cx, 1, 0, cy, 2, 1 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.6, -0.6, -1.18, // 1 @@ -395,7 +395,7 @@ tape( 'the function supports a `cy` offset', opts, function test( t ) { -0.59, // 3 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -416,6 +416,29 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); +tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { + var expected; + var viewY; + var ca; + var cx; + var cy; + + cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + ca = new Complex64( 0.0, 0.0 ); + + viewY = new Float32Array( cy.buffer ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + caxpy( -1, ca, cx, 1, 0, cy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + caxpy( 0, ca, cx, 1, 0, cy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the second input array unchanged', opts, function test( t ) { var expected; var viewY; @@ -446,7 +469,7 @@ tape( 'the function supports a negative `cx` stride', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, @@ -461,8 +484,8 @@ tape( 'the function supports a negative `cx` stride', opts, function test( t ) { 0.4, -0.6, // 1 0.6 // 1 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -477,13 +500,13 @@ tape( 'the function supports a negative `cx` stride', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -2, 6, cy, 1, 0 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 1 0.06, // 1 -1.54, // 2 @@ -498,7 +521,7 @@ tape( 'the function supports a negative `cx` stride', opts, function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -510,7 +533,7 @@ tape( 'the function supports a negative `cy` stride', opts, function test( t ) { var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -525,8 +548,8 @@ tape( 'the function supports a negative `cy` stride', opts, function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -541,13 +564,13 @@ tape( 'the function supports a negative `cy` stride', opts, function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, 2, 0, cy, -2, 6 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.78, // 4 0.06, // 4 -0.9, @@ -562,7 +585,7 @@ tape( 'the function supports a negative `cy` stride', opts, function test( t ) { -0.3, 0.52, // 1 -1.51 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); @@ -574,7 +597,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var cx; var cy; - cx = new Complex64Array( [ + cx = new Complex64Array([ 0.7, // 4 -0.8, // 4 -0.4, // 3 @@ -589,8 +612,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.4, -0.6, 0.6 - ] ); - cy = new Complex64Array( [ + ]); + cy = new Complex64Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -605,13 +628,13 @@ tape( 'the function supports complex access patterns', opts, function test( t ) -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); ca = new Complex64( 0.4, -0.7 ); caxpy( 4, ca, cx, -1, 3, cy, -2, 6 ); viewY = new Float32Array( cy.buffer ); - expected = new Float32Array( [ + expected = new Float32Array([ 0.32, // 4 -1.41, // 4 -0.9, @@ -626,7 +649,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) -0.3, 0.32, // 1 -1.16 // 1 - ] ); + ]); isApprox( t, viewY, expected, 10.0 ); t.end(); }); From 9d48ef08b5f3138cef2fba9489d2725a5ff2445b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Thu, 3 Apr 2025 14:58:01 +0530 Subject: [PATCH 2/3] chore: modified if conditions --- 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: na - 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/caxpy/lib/ndarray.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/caxpy/lib/ndarray.js index bb377e385e12..f43da14b46ad 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/caxpy/lib/ndarray.js @@ -56,10 +56,7 @@ function caxpy( N, ca, cx, strideX, offsetX, cy, strideY, offsetY ) { var iy; var i; - if ( N <= 0 ) { - return cy; - } - if ( scabs1( ca ) === 0.0 ) { + if ( N <= 0 || scabs1( ca ) === 0.0 ) { return cy; } ix = offsetX; From c0d9e568c55e9b79c4276726be28de1c2ebc6231 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 3 Apr 2025 02:46:37 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/blas/base/caxpy/test/test.caxpy.native.js | 2 +- .../@stdlib/blas/base/caxpy/test/test.ndarray.native.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js index a21f684a678c..905507b109d1 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js +++ b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.caxpy.native.js @@ -288,7 +288,7 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); -tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { +tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', opts, function test( t ) { var expected; var viewY; var ca; diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js index 93a836e83be1..cd9a8455b236 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/caxpy/test/test.ndarray.native.js @@ -416,7 +416,7 @@ tape( 'the function returns a reference to the output array', opts, function tes t.end(); }); -tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { +tape( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged', opts, function test( t ) { var expected; var viewY; var ca;