Skip to content
Open
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
40 changes: 21 additions & 19 deletions lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var tape = require( 'tape' );
var Complex64Array = require( '@stdlib/array/complex64' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var scasum = require( './../lib/ndarray.js' );


Expand All @@ -36,19 +35,10 @@ var scasum = require( './../lib/ndarray.js' );
* @param {Object} t - test object
* @param {number} actual - actual value
* @param {number} expected - expected value
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;

if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value' );
} else {
delta = abs( actual - expected );
tol = rtol * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
}
function isApprox( t, actual, expected, ulp ) {
t.strictEqual( isAlmostSameValuef( actual, expected, ulp ), true, 'returns expected value' );
}


Expand All @@ -68,8 +58,11 @@ tape( 'the function has an arity of 4', function test( t ) {
tape( 'the function computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector', function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 1
0.1, // 1
Expand All @@ -85,7 +78,7 @@ tape( 'the function computes the sum of the absolute values of the real and imag
expected = 1.6;

actual = scasum( 4, x, 1, 0 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );

x = new Complex64Array([
0.1, // 1
Expand All @@ -100,7 +93,7 @@ tape( 'the function computes the sum of the absolute values of the real and imag
expected = 1.3;

actual = scasum( 3, x, 1, 0 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

Expand Down Expand Up @@ -137,8 +130,11 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
tape( 'the function supports specifying a stride', function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 1
0.1, // 1
Expand All @@ -160,15 +156,18 @@ tape( 'the function supports specifying a stride', function test( t ) {
expected = 1.6;

actual = scasum( 4, x, 2, 0 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

tape( 'the function supports specifying a negative stride', function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 4
0.1, // 4
Expand All @@ -190,7 +189,7 @@ tape( 'the function supports specifying a negative stride', function test( t ) {
expected = 28.9;

actual = scasum( 4, x, -1, 3 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

Expand Down Expand Up @@ -221,8 +220,11 @@ tape( 'the function supports specifying an offset', function test( t ) {
tape( 'the function supports specifying complex access patterns', function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 4
0.1, // 4
Expand All @@ -244,6 +246,6 @@ tape( 'the function supports specifying complex access patterns', function test(
expected = 1.6;

actual = scasum( 4, x, -2, 6 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var Complex64Array = require( '@stdlib/array/complex64' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand All @@ -45,19 +44,10 @@ var opts = {
* @param {Object} t - test object
* @param {number} actual - actual value
* @param {number} expected - expected value
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;

if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value' );
} else {
delta = abs( actual - expected );
tol = rtol * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
}
function isApprox( t, actual, expected, ulp ) {
t.strictEqual( isAlmostSameValuef( actual, expected, ulp ), true, 'returns expected value' );
}


Expand All @@ -77,8 +67,11 @@ tape( 'the function has an arity of 4', opts, function test( t ) {
tape( 'the function computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector', opts, function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 1
0.1, // 1
Expand All @@ -94,7 +87,7 @@ tape( 'the function computes the sum of the absolute values of the real and imag
expected = 1.6;

actual = scasum( 4, x, 1, 0 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );

x = new Complex64Array([
0.1, // 1
Expand All @@ -109,7 +102,7 @@ tape( 'the function computes the sum of the absolute values of the real and imag
expected = 1.3;

actual = scasum( 3, x, 1, 0 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

Expand Down Expand Up @@ -146,8 +139,11 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
tape( 'the function supports specifying a stride', opts, function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 1
0.1, // 1
Expand All @@ -169,15 +165,18 @@ tape( 'the function supports specifying a stride', opts, function test( t ) {
expected = 1.6;

actual = scasum( 4, x, 2, 0 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

tape( 'the function supports specifying a negative stride', opts, function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 4
0.1, // 4
Expand All @@ -199,7 +198,7 @@ tape( 'the function supports specifying a negative stride', opts, function test(
expected = 28.9;

actual = scasum( 4, x, -1, 3 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

Expand Down Expand Up @@ -230,8 +229,11 @@ tape( 'the function supports specifying an offset', opts, function test( t ) {
tape( 'the function supports specifying complex access patterns', opts, function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 4
0.1, // 4
Expand All @@ -253,6 +255,6 @@ tape( 'the function supports specifying complex access patterns', opts, function
expected = 1.6;

actual = scasum( 4, x, -2, 6 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});
35 changes: 17 additions & 18 deletions lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var tape = require( 'tape' );
var Complex64Array = require( '@stdlib/array/complex64' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var scasum = require( './../lib/scasum.js' );


Expand All @@ -36,19 +35,10 @@ var scasum = require( './../lib/scasum.js' );
* @param {Object} t - test object
* @param {number} actual - actual value
* @param {number} expected - expected value
* @param {number} rtol - relative tolerance
* @param {NonNegativeInteger} ulp - maximum allowed ULP difference
*/
function isApprox( t, actual, expected, rtol ) {
var delta;
var tol;

if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value' );
} else {
delta = abs( actual - expected );
tol = rtol * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
}
function isApprox( t, actual, expected, ulp ) {
t.strictEqual( isAlmostSameValuef( actual, expected, ulp ), true, 'returns expected value' );
}


Expand All @@ -68,8 +58,11 @@ tape( 'the function has an arity of 3', function test( t ) {
tape( 'the function computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector', function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 1
0.1, // 1
Expand All @@ -85,7 +78,7 @@ tape( 'the function computes the sum of the absolute values of the real and imag
expected = 1.6;

actual = scasum( 4, x, 1 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );

x = new Complex64Array([
0.1, // 1
Expand All @@ -100,7 +93,7 @@ tape( 'the function computes the sum of the absolute values of the real and imag
expected = 1.3;

actual = scasum( 3, x, 1 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

Expand Down Expand Up @@ -137,8 +130,11 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
tape( 'the function supports specifying a stride', function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 1
0.1, // 1
Expand All @@ -160,15 +156,18 @@ tape( 'the function supports specifying a stride', function test( t ) {
expected = 1.6;

actual = scasum( 4, x, 2 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

tape( 'the function supports specifying a negative stride', function test( t ) {
var expected;
var actual;
var ULP;
var x;

ULP = 1;

x = new Complex64Array([
0.3, // 4
0.1, // 4
Expand All @@ -182,7 +181,7 @@ tape( 'the function supports specifying a negative stride', function test( t ) {
expected = 28.9;

actual = scasum( 4, x, -1 );
isApprox( t, actual, expected, 2.0 );
isApprox( t, actual, expected, ULP );
t.end();
});

Expand Down
Loading
Loading