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
63 changes: 7 additions & 56 deletions lib/node_modules/@stdlib/math/base/special/erf/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var PINF = require( '@stdlib/constants/float64/pinf' );
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 erf = require( './../lib' );


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

tape( 'the function evaluates the error function for `x` on the interval `[-5,-100]', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -67,21 +64,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[-5,-1
x = veryLargeNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = erf( 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.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the error function for `x` on the interval `[5,100]`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -90,21 +79,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[5,100
x = veryLargePositive.x;
for ( i = 0; i < x.length; i++ ) {
y = erf( 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.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the error function for `x` on the interval `[-2.5,-5]`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -113,21 +94,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[-2.5,
x = largeNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = erf( 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.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the error function for `x` on the interval `[2.5,5]`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -136,21 +109,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[2.5,5
x = largePositive.x;
for ( i = 0; i < x.length; i++ ) {
y = erf( 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.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the error function for `x` on the interval `[-1,-3]`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -159,21 +124,13 @@ tape( 'the function evaluates the error function for `x` on the interval `[-1,-3
x = mediumNegative.x;
for ( i = 0; i < x.length; i++ ) {
y = erf( 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.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the error function for `x` on the interval `[1,3]`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var y;
var i;
Expand All @@ -182,13 +139,7 @@ tape( 'the function evaluates the error function for `x` on the interval `[1,3]`
x = mediumPositive.x;
for ( i = 0; i < x.length; i++ ) {
y = erf( 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.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Expand Down
Loading