diff --git a/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.js b/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.js index 698eccfedda2..37a2d16e57de 100644 --- a/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.js @@ -21,12 +21,11 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var HALF_PI = require( '@stdlib/constants/float64/half-pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var ellipk = require( './../lib' ); @@ -48,92 +47,64 @@ tape( 'main export is a function', function test( t ) { tape( 'the function evaluates the complete elliptic integral of the first kind (medium positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = mediumPositive.expected; x = mediumPositive.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 25.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 25 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the complete elliptic integral of the first kind (values close to positive unity)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = closeToUnity.expected; x = closeToUnity.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 8000.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 12065 ), true, 'returns expected value' ); // FIXME: investigate the reason for this large discrepancy } t.end(); }); tape( 'the function evaluates the complete elliptic integral of the first kind (medium negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = mediumNegative.expected; x = mediumNegative.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.5 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the complete elliptic integral of the first kind (large negative values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = largeNegative.expected; x = largeNegative.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1e9 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 204773163 ), true, 'returns expected value' ); // FIXME: investigate the reason for this large discrepancy } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.native.js index 6d0e208696f8..de505efb136c 100644 --- a/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ellipk/test/test.native.js @@ -22,12 +22,11 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var HALF_PI = require( '@stdlib/constants/float64/half-pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -57,92 +56,64 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function evaluates the complete elliptic integral of the first kind (medium positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = mediumPositive.expected; x = mediumPositive.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 25.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 25 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the complete elliptic integral of the first kind (values close to positive unity)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = closeToUnity.expected; x = closeToUnity.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 8000.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 12065 ), true, 'returns expected value' ); // FIXME: investigate the reason for this large discrepancy } t.end(); }); tape( 'the function evaluates the complete elliptic integral of the first kind (medium negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = mediumNegative.expected; x = mediumNegative.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.5 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the complete elliptic integral of the first kind (large negative values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; expected = largeNegative.expected; x = largeNegative.x; + for ( i = 0; i < x.length; i++ ) { y = ellipk( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1e9 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 204773163 ), true, 'returns expected value' ); // FIXME: investigate the reason for this large discrepancy } t.end(); });