Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
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 EPS = require( '@stdlib/constants/float64/eps' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var rempio2 = require( '@stdlib/math/base/special/rempio2' );
var tryRequire = require( '@stdlib/utils/try-require' );

Expand Down Expand Up @@ -63,9 +62,7 @@ tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t )

tape( 'the function evaluates the sine and cosine for input values on the interval `[-pi/4, pi/4]`', opts, function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var x;
var y;
var i;
Expand All @@ -76,25 +73,17 @@ tape( 'the function evaluates the sine and cosine for input values on the interv

for ( i = 0; i < x.length; i++ ) {
y = kernelSincos( x[i], 0.0 );
if ( y[0] === sine[ i ] ) {
t.strictEqual( y[0], sine[ i ], 'returns expected value' );
} else {
delta = abs( y[0] - sine[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 = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
// 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
t.strictEqual( isAlmostSameValue( y[0], sine[ i ], 1 ), true, 'returns expected value' );
t.strictEqual( y[1], cosine[ i ], 'returns expected value' );
}
t.end();
});

tape( 'the function can be used to compute the sine and cosine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (positive)', opts, function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var out;
var x;
var y;
Expand All @@ -110,39 +99,21 @@ tape( 'the function can be used to compute the sine and cosine for input values
switch ( n & 3 ) {
case 0:
out = kernelSincos( y[ 0 ], y[ 1 ] );
if ( out[0] === sine[ i ] ) {
t.strictEqual( out[0], sine[ i ], 'returns expected value' );
} else {
delta = abs( out[0] - sine[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 = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}

// 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
t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' );
t.strictEqual( out[1], cosine[ i ], 'returns expected value' );
break;
case 2:
out = kernelSincos( y[ 0 ], y[ 1 ] );
out[ 0 ] = -out[ 0 ];
out[ 1 ] = -out[ 1 ];
if ( out[0] === sine[ i ] ) {
t.strictEqual( out[0], sine[ i ], 'returns expected value' );
} else {
delta = abs( out[0] - sine[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 = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( out[1] === cosine[ i ] ) {
t.strictEqual( out[1], cosine[ i ], 'returns expected value' );
} else {
delta = abs( out[1] - cosine[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 = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}

// 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
t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' );

// 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
t.strictEqual( isAlmostSameValue( out[1], cosine[ i ], 1 ), true, 'returns expected value' );
break;
default:
break;
Expand All @@ -153,9 +124,7 @@ tape( 'the function can be used to compute the sine and cosine for input values

tape( 'the function can be used to compute the sine and cosine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (negative)', opts, function test( t ) {
var cosine;
var delta;
var sine;
var tol;
var out;
var x;
var y;
Expand All @@ -171,39 +140,21 @@ tape( 'the function can be used to compute the sine and cosine for input values
switch ( n & 3 ) {
case 0:
out = kernelSincos( y[ 0 ], y[ 1 ] );
if ( out[0] === sine[ i ] ) {
t.strictEqual( out[0], sine[ i ], 'returns expected value' );
} else {
delta = abs( out[0] - sine[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 = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}

// 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
t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' );
t.strictEqual( out[1], cosine[ i ], 'returns expected value' );
break;
case 2:
out = kernelSincos( y[ 0 ], y[ 1 ] );
out[ 0 ] = -out[ 0 ];
out[ 1 ] = -out[ 1 ];
if ( out[0] === sine[ i ] ) {
t.strictEqual( out[0], sine[ i ], 'returns expected value' );
} else {
delta = abs( out[0] - sine[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 = EPS * abs( sine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[0]+'. Expected: '+sine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}
if ( out[1] === cosine[ i ] ) {
t.strictEqual( out[1], cosine[ i ], 'returns expected value' );
} else {
delta = abs( out[1] - cosine[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 = EPS * abs( cosine[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+out[1]+'. Expected: '+cosine[i]+'. tol: '+tol+'. delta: '+delta+'.' );
}

// 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
t.strictEqual( isAlmostSameValue( out[0], sine[ i ], 1 ), true, 'returns expected value' );

// 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
t.strictEqual( isAlmostSameValue( out[1], cosine[ i ], 1 ), true, 'returns expected value' );
break;
default:
break;
Expand Down