Skip to content
Draft
Show file tree
Hide file tree
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
49 changes: 28 additions & 21 deletions lib/node_modules/@stdlib/blas/base/zaxpy/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ var tape = require( 'tape' );
var Float64Array = require( '@stdlib/array/float64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var EPS = require( '@stdlib/constants/float64/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var zaxpy = require( './../lib/ndarray.js' );


Expand All @@ -38,22 +37,14 @@ var zaxpy = require( './../lib/ndarray.js' );
* @param {Object} t - test object
* @param {Collection} actual - actual values
* @param {Collection} expected - expected values
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;
function isApprox( t, actual, expected, ulp ) {
var i;

t.strictEqual( actual.length, expected.length, 'returns expected value' );
for ( i = 0; i < expected.length; i++ ) {
if ( actual[ i ] === expected[ i ] ) {
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
} else {
delta = abs( actual[ i ] - expected[ i ] );
tol = rtol * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand All @@ -75,6 +66,7 @@ tape( 'the function scales elements from `x` by `alpha` and adds the result to `
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -131,14 +123,16 @@ tape( 'the function scales elements from `x` by `alpha` and adds the result to `
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 24;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports an `x` stride', function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -195,14 +189,16 @@ tape( 'the function supports an `x` stride', function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 8;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports an `x` offset', function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -259,14 +255,16 @@ tape( 'the function supports an `x` offset', function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 11;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports a `y` stride', function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -323,14 +321,16 @@ tape( 'the function supports a `y` stride', function test( t ) {
0.32, // 4
-1.16 // 4
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 6;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports a `y` offset', function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -387,7 +387,8 @@ tape( 'the function supports a `y` offset', function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 1;
isApprox( t, viewY, expected, ULP );
t.end();
});

Expand Down Expand Up @@ -457,6 +458,7 @@ tape( 'the function supports a negative `x` stride', function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -513,14 +515,16 @@ tape( 'the function supports a negative `x` stride', function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 24;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports a negative `y` stride', function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -577,14 +581,16 @@ tape( 'the function supports a negative `y` stride', function test( t ) {
0.52, // 1
-1.51 // 1
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 8;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports complex access patterns', function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -641,6 +647,7 @@ tape( 'the function supports complex access patterns', function test( t ) {
0.32, // 1
-1.16 // 1
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 6;
isApprox( t, viewY, expected, ULP );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ var tape = require( 'tape' );
var Float64Array = require( '@stdlib/array/float64' );
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var EPS = require( '@stdlib/constants/float64/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand All @@ -47,22 +46,14 @@ var opts = {
* @param {Object} t - test object
* @param {Collection} actual - actual values
* @param {Collection} expected - expected values
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;
function isApprox( t, actual, expected, ulp ) {
var i;

t.strictEqual( actual.length, expected.length, 'returns expected value' );
for ( i = 0; i < expected.length; i++ ) {
if ( actual[ i ] === expected[ i ] ) {
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
} else {
delta = abs( actual[ i ] - expected[ i ] );
tol = rtol * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], ulp ), true, 'returns expected value' );
}
}

Expand All @@ -84,6 +75,7 @@ tape( 'the function scales elements from `x` by `alpha` and adds the result to `
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -140,14 +132,16 @@ tape( 'the function scales elements from `x` by `alpha` and adds the result to `
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 24;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'if dcabs1( alpha ) === 0.0; the function returns the second input array unchanged', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -204,14 +198,16 @@ tape( 'if dcabs1( alpha ) === 0.0; the function returns the second input array u
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 0;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports an `x` stride', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -268,14 +264,16 @@ tape( 'the function supports an `x` stride', opts, function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 8;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports an `x` offset', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -332,14 +330,16 @@ tape( 'the function supports an `x` offset', opts, function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 11;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports a `y` stride', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -396,14 +396,16 @@ tape( 'the function supports a `y` stride', opts, function test( t ) {
0.32, // 4
-1.16 // 4
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 6;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports a `y` offset', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -460,7 +462,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 1;
isApprox( t, viewY, expected, ULP );
t.end();
});

Expand Down Expand Up @@ -507,6 +510,7 @@ tape( 'the function supports a negative `x` stride', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -563,14 +567,16 @@ tape( 'the function supports a negative `x` stride', opts, function test( t ) {
0.8,
-0.7
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 24;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports a negative `y` stride', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -627,14 +633,16 @@ tape( 'the function supports a negative `y` stride', opts, function test( t ) {
0.52, // 1
-1.51 // 1
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 8;
isApprox( t, viewY, expected, ULP );
t.end();
});

tape( 'the function supports complex access patterns', opts, function test( t ) {
var expected;
var viewY;
var alpha;
var ULP;
var x;
var y;

Expand Down Expand Up @@ -691,6 +699,7 @@ tape( 'the function supports complex access patterns', opts, function test( t )
0.32, // 1
-1.16 // 1
]);
isApprox( t, viewY, expected, 14.0 );
ULP = 6;
isApprox( t, viewY, expected, ULP );
t.end();
});
Loading
Loading