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
39 changes: 7 additions & 32 deletions lib/node_modules/@stdlib/math/base/special/hyp2f1/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );


Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -278,16 +255,14 @@ 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:
*
* 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();
});
Original file line number Diff line number Diff line change
Expand Up @@ -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' );


Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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();
});