Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 96 additions & 8 deletions lib/node_modules/@stdlib/blas/ext/base/ndarray/zxsa/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,18 @@ tape( 'the function subtracts a scalar constant from each element', function tes
var xbuf;
var x;

xbuf = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0, 2.0, 1.0 ] );
xbuf = new Complex128Array([
-2.0, // 0
1.0, // 0
3.0, // 1
-5.0, // 1
4.0, // 2
0.0, // 2
-1.0, // 3
-3.0, // 3
2.0, // 4
1.0 // 4
]);
x = vector( xbuf, 5, 1, 0 );
alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), {
'dtype': 'complex128'
Expand All @@ -69,7 +80,18 @@ tape( 'the function subtracts a scalar constant from each element', function tes
actual = zxsa( [ x, alpha ] );
t.strictEqual( actual, x, 'returns expected value' );

expected = new Complex128Array( [ -7.0, 1.0, -2.0, -5.0, -1.0, 0.0, -6.0, -3.0, -3.0, 1.0 ] );
expected = new Complex128Array([
-7.0, // 0
1.0, // 0
-2.0, // 1
-5.0, // 1
-1.0, // 2
0.0, // 2
-6.0, // 3
-3.0, // 3
-3.0, // 4
1.0 // 4
]);
t.deepEqual( xbuf, expected, 'returns expected value' );

t.end();
Expand All @@ -82,7 +104,16 @@ tape( 'the function supports an input ndarray having a non-unit stride', functio
var xbuf;
var x;

xbuf = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
xbuf = new Complex128Array([
-2.0, // 0
1.0, // 0
0.0,
0.0,
4.0, // 1
0.0, // 1
0.0,
0.0
]);
x = vector( xbuf, 2, 2, 0 );
alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), {
'dtype': 'complex128'
Expand All @@ -91,7 +122,16 @@ tape( 'the function supports an input ndarray having a non-unit stride', functio
actual = zxsa( [ x, alpha ] );
t.strictEqual( actual, x, 'returns expected value' );

expected = new Complex128Array( [ -7.0, 1.0, 3.0, -5.0, -1.0, 0.0, -1.0, -3.0 ] );
expected = new Complex128Array([
-7.0, // 0
1.0, // 0
0.0,
0.0,
-1.0, // 1
0.0, // 1
0.0,
0.0
]);
t.deepEqual( xbuf, expected, 'returns expected value' );

t.end();
Expand All @@ -104,7 +144,18 @@ tape( 'the function supports an input ndarray having a negative stride', functio
var xbuf;
var x;

xbuf = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0, 2.0, 1.0 ] );
xbuf = new Complex128Array([
-2.0, // 4
1.0, // 4
3.0, // 3
-5.0, // 3
4.0, // 2
0.0, // 2
-1.0, // 1
-3.0, // 1
2.0, // 0
1.0 // 0
]);
x = vector( xbuf, 5, -1, 4 );
alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), {
'dtype': 'complex128'
Expand All @@ -113,7 +164,18 @@ tape( 'the function supports an input ndarray having a negative stride', functio
actual = zxsa( [ x, alpha ] );
t.strictEqual( actual, x, 'returns expected value' );

expected = new Complex128Array( [ -7.0, 1.0, -2.0, -5.0, -1.0, 0.0, -6.0, -3.0, -3.0, 1.0 ] );
expected = new Complex128Array([
-7.0, // 4
1.0, // 4
-2.0, // 3
-5.0, // 3
-1.0, // 2
0.0, // 2
-6.0, // 1
-3.0, // 1
-3.0, // 0
1.0 // 0
]);
t.deepEqual( xbuf, expected, 'returns expected value' );

t.end();
Expand All @@ -126,7 +188,20 @@ tape( 'the function supports an input ndarray having a non-zero offset', functio
var xbuf;
var x;

xbuf = new Complex128Array( [ 1.0, 0.0, -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0, 2.0, 1.0 ] );
xbuf = new Complex128Array([
0.0,
0.0,
0.0,
0.0,
3.0, // 0
-5.0, // 0
4.0, // 1
0.0, // 1
-1.0, // 2
-3.0, // 2
0.0,
0.0
]);
x = vector( xbuf, 3, 1, 2 );
alpha = scalar2ndarray( new Complex128( 5.0, 0.0 ), {
'dtype': 'complex128'
Expand All @@ -135,7 +210,20 @@ tape( 'the function supports an input ndarray having a non-zero offset', functio
actual = zxsa( [ x, alpha ] );
t.strictEqual( actual, x, 'returns expected value' );

expected = new Complex128Array( [ 1.0, 0.0, -2.0, 1.0, -2.0, -5.0, -1.0, 0.0, -6.0, -3.0, 2.0, 1.0 ] );
expected = new Complex128Array([
0.0,
0.0,
0.0,
0.0,
-2.0, // 0
-5.0, // 0
-1.0, // 1
0.0, // 1
-6.0, // 2
-3.0, // 2
0.0,
0.0
]);
t.deepEqual( xbuf, expected, 'returns expected value' );

t.end();
Expand Down