Skip to content
Merged
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var tape = require( 'tape' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var EPS = require( '@stdlib/constants/float64/eps' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var gammaDeltaRatio = require( './../lib' );


Expand Down Expand Up @@ -74,9 +73,7 @@ tape( 'the function returns `0` for very large `z` and negligible `delta`', func

tape( 'the function evaluates the ratio of two gamma functions (decimals)', function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -86,18 +83,14 @@ tape( 'the function evaluates the ratio of two gamma functions (decimals)', func
expected = decimals.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 337.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 728 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (small integers)', function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -107,18 +100,14 @@ tape( 'the function evaluates the ratio of two gamma functions (small integers)'
expected = smallIntegers.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 1.1 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (large integers)', function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -128,18 +117,14 @@ tape( 'the function evaluates the ratio of two gamma functions (large integers)'
expected = largeIntegers.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 129.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 409 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (non-integer `z`, integer `delta`)', function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -149,18 +134,14 @@ tape( 'the function evaluates the ratio of two gamma functions (non-integer `z`,
expected = decimalsIntegers.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 129.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 40 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (tiny `z`, large `delta`)', function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -170,23 +151,14 @@ tape( 'the function evaluates the ratio of two gamma functions (tiny `z`, large
expected = tinyLarge.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 3.3 * EPS * abs( expected[ i ] );

// Handle cases where either the expected value is zero or `v` is zero and the expected value is very small...
if ( tol < 1.0e-300 ) {
tol = 1.0e-300;
}
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 8 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (large `z`, tiny `delta`)', function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -196,9 +168,7 @@ tape( 'the function evaluates the ratio of two gamma functions (large `z`, tiny
expected = largeTiny.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var EPS = require( '@stdlib/constants/float64/eps' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -83,9 +82,7 @@ tape( 'the function returns `0` for very large `z` and negligible `delta`', opts

tape( 'the function evaluates the ratio of two gamma functions (decimals)', opts, function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -95,18 +92,14 @@ tape( 'the function evaluates the ratio of two gamma functions (decimals)', opts
expected = decimals.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 337.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 728 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (small integers)', opts, function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -116,18 +109,14 @@ tape( 'the function evaluates the ratio of two gamma functions (small integers)'
expected = smallIntegers.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 1.1 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (large integers)', opts, function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -137,18 +126,14 @@ tape( 'the function evaluates the ratio of two gamma functions (large integers)'
expected = largeIntegers.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 129.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 409 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (non-integer `z`, integer `delta`)', opts, function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -158,18 +143,16 @@ tape( 'the function evaluates the ratio of two gamma functions (non-integer `z`,
expected = decimalsIntegers.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 129.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );

// 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
t.strictEqual( isAlmostSameValue( v, expected[ i ], 41 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (tiny `z`, large `delta`)', opts, function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -179,23 +162,14 @@ tape( 'the function evaluates the ratio of two gamma functions (tiny `z`, large
expected = tinyLarge.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 3.3 * EPS * abs( expected[ i ] );

// Handle cases where either the expected value is zero or `v` is zero and the expected value is very small...
if ( tol < 1.0e-300 ) {
tol = 1.0e-300;
}
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 8 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the ratio of two gamma functions (large `z`, tiny `delta`)', opts, function test( t ) {
var expected;
var delta;
var diff;
var tol;
var v;
var i;
var z;
Expand All @@ -205,9 +179,7 @@ tape( 'the function evaluates the ratio of two gamma functions (large `z`, tiny
expected = largeTiny.expected;
for ( i = 0; i < z.length; i++ ) {
v = gammaDeltaRatio( z[ i ], diff[ i ] );
delta = abs( v - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+z[i]+'. delta: '+diff[i]+'. v: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});