Skip to content
Draft
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
110 changes: 12 additions & 98 deletions lib/node_modules/@stdlib/math/base/special/sincos/test/test.assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ var tape = require( 'tape' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
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 Float64Array = require( '@stdlib/array/float64' );
var sincos = require( './../lib/assign.js' );

Expand All @@ -50,9 +48,7 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var x;
var y;
var i;
Expand All @@ -66,29 +62,15 @@ tape( 'the function computes the sine and cosine (for -256*pi < x < 0)', functio
for ( i = 0; i < x.length; i++ ) {
y = sincos( x[i], z, 1, 0 );
t.strictEqual( y, z, 'returns output array' );
if ( y[0] === sine[ i ] ) {
t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] );
} else {
delta = abs( y[0] - sine[i] );
tol = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( y[1] === cosine[ i ] ) {
t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] );
} else {
delta = abs( y[1] - cosine[i] );
tol = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var x;
var y;
var i;
Expand All @@ -102,29 +84,15 @@ tape( 'the function computes the sine and cosine (for 0 < x < 256*pi)', function
for ( i = 0; i < x.length; i++ ) {
y = sincos( x[i], z, 1, 0 );
t.strictEqual( y, z, 'returns output array' );
if ( y[0] === sine[ i ] ) {
t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] );
} else {
delta = abs( y[0] - sine[i] );
tol = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( y[1] === cosine[ i ] ) {
t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] );
} else {
delta = abs( y[1] - cosine[i] );
tol = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20 (pi/2))', function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var x;
var y;
var i;
Expand All @@ -138,29 +106,15 @@ tape( 'the function computes the sine and cosine (for -2**60 (pi/2) < x < -2**20
for ( i = 0; i < x.length; i++ ) {
y = sincos( x[i], z, 1, 0 );
t.strictEqual( y, z, 'returns output array' );
if ( y[0] === sine[ i ] ) {
t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] );
} else {
delta = abs( y[0] - sine[i] );
tol = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( y[1] === cosine[ i ] ) {
t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] );
} else {
delta = abs( y[1] - cosine[i] );
tol = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 (pi/2))', function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var x;
var y;
var i;
Expand All @@ -174,29 +128,15 @@ tape( 'the function computes the sine and cosine (for 2**20 (pi/2) < x < 2**60 (
for ( i = 0; i < x.length; i++ ) {
y = sincos( x[i], z, 1, 0 );
t.strictEqual( y, z, 'returns output array' );
if ( y[0] === sine[ i ] ) {
t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] );
} else {
delta = abs( y[0] - sine[i] );
tol = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( y[1] === cosine[ i ] ) {
t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] );
} else {
delta = abs( y[1] - cosine[i] );
tol = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var x;
var y;
var i;
Expand All @@ -210,29 +150,15 @@ tape( 'the function computes the sine and cosine (for x <= -2**60 (PI/2))', func
for ( i = 0; i < x.length; i++ ) {
y = sincos( x[i], z, 1, 0 );
t.strictEqual( y, z, 'returns output array' );
if ( y[0] === sine[ i ] ) {
t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] );
} else {
delta = abs( y[0] - sine[i] );
tol = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( y[1] === cosine[ i ] ) {
t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] );
} else {
delta = abs( y[1] - cosine[i] );
tol = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var x;
var y;
var i;
Expand All @@ -246,20 +172,8 @@ tape( 'the function computes the sine and cosine (for x >= 2**60 (PI/2))', funct
for ( i = 0; i < x.length; i++ ) {
y = sincos( x[i], z, 1, 0 );
t.strictEqual( y, z, 'returns output array' );
if ( y[0] === sine[ i ] ) {
t.strictEqual( y[0], sine[ i ], 'x: '+x[i]+'. Expected: '+sine[i] );
} else {
delta = abs( y[0] - sine[i] );
tol = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( y[1] === cosine[ i ] ) {
t.strictEqual( y[1], cosine[ i ], 'x: '+x[i]+'. Expected: '+cosine[i] );
} else {
delta = abs( y[1] - cosine[i] );
tol = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( y[ 0 ], sine[ i ], 'returns expected value' );
t.strictEqual( y[ 1 ], cosine[ i ], 'returns expected value' );
}
t.end();
});
Expand Down
Loading