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
73 changes: 8 additions & 65 deletions lib/node_modules/@stdlib/math/base/special/lnf/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var PINF = require( '@stdlib/constants/float32/pinf' );
var NINF = require( '@stdlib/constants/float32/ninf' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var lnf = require( './../lib' );
Expand All @@ -52,8 +51,6 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function evaluates the natural logarithm of `x` (very large positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -64,21 +61,13 @@ tape( 'the function evaluates the natural logarithm of `x` (very large positive
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (large positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -89,21 +78,13 @@ tape( 'the function evaluates the natural logarithm of `x` (large positive value
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (medium positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -114,21 +95,13 @@ tape( 'the function evaluates the natural logarithm of `x` (medium positive valu
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (small positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -139,21 +112,13 @@ tape( 'the function evaluates the natural logarithm of `x` (small positive value
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 106.0 * EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 174 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (smaller positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -164,21 +129,13 @@ tape( 'the function evaluates the natural logarithm of `x` (smaller positive val
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 1.8 * EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (tiny positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -189,21 +146,13 @@ tape( 'the function evaluates the natural logarithm of `x` (tiny positive values
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -214,13 +163,7 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 7.0 * EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 10 ), true, 'returns expected value' );
}
t.end();
});
Expand Down
73 changes: 8 additions & 65 deletions lib/node_modules/@stdlib/math/base/special/lnf/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var PINF = require( '@stdlib/constants/float32/pinf' );
var NINF = require( '@stdlib/constants/float32/ninf' );
var EPS = require( '@stdlib/constants/float32/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var tryRequire = require( '@stdlib/utils/try-require' );
Expand Down Expand Up @@ -61,8 +60,6 @@ tape( 'main export is a function', opts, function test( t ) {

tape( 'the function evaluates the natural logarithm of `x` (very large positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -73,21 +70,13 @@ tape( 'the function evaluates the natural logarithm of `x` (very large positive
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (large positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -98,21 +87,13 @@ tape( 'the function evaluates the natural logarithm of `x` (large positive value
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (medium positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -123,21 +104,13 @@ tape( 'the function evaluates the natural logarithm of `x` (medium positive valu
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (small positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -148,21 +121,13 @@ tape( 'the function evaluates the natural logarithm of `x` (small positive value
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 106.0 * EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 174 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (smaller positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -173,21 +138,13 @@ tape( 'the function evaluates the natural logarithm of `x` (smaller positive val
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 1.8 * EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (tiny positive values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -198,21 +155,13 @@ tape( 'the function evaluates the natural logarithm of `x` (tiny positive values
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the natural logarithm of `x` (subnormal values)', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -223,13 +172,7 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
for ( i = 0; i < x.length; i++ ) {
y = lnf( x[i] );
e = float64ToFloat32( expected[ i ] );
if ( y === e ) {
t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 7.0 * EPS * abs( e );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, e, 10 ), true, 'returns expected value' );
}
t.end();
});
Expand Down