diff --git a/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.js index 6f34f4c3fce4..82d5be077ebc 100644 --- a/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.js @@ -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' ); @@ -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' ); } @@ -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 @@ -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 @@ -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(); }); @@ -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 @@ -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 @@ -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(); }); @@ -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 @@ -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(); }); diff --git a/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.native.js index 1196f4be567d..d860ec43aeb9 100644 --- a/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/scasum/test/test.ndarray.native.js @@ -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' ); @@ -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' ); } @@ -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 @@ -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 @@ -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(); }); @@ -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 @@ -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 @@ -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(); }); @@ -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 @@ -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(); }); diff --git a/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.js b/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.js index 4a534573d18e..63777032dec0 100644 --- a/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.js +++ b/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.js @@ -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' ); @@ -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' ); } @@ -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 @@ -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 @@ -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(); }); @@ -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 @@ -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 @@ -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(); }); diff --git a/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.native.js b/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.native.js index 4185bfb1b6ee..bdca8399ccff 100644 --- a/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.native.js +++ b/lib/node_modules/@stdlib/blas/base/scasum/test/test.scasum.native.js @@ -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' ); @@ -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' ); } @@ -77,8 +67,11 @@ tape( 'the function has an arity of 3', 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 @@ -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 ); - isApprox( t, actual, expected, 2.0 ); + isApprox( t, actual, expected, ULP ); x = new Complex64Array([ 0.1, // 1 @@ -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 ); - isApprox( t, actual, expected, 2.0 ); + isApprox( t, actual, expected, ULP ); t.end(); }); @@ -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 @@ -169,15 +165,18 @@ tape( 'the function supports specifying a stride', opts, 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', opts, function test( t ) { var expected; var actual; + var ULP; var x; + ULP = 1; + x = new Complex64Array([ 0.3, // 4 0.1, // 4 @@ -191,7 +190,7 @@ tape( 'the function supports specifying a negative stride', opts, function test( expected = 28.9; actual = scasum( 4, x, -1 ); - isApprox( t, actual, expected, 2.0 ); + isApprox( t, actual, expected, ULP ); t.end(); });