From d8b6e5a1d6841b05d1af0dfc627be38bb25f9cf1 Mon Sep 17 00:00:00 2001 From: Aman Bhansali <92033532+aman-095@users.noreply.github.com> Date: Wed, 26 Jun 2024 01:32:13 +0530 Subject: [PATCH] test: add test cases to `blas/base/drotm` PR-URL: https://github.com/stdlib-js/stdlib/pull/2454 Reviewed-by: Athan Reines --- .../blas/base/drotm/test/test.drotm.js | 376 +++++++++++++++--- .../blas/base/drotm/test/test.drotm.native.js | 376 +++++++++++++++--- .../blas/base/drotm/test/test.ndarray.js | 356 ++++++++++++++--- .../base/drotm/test/test.ndarray.native.js | 356 ++++++++++++++--- 4 files changed, 1240 insertions(+), 224 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.js b/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.js index 24b0d69977a..77c674e0926 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.js +++ b/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.js @@ -238,6 +238,88 @@ tape( 'the function applies a plane rotation (sx=-1, sy=-2)', function test( t ) t.end(); }); +tape( 'the function applies a plane rotation', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 2, y, 2, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + -24.0, // 1 + 4.0, + -30.0 // 2 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 6.0, // 1 + 9.0, + 10.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + + drotm( 2, x, 3, y, 3, param ); + + xe = new Float64Array( [ + 6.0, // 0 + 2.0, + 3.0, + 9.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + -1.0, // 0 + 7.0, + 8.0, + -4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + tape( 'the function supports an `x` stride', function test( t ) { var param; var xe; @@ -278,6 +360,124 @@ tape( 'the function supports an `x` stride', function test( t ) { 10.0 ] ); + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 3, y, 1, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + 3.0, + -21.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 8.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, -2, y, 1, param ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, // 2 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, -2, y, 1, param ); + + xe = new Float64Array( [ + 8.0, // 2 + 2.0, + 7.0, // 1 + 4.0, + 6.0 // 0 + ] ); + ye = new Float64Array( [ + -5.0, // 0 + -3.0, // 1 + -1.0, // 2 + 9.0, + 10.0 + ] ); + isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); @@ -324,8 +524,126 @@ tape( 'the function supports a `y` stride', function test( t ) { 16.0 // 2 ] ); - t.deepEqual( x, xe, 'returns expected value' ); - t.deepEqual( y, ye, 'returns expected value' ); + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, y, 3, param ); + + xe = new Float64Array( [ + -18.0, // 0 + -27.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 8.0, + 4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, y, -2, param ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 2 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 1, y, -2, param ); + + xe = new Float64Array( [ + -30.0, // 0 + -24.0, // 1 + -18.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 2 + 7.0, + 4.0, // 1 + 9.0, + 2.0 // 0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); t.end(); }); @@ -374,60 +692,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function leav t.end(); }); -tape( 'the function supports negative strides', function test( t ) { - var param; - var xe; - var ye; - var x; - var y; - - x = new Float64Array([ - 0.6, // 1 - 0.1, - -0.5, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ]); - y = new Float64Array([ - 0.5, // 0 - -0.9, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ]); - param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); - - drotm( 2, x, -2, y, 1, param ); - - xe = new Float64Array( [ - 3.3, // 1 - 0.1, - -2.0, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ] ); - ye = new Float64Array( [ - -0.5, // 0 - 0.3, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ] ); - - isApprox( t, x, xe, 10.0 ); - isApprox( t, y, ye, 10.0 ); - - t.end(); -}); - tape( 'the function supports complex access patterns', function test( t ) { var param; var xe; diff --git a/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.native.js b/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.native.js index 86cf7539503..b4871f95687 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.native.js +++ b/lib/node_modules/@stdlib/blas/base/drotm/test/test.drotm.native.js @@ -251,6 +251,88 @@ tape( 'the function applies a plane rotation (sx=-1, sy=-2)', opts, function tes t.end(); }); +tape( 'the function applies a plane rotation', opts, function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 2, y, 2, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + -24.0, // 1 + 4.0, + -30.0 // 2 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 6.0, // 1 + 9.0, + 10.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + + drotm( 2, x, 3, y, 3, param ); + + xe = new Float64Array( [ + 6.0, // 0 + 2.0, + 3.0, + 9.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + -1.0, // 0 + 7.0, + 8.0, + -4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + tape( 'the function supports an `x` stride', opts, function test( t ) { var param; var xe; @@ -294,6 +376,124 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 3, y, 1, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + 3.0, + -21.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 8.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, -2, y, 1, param ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, // 2 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, -2, y, 1, param ); + + xe = new Float64Array( [ + 8.0, // 2 + 2.0, + 7.0, // 1 + 4.0, + 6.0 // 0 + ] ); + ye = new Float64Array( [ + -5.0, // 0 + -3.0, // 1 + -1.0, // 2 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + t.end(); }); @@ -337,8 +537,126 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 16.0 // 2 ] ); - t.deepEqual( x, xe, 'returns expected value' ); - t.deepEqual( y, ye, 'returns expected value' ); + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, y, 3, param ); + + xe = new Float64Array( [ + -18.0, // 0 + -27.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 8.0, + 4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, y, -2, param ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 2 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 1, y, -2, param ); + + xe = new Float64Array( [ + -30.0, // 0 + -24.0, // 1 + -18.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 2 + 7.0, + 4.0, // 1 + 9.0, + 2.0 // 0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); t.end(); }); @@ -387,60 +705,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function leav t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { - var param; - var xe; - var ye; - var x; - var y; - - x = new Float64Array([ - 0.6, // 1 - 0.1, - -0.5, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ]); - y = new Float64Array([ - 0.5, // 0 - -0.9, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ]); - param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); - - drotm( 2, x, -2, y, 1, param ); - - xe = new Float64Array( [ - 3.3, // 1 - 0.1, - -2.0, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ] ); - ye = new Float64Array( [ - -0.5, // 0 - 0.3, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ] ); - - isApprox( t, x, xe, 10.0 ); - isApprox( t, y, ye, 10.0 ); - - t.end(); -}); - tape( 'the function supports complex access patterns', opts, function test( t ) { var param; var xe; diff --git a/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.js index 5bb2b80f7d3..5118337d462 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.js @@ -262,6 +262,88 @@ tape( 'the function applies a plane rotation (sx=-1, sy=-2)', function test( t ) t.end(); }); +tape( 'the function applies a plane rotation', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 2, 0, y, 2, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + -24.0, // 1 + 4.0, + -30.0 // 2 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 6.0, // 1 + 9.0, + 10.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + + drotm( 2, x, 3, 0, y, 3, 0, param ); + + xe = new Float64Array( [ + 6.0, // 0 + 2.0, + 3.0, + 9.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + -1.0, // 0 + 7.0, + 8.0, + -4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + tape( 'the function supports an `x` stride', function test( t ) { var param; var xe; @@ -306,6 +388,42 @@ tape( 'the function supports an `x` stride', function test( t ) { isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 3, 0, y, 1, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + 3.0, + -21.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 8.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + t.end(); }); @@ -341,6 +459,78 @@ tape( 'the function supports an `x` offset', function test( t ) { isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); + x = new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, -2, 2, y, 1, 0, param ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, // 2 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, -2, 4, y, 1, 0, param ); + + xe = new Float64Array( [ + 8.0, // 2 + 2.0, + 7.0, // 1 + 4.0, + 6.0 // 0 + ] ); + ye = new Float64Array( [ + -5.0, // 0 + -3.0, // 1 + -1.0, // 2 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + t.end(); }); @@ -384,8 +574,44 @@ tape( 'the function supports a `y` stride', function test( t ) { 16.0 // 2 ] ); - t.deepEqual( x, xe, 'returns expected value' ); - t.deepEqual( y, ye, 'returns expected value' ); + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, 0, y, 3, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + -27.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 8.0, + 4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); t.end(); }); @@ -422,6 +648,78 @@ tape( 'the function supports a `y` offset', function test( t ) { isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, 0, y, -2, 2, param ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 2 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 1, 0, y, -2, 4, param ); + + xe = new Float64Array( [ + -30.0, // 0 + -24.0, // 1 + -18.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 2 + 7.0, + 4.0, // 1 + 9.0, + 2.0 // 0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + t.end(); }); @@ -469,60 +767,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function leav t.end(); }); -tape( 'the function supports negative strides', function test( t ) { - var param; - var xe; - var ye; - var x; - var y; - - x = new Float64Array([ - 0.6, // 1 - 0.1, - -0.5, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ]); - y = new Float64Array([ - 0.5, // 0 - -0.9, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ]); - param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); - - drotm( 2, x, -2, 2, y, 1, 0, param ); - - xe = new Float64Array( [ - 3.3, // 1 - 0.1, - -2.0, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ] ); - ye = new Float64Array( [ - -0.5, // 0 - 0.3, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ] ); - - isApprox( t, x, xe, 10.0 ); - isApprox( t, y, ye, 10.0 ); - - t.end(); -}); - tape( 'the function supports complex access patterns', function test( t ) { var param; var xe; diff --git a/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.native.js index 72e01f12b01..d07c649ba1d 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/drotm/test/test.ndarray.native.js @@ -271,6 +271,88 @@ tape( 'the function applies a plane rotation (sx=-1, sy=-2)', opts, function tes t.end(); }); +tape( 'the function applies a plane rotation', opts, function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 2, 0, y, 2, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + -24.0, // 1 + 4.0, + -30.0 // 2 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 6.0, // 1 + 9.0, + 10.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + + drotm( 2, x, 3, 0, y, 3, 0, param ); + + xe = new Float64Array( [ + 6.0, // 0 + 2.0, + 3.0, + 9.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + -1.0, // 0 + 7.0, + 8.0, + -4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + tape( 'the function supports an `x` stride', opts, function test( t ) { var param; var xe; @@ -315,6 +397,42 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 3, 0, y, 1, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + 3.0, + -21.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 8.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + t.end(); }); @@ -350,6 +468,78 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); + x = new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, -2, 2, y, 1, 0, param ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, // 2 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, -2, 4, y, 1, 0, param ); + + xe = new Float64Array( [ + 8.0, // 2 + 2.0, + 7.0, // 1 + 4.0, + 6.0 // 0 + ] ); + ye = new Float64Array( [ + -5.0, // 0 + -3.0, // 1 + -1.0, // 2 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + t.end(); }); @@ -393,8 +583,44 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 16.0 // 2 ] ); - t.deepEqual( x, xe, 'returns expected value' ); - t.deepEqual( y, ye, 'returns expected value' ); + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, 0, y, 3, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + -27.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 8.0, + 4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); t.end(); }); @@ -431,6 +657,78 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { isApprox( t, x, xe, 2.0 ); isApprox( t, y, ye, 2.0 ); + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 2, x, 1, 0, y, -2, 2, param ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 2 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm( 3, x, 1, 0, y, -2, 4, param ); + + xe = new Float64Array( [ + -30.0, // 0 + -24.0, // 1 + -18.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 2 + 7.0, + 4.0, // 1 + 9.0, + 2.0 // 0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + t.end(); }); @@ -478,60 +776,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function leav t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { - var param; - var xe; - var ye; - var x; - var y; - - x = new Float64Array([ - 0.6, // 1 - 0.1, - -0.5, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ]); - y = new Float64Array([ - 0.5, // 0 - -0.9, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ]); - param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); - - drotm( 2, x, -2, 2, y, 1, 0, param ); - - xe = new Float64Array( [ - 3.3, // 1 - 0.1, - -2.0, // 0 - 0.8, - 0.9, - -0.3, - -0.4 - ] ); - ye = new Float64Array( [ - -0.5, // 0 - 0.3, // 1 - 0.3, - 0.7, - -0.6, - 0.2, - 0.8 - ] ); - - isApprox( t, x, xe, 10.0 ); - isApprox( t, y, ye, 10.0 ); - - t.end(); -}); - tape( 'the function supports complex access patterns', opts, function test( t ) { var param; var xe;