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
23 changes: 3 additions & 20 deletions lib/node_modules/@stdlib/math/base/special/gammaln/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
// MODULES //

var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var ln = require( '@stdlib/math/base/special/ln' );
var pow = require( '@stdlib/math/base/special/pow' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var gammaln = require( './../lib' );


Expand Down Expand Up @@ -88,8 +87,6 @@ tape( 'the function returns `-ln(x)` for very small x', function test( t ) {

tape( 'the function evaluates the natural logarithm of the gamma function (positive integers)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -99,21 +96,13 @@ tape( 'the function evaluates the natural logarithm of the gamma function (posit

for ( i = 0; i < x.length; i++ ) {
y = gammaln( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 21.2 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of the gamma function (decimal values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -123,13 +112,7 @@ tape( 'the function evaluates the natural logarithm of the gamma function (decim

for ( i = 0; i < x.length; i++ ) {
y = gammaln( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.1e4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 15 ), true, 'returns expected value' );
}
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@

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 abs = require( '@stdlib/math/base/special/abs' );
var ln = require( '@stdlib/math/base/special/ln' );
var pow = require( '@stdlib/math/base/special/pow' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -97,8 +96,6 @@ tape( 'the function returns `-ln(x)` for very small x', opts, function test( t )

tape( 'the function evaluates the natural logarithm of the gamma function (positive integers)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -108,21 +105,13 @@ tape( 'the function evaluates the natural logarithm of the gamma function (posit

for ( i = 0; i < x.length; i++ ) {
y = gammaln( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 21.2 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of the gamma function (decimal values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -132,13 +121,7 @@ tape( 'the function evaluates the natural logarithm of the gamma function (decim

for ( i = 0; i < x.length; i++ ) {
y = gammaln( x[ i ] );
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.1e4 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 15 ), true, 'returns expected value' );
}
t.end();
});
Expand Down
Loading