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: 5 additions & 18 deletions lib/node_modules/@stdlib/math/base/special/spence/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
// MODULES //

var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var PI_SQUARED = require( '@stdlib/constants/float64/pi-squared' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var abs = require( '@stdlib/math/base/special/abs' );
var PI_SQUARED = require( '@stdlib/constants/float64/pi-squared' );
var EPS = require( '@stdlib/constants/float64/eps' );
var spence = require( './../lib' );


Expand All @@ -46,8 +45,6 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function accurately computes the dilogarithm for small positive numbers', function test( t ) {
var expected;
var delta;
var tol;
var x;
var v;
var i;
Expand All @@ -57,17 +54,13 @@ tape( 'the function accurately computes the dilogarithm for small positive numbe

for ( i = 0; i < x.length; i++ ) {
v = spence( x[ i ] );
delta = abs( v - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function accurately computes the dilogarithm for medium positive numbers', function test( t ) {
var expected;
var delta;
var tol;
var x;
var v;
var i;
Expand All @@ -77,17 +70,13 @@ tape( 'the function accurately computes the dilogarithm for medium positive numb

for ( i = 0; i < x.length; i++ ) {
v = spence( x[ i ] );
delta = abs( v - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function accurately computes the dilogarithm for large positive numbers', function test( t ) {
var expected;
var delta;
var tol;
var x;
var v;
var i;
Expand All @@ -97,9 +86,7 @@ tape( 'the function accurately computes the dilogarithm for large positive numbe

for ( i = 0; i < x.length; i++ ) {
v = spence( x[ i ] );
delta = abs( v - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Expand Down
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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var PI_SQUARED = require( '@stdlib/constants/float64/pi-squared' );
var EPS = require( '@stdlib/constants/float64/eps' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -54,8 +53,6 @@ tape( 'main export is a function', opts, function test( t ) {

tape( 'the function accurately computes the dilogarithm for small positive numbers', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var v;
var i;
Expand All @@ -65,17 +62,13 @@ tape( 'the function accurately computes the dilogarithm for small positive numbe

for ( i = 0; i < x.length; i++ ) {
v = spence( x[ i ] );
delta = abs( v - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. Value: ' + v + '. Expected: ' + expected[ i ] + '. Tolerance: ' + tol + '.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function accurately computes the dilogarithm for medium positive numbers', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var v;
var i;
Expand All @@ -85,19 +78,13 @@ tape( 'the function accurately computes the dilogarithm for medium positive numb

for ( i = 0; i < x.length; i++ ) {
v = spence( 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 = 8.3 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function accurately computes the dilogarithm for large positive numbers', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var v;
var i;
Expand All @@ -107,9 +94,7 @@ tape( 'the function accurately computes the dilogarithm for large positive numbe

for ( i = 0; i < x.length; i++ ) {
v = spence( x[ i ] );
delta = abs( v - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Expand Down