From bedd76c28fe5f791e5d13851152e416620307355 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sun, 14 Jun 2026 12:02:38 -0700 Subject: [PATCH] test: fix complex array indexing in `blas/ext/base/cxpy` --- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/cxpy/test/test.cxpy.js | 20 +++++++++++++------ .../ext/base/cxpy/test/test.cxpy.native.js | 20 +++++++++++++------ .../blas/ext/base/cxpy/test/test.ndarray.js | 20 +++++++++++++------ .../ext/base/cxpy/test/test.ndarray.native.js | 20 +++++++++++++------ 4 files changed, 56 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.js b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.js index ab868ca2f70d..b6775dc655b5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.js @@ -25,6 +25,8 @@ var tape = require( 'tape' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); var cxpy = require( './../lib/cxpy.js' ); @@ -283,6 +285,8 @@ tape( 'the function supports view offsets', function test( t ) { tape( 'if both strides are equal to `1`, the function efficiently adds elements of `x` to the corresponding elements of `y` and assigns the results to `y`', function test( t ) { var expected; + var xv; + var yv; var x; var y; var i; @@ -291,9 +295,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 100 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, y, 1 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); @@ -302,9 +308,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 240 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, y, 1 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.native.js index 4754e7265498..c46b9843dfdd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.cxpy.native.js @@ -26,6 +26,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -292,6 +294,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { tape( 'if both strides are equal to `1`, the function efficiently adds elements of `x` to the corresponding elements of `y` and assigns the results to `y`', opts, function test( t ) { var expected; + var xv; + var yv; var x; var y; var i; @@ -300,9 +304,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 100 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, y, 1 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); @@ -311,9 +317,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 240 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, y, 1 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.js index 94a95a898b9f..66565506881c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.js @@ -25,6 +25,8 @@ var tape = require( 'tape' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); var cxpy = require( './../lib/ndarray.js' ); @@ -283,6 +285,8 @@ tape( 'the function supports view offsets', function test( t ) { tape( 'if both strides are equal to `1`, the function efficiently adds elements of `x` to the corresponding elements of `y` and assigns the results to `y`', function test( t ) { var expected; + var xv; + var yv; var x; var y; var i; @@ -291,9 +295,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 100 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); @@ -302,9 +308,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 240 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.native.js index 2502a116a5c9..600658ba187a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cxpy/test/test.ndarray.native.js @@ -26,6 +26,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -292,6 +294,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { tape( 'if both strides are equal to `1`, the function efficiently adds elements of `x` to the corresponding elements of `y` and assigns the results to `y`', opts, function test( t ) { var expected; + var xv; + var yv; var x; var y; var i; @@ -300,9 +304,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 100 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); @@ -311,9 +317,11 @@ tape( 'if both strides are equal to `1`, the function efficiently adds elements y = new Complex64Array( 240 ); expected = new Complex64Array( x.length ); for ( i = 0; i < x.length; i++ ) { - x[ i ] = i; - y[ i ] = x.length - i; - expected[ i ] = x[ i ] + y[ i ]; + xv = new Complex64( i, 0.0 ); + yv = new Complex64( x.length - i, 0.0 ); + x.set( xv, i ); + y.set( yv, i ); + expected.set( caddf( xv, yv ), i ); } cxpy( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' );