diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.js index cd7ac3d72994..5fc2a235521a 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/lib/ndarray.js @@ -64,10 +64,7 @@ function zaxpy( N, za, zx, strideX, offsetX, zy, strideY, offsetY ) { var im; var i; - if ( N <= 0 ) { - return zy; - } - if ( dcabs1( za ) === 0.0 ) { + if ( N <= 0 || dcabs1( za ) === 0.0 ) { return zy; } re = real( za ); diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.js index 176fc88a890d..0e9e16535946 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.js @@ -78,7 +78,7 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -93,8 +93,8 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy 0.4, -0.6, 0.6 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -109,13 +109,13 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy -0.3, 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 1, 0, zy, 1, 0 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.32, // 1 -1.41, // 1 -1.55, // 2 @@ -130,7 +130,7 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -142,7 +142,7 @@ tape( 'the function supports a `zx` stride', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -157,8 +157,8 @@ tape( 'the function supports a `zx` stride', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -173,13 +173,13 @@ tape( 'the function supports a `zx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 2, 0, zy, 1, 0 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.32, // 1 -1.41, // 1 -1.57, // 2 @@ -194,7 +194,7 @@ tape( 'the function supports a `zx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -206,7 +206,7 @@ tape( 'the function supports a `zx` offset', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, -0.8, -0.4, // 1 @@ -221,8 +221,8 @@ tape( 'the function supports a `zx` offset', function test( t ) { 0.4, // 3 -0.6, 0.6 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -237,13 +237,13 @@ tape( 'the function supports a `zx` offset', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 3, za, zx, 2, 1, zy, 1, 0 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ -0.05, // 1 -0.6, // 1 -1.38, // 2 @@ -258,7 +258,7 @@ tape( 'the function supports a `zx` offset', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -270,7 +270,7 @@ tape( 'the function supports a `zy` stride', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -285,8 +285,8 @@ tape( 'the function supports a `zy` stride', function test( t ) { 0.4, -0.6, 0.6 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, @@ -301,13 +301,13 @@ tape( 'the function supports a `zy` stride', function test( t ) { -0.3, 0.8, // 4 -0.7 // 4 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 1, 0, zy, 2, 0 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.32, // 1 -1.41, // 1 -0.9, @@ -322,7 +322,7 @@ tape( 'the function supports a `zy` stride', function test( t ) { -0.3, 0.32, // 4 -1.16 // 4 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -334,7 +334,7 @@ tape( 'the function supports a `zy` offset', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -349,8 +349,8 @@ tape( 'the function supports a `zy` offset', function test( t ) { 0.4, -0.6, 0.6 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, -0.6, -0.9, // 1 @@ -365,13 +365,13 @@ tape( 'the function supports a `zy` offset', function test( t ) { -0.3, // 3 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 3, za, zx, 1, 0, zy, 2, 1 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.6, -0.6, -1.18, // 1 @@ -386,7 +386,7 @@ tape( 'the function supports a `zy` offset', function test( t ) { -0.59, // 3 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.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 `za` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { + var expected; + var viewY; + var za; + var zx; + var zy; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + zy = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + za = new Complex128( 0.0, 0.0 ); + + viewY = new Float64Array( zy.buffer ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + zaxpy( -1, za, zx, 1, 0, zy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + zaxpy( 0, za, zx, 1, 0, zy, 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 `zx` stride', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 4 -0.8, // 4 -0.4, @@ -452,8 +475,8 @@ tape( 'the function supports a negative `zx` stride', function test( t ) { 0.4, -0.6, // 1 0.6 // 1 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -468,13 +491,13 @@ tape( 'the function supports a negative `zx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, -2, 6, zy, 1, 0 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.78, // 1 0.06, // 1 -1.54, // 2 @@ -489,7 +512,7 @@ tape( 'the function supports a negative `zx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -501,7 +524,7 @@ tape( 'the function supports a negative `zy` stride', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -516,8 +539,8 @@ tape( 'the function supports a negative `zy` stride', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -532,13 +555,13 @@ tape( 'the function supports a negative `zy` stride', function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 2, 0, zy, -2, 6 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.78, // 4 0.06, // 4 -0.9, @@ -553,7 +576,7 @@ tape( 'the function supports a negative `zy` stride', function test( t ) { -0.3, 0.52, // 1 -1.51 // 1 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -565,7 +588,7 @@ tape( 'the function supports complex access patterns', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 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 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 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 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, -1, 3, zy, -2, 6 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 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, 14.0 ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.js b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.js index 9152693cd2fc..04a541815f42 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.js +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/test/test.zaxpy.js @@ -78,7 +78,7 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -93,8 +93,8 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy 0.4, -0.6, 0.6 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -109,13 +109,13 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy -0.3, 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 1, zy, 1 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.32, // 1 -1.41, // 1 -1.55, // 2 @@ -130,7 +130,7 @@ tape( 'the function scales elements from `zx` by `za` and adds the result to `zy -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -142,7 +142,7 @@ tape( 'the function supports a `zx` stride', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -157,8 +157,8 @@ tape( 'the function supports a `zx` stride', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -173,13 +173,13 @@ tape( 'the function supports a `zx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 2, zy, 1 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.32, // 1 -1.41, // 1 -1.57, // 2 @@ -194,7 +194,7 @@ tape( 'the function supports a `zx` stride', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -206,7 +206,7 @@ tape( 'the function supports a `zy` stride', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, // 2 @@ -221,8 +221,8 @@ tape( 'the function supports a `zy` stride', function test( t ) { 0.4, -0.6, 0.6 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, @@ -237,13 +237,13 @@ tape( 'the function supports a `zy` stride', function test( t ) { -0.3, 0.8, // 4 -0.7 // 4 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 1, zy, 2 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.32, // 1 -1.41, // 1 -0.9, @@ -258,7 +258,7 @@ tape( 'the function supports a `zy` stride', function test( t ) { -0.3, 0.32, // 4 -1.16 // 4 - ] ); + ]); isApprox( t, viewY, expected, 14.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 `za` parameter equal to `0`, the function returns the second input array unchanged', function test( t ) { + var expected; + var viewY; + var za; + var zx; + var cy; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + za = new Complex128( 0.0, 0.0 ); + + viewY = new Float64Array( cy.buffer ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + zaxpy( -1, za, zx, 1, 0, cy, 1, 0 ); + t.deepEqual( viewY, expected, 'returns expected value' ); + + zaxpy( 0, za, zx, 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 `zx` strides', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 4 -0.8, // 4 -0.4, @@ -324,8 +347,8 @@ tape( 'the function supports negative `zx` strides', function test( t ) { 0.4, -0.6, // 1 0.6 // 1 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 1 -0.6, // 1 -0.9, // 2 @@ -340,13 +363,13 @@ tape( 'the function supports negative `zx` strides', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, -2, zy, 1 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.78, // 1 0.06, // 1 -1.54, // 2 @@ -361,7 +384,7 @@ tape( 'the function supports negative `zx` strides', function test( t ) { -0.3, 0.8, -0.7 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -373,7 +396,7 @@ tape( 'the function supports negative `zy` strides', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 0.7, // 1 -0.8, // 1 -0.4, @@ -388,8 +411,8 @@ tape( 'the function supports negative `zy` strides', function test( t ) { 0.4, -0.6, // 4 0.6 // 4 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 0.6, // 4 -0.6, // 4 -0.9, @@ -404,13 +427,13 @@ tape( 'the function supports negative `zy` strides', function test( t ) { -0.3, 0.8, // 1 -0.7 // 1 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, 2, zy, -2 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 0.78, // 4 0.06, // 4 -0.9, @@ -425,7 +448,7 @@ tape( 'the function supports negative `zy` strides', function test( t ) { -0.3, 0.52, // 1 -1.51 // 1 - ] ); + ]); isApprox( t, viewY, expected, 14.0 ); t.end(); }); @@ -437,7 +460,7 @@ tape( 'the function supports complex access patterns', function test( t ) { var zx; var zy; - zx = new Complex128Array( [ + zx = new Complex128Array([ 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 - ] ); - zy = new Complex128Array( [ + ]); + zy = new Complex128Array([ 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 - ] ); + ]); za = new Complex128( 0.4, -0.7 ); zaxpy( 4, za, zx, -1, zy, -2 ); viewY = new Float64Array( zy.buffer ); - expected = new Float64Array( [ + expected = new Float64Array([ 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, 14.0 ); t.end(); });