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
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
// MODULES //

var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var uniform = require( '@stdlib/random/base/uniform' );
var abs = require( '@stdlib/math/base/special/abs' );
var exp = require( '@stdlib/math/base/special/exp' );
var expm1 = require( '@stdlib/math/base/special/expm1' );
var EPS = require( '@stdlib/constants/float64/eps' );
Expand Down Expand Up @@ -107,18 +107,14 @@ tape( 'the function computes the natural logarithm of `1-exp(-|x|)` (`x > ln(2)`

tape( 'the function accurately computes the natural logarithm of `1-exp(-|x|)`', function test( t ) {
var actual;
var delta;
var tol;
var i;

for ( i = 0; i < data.length; i++ ) {
actual = log1mexp( data[ i ] );
if ( actual === expected[ i ] ) {
t.strictEqual( actual, expected[ i ], 'returns '+expected[ i ]+' when provided '+data[ i ] );
} else {
delta = abs( actual - expected[ i ] );
tol = 100.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+data[ i ]+'. actual: '+actual+'. expected: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' );
}
}
t.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var uniform = require( '@stdlib/random/base/uniform' );
var tryRequire = require( '@stdlib/utils/try-require' );
var abs = require( '@stdlib/math/base/special/abs' );
var exp = require( '@stdlib/math/base/special/exp' );
var expm1 = require( '@stdlib/math/base/special/expm1' );
var EPS = require( '@stdlib/constants/float64/eps' );
Expand Down Expand Up @@ -76,9 +76,7 @@ tape( 'if provided `+-0`, the function returns -infinity', opts, function test(
});

tape( 'the function computes the natural logarithm of `1-exp(-|x|)` (`0 < |x| <= ln(2)`)', opts, function test( t ) {
var delta;
var rand;
var tol;
var x;
var y;
var v;
Expand All @@ -94,18 +92,14 @@ tape( 'the function computes the natural logarithm of `1-exp(-|x|)` (`0 < |x| <=
if ( x === y ) {
t.strictEqual( x, y, 'returns '+y+' when provided '+v );
} else {
delta = abs( x - y );
tol = 1.0 * EPS * abs( y );
t.ok( delta <= tol, 'within tolerance. v: '+v+'. actual: '+x+'. expected: '+y+'. Δ: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( x, y, 2 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function computes the natural logarithm of `1-exp(-|x|)` (`x > ln(2)`)', opts, function test( t ) {
var delta;
var rand;
var tol;
var x;
var y;
var v;
Expand All @@ -122,28 +116,22 @@ tape( 'the function computes the natural logarithm of `1-exp(-|x|)` (`x > ln(2)`
if ( x === y ) {
t.strictEqual( x, y, 'returns '+y+' when provided '+v );
} else {
delta = abs( x - y );
tol = 1.0 * EPS * abs( y );
t.ok( delta <= tol, 'within tolerance. v: '+v+'. actual: '+x+'. expected: '+y+'. Δ: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( x, y, 2 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function accurately computes the natural logarithm of `1-exp(-|x|)`', opts, function test( t ) {
var actual;
var delta;
var tol;
var i;

for ( i = 0; i < data.length; i++ ) {
actual = log1mexp( data[ i ] );
if ( actual === expected[ i ] ) {
t.strictEqual( actual, expected[ i ], 'returns '+expected[ i ]+' when provided '+data[ i ] );
} else {
delta = abs( actual - expected[ i ] );
tol = 100.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+data[ i ]+'. actual: '+actual+'. expected: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' );
}
}
t.end();
Expand Down
Loading