diff --git a/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.js b/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.js index 14021e95a056..9265dc8bcf7a 100644 --- a/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.js @@ -21,10 +21,9 @@ // MODULES // var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var hyp2f1 = require( './../lib' ); @@ -111,8 +110,6 @@ tape( 'the function returns `PINF` when `c <= a + b`, `x === 1`, and neither `a` tape( 'the function correctly evaluates the hypergeometric function', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -132,17 +129,13 @@ tape( 'the function correctly evaluates the hypergeometric function', function t t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -162,17 +155,13 @@ tape( 'the function correctly evaluates the hypergeometric function', function t t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -192,17 +181,13 @@ tape( 'the function correctly evaluates the hypergeometric function', function t t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - tol = 7.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 7 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -222,17 +207,13 @@ tape( 'the function correctly evaluates the hypergeometric function', function t t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - tol = 10.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 18 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -252,17 +233,13 @@ tape( 'the function correctly evaluates the hypergeometric function', function t t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - tol = 17.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 33 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -278,7 +255,6 @@ tape( 'the function correctly evaluates the hypergeometric function', function t for ( i = 0; i < x.length; i++ ) { v = hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] ); - delta = abs( v - expected[ i ] ); /* * NOTE: the tolerance is set high in this case due to: @@ -286,8 +262,7 @@ tape( 'the function correctly evaluates the hypergeometric function', function t * 1. The expected values having a very large range, being either very small or very large. * 2. The function making a large number of internal calls, leading to accumulated numerical errors. */ - tol = 260000.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 294333 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.native.js index 55b8b9e2ab9d..eff8f30c8372 100644 --- a/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.native.js @@ -22,10 +22,9 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -123,8 +122,6 @@ tape( 'the function returns `PINF` when `c <= a + b`, `x === 1`, and neither `a` tape( 'the function correctly evaluates the hypergeometric function', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -144,17 +141,13 @@ tape( 'the function correctly evaluates the hypergeometric function', opts, func t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -174,19 +167,13 @@ tape( 'the function correctly evaluates the hypergeometric function', opts, func t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = 1.2 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -206,19 +193,13 @@ tape( 'the function correctly evaluates the hypergeometric function', opts, func t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = 24.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 7 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -238,19 +219,13 @@ tape( 'the function correctly evaluates the hypergeometric function', opts, func t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = 32.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 18 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -270,19 +245,13 @@ tape( 'the function correctly evaluates the hypergeometric function', opts, func t.strictEqual( v, PINF, 'returns expected value' ); continue; } - delta = abs( v - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = 84.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 33 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function correctly evaluates the hypergeometric function', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -298,11 +267,7 @@ tape( 'the function correctly evaluates the hypergeometric function', opts, func for ( i = 0; i < x.length; i++ ) { v = hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] ); - delta = abs( v - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = 345877.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: ' + a[ i ] + ' b: ' + b[ i ] + ' c: ' + c[ i ] + ' x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Delta: ' + delta + '. Tolerance: ' + tol + '.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 294333 ), true, 'returns expected value' ); } t.end(); });