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
113 changes: 12 additions & 101 deletions lib/node_modules/@stdlib/math/base/special/besselj1/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
var randu = require( '@stdlib/random/base/randu' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var j1 = require( './../lib' );


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

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (very large positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -65,21 +62,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = veryLargePositive.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 600.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 885 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (large positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -88,21 +77,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = largePositive.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 300.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 302 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (medium positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -111,21 +92,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = mediumPositive.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 2600.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 2870 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (small positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -134,21 +107,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = smallPositive.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 5.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 8 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (small negative values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -157,21 +122,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = smallNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 5.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 8 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates Bessel function of the first kind of order one (J_1) (smaller positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -180,21 +137,13 @@ tape( 'the function evaluates Bessel function of the first kind of order one (J_
x = smaller.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 3.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 5 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (tiny positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -203,21 +152,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = tinyPositive.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (subnormal values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -226,21 +167,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = subnormal.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 5.0e-324;
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) (huge positive values)', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -249,21 +182,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = hugePositive.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 3000.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 4054 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) for positive x over a wide range of magnitudes', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -272,21 +197,13 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = positiveGamut.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 18.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 31 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the Bessel function of the first kind of order one (J_1) for negative x over a wide range of magnitudes', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -295,13 +212,7 @@ tape( 'the function evaluates the Bessel function of the first kind of order one
x = negativeGamut.x;
for ( i = 0; i < x.length; i++ ) {
y = j1( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 18.0 * EPS * abs( expected[i] );
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 31 ), true, 'returns expected value' );
}
t.end();
});
Expand Down
Loading