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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ file = @__FILE__;
dir = dirname( file );

# Generate fixture data for negative values:
x = range( -360.0, stop = 0.0, length = 1000 );
x = range( -360.0, stop = 0.1, length = 1000 );
gen( x, "negative.json" );

# Generate fixture data for positive values:
x = range( 0.0, stop = 360.0, length = 1000 );
x = range( 0.1, stop = 360.0, length = 1000 );
gen( x, "positive.json" );
39 changes: 36 additions & 3 deletions lib/node_modules/@stdlib/math/base/special/cscd/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var tape = require( 'tape' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var EPS = require( '@stdlib/constants/float64/eps' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var abs = require( '@stdlib/math/base/special/abs' );
var cscd = require( './../lib' );

Expand All @@ -48,6 +49,38 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
t.end();
});

tape( 'if provided a positive multiple of `180.0`, the function returns `+infinity`', function test( t ) {
var v = cscd( 180.0 );
t.strictEqual( PINF, v, 'returns expected value' );

v = cscd( 360.0 );
t.strictEqual( PINF, v, 'returns expected value' );

t.end();
});

tape( 'if provided a negative multiple of `180.0`, the function returns `-infinity`', function test( t ) {
var v = cscd( -180.0 );
t.strictEqual( NINF, v, 'returns expected value' );

v = cscd( -360.0 );
t.strictEqual( NINF, v, 'returns expected value' );

t.end();
});

tape( 'the function returns `-0` if provided `-infinity`', function test( t ) {
var v = cscd( -0.0 );
t.strictEqual( NINF, v, 'returns expected value' );
t.end();
});

tape( 'the function returns `+0` if provided `+infinity`', function test( t ) {
var v = cscd( 0.0 );
t.strictEqual( PINF, v, 'returns expected value' );
t.end();
});

tape( 'the function computes the cosecant in degrees (negative values)', function test( t ) {
var expected;
var delta;
Expand All @@ -62,14 +95,14 @@ tape( 'the function computes the cosecant in degrees (negative values)', functio
for ( i = 0; i < x.length; i++ ) {
y = cscd( x[i] );
if ( expected[ i ] === null ) {
t.strictEqual( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
t.strictEqual( y, NINF, 'x: '+x[i]+'. E: '+expected[i] );
continue;
}
if ( y === expected[ i ] ) {
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 1.3 * EPS * abs( expected[i] );
tol = 1.4 * EPS * abs( expected[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
}
Expand Down Expand Up @@ -97,7 +130,7 @@ tape( 'the function computes the cosecant in degrees (positive values)', functio
t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
} else {
delta = abs( y - expected[i] );
tol = 1.3 * EPS * abs( expected[i] );
tol = 1.4 * EPS * abs( expected[i] );
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var tape = require( 'tape' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var EPS = require( '@stdlib/constants/float64/eps' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var abs = require( '@stdlib/math/base/special/abs' );
var tryRequire = require( '@stdlib/utils/try-require' );

Expand Down Expand Up @@ -57,6 +58,38 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
t.end();
});

tape( 'if provided a positive multiple of `180.0`, the function returns `+infinity`', opts, function test( t ) {
var v = cscd( 180.0 );
t.strictEqual( PINF, v, 'returns expected value' );

v = cscd( 360.0 );
t.strictEqual( PINF, v, 'returns expected value' );

t.end();
});

tape( 'if provided a negative multiple of `180.0`, the function returns `-infinity`', opts, function test( t ) {
var v = cscd( -180.0 );
t.strictEqual( NINF, v, 'returns expected value' );

v = cscd( -360.0 );
t.strictEqual( NINF, v, 'returns expected value' );

t.end();
});

tape( 'the function returns `-0` if provided `-infinity`', opts, function test( t ) {
var v = cscd( -0.0 );
t.strictEqual( NINF, v, 'returns expected value' );
t.end();
});

tape( 'the function returns `+0` if provided `+infinity`', opts, function test( t ) {
var v = cscd( 0.0 );
t.strictEqual( PINF, v, 'returns expected value' );
t.end();
});

tape( 'the function computes the cosecant in degrees (negative values)', opts, function test( t ) {
var expected;
var delta;
Expand All @@ -71,7 +104,7 @@ tape( 'the function computes the cosecant in degrees (negative values)', opts, f
for ( i = 0; i < x.length; i++ ) {
y = cscd( x[i] );
if ( expected[ i ] === null ) {
t.strictEqual( y, PINF, 'x: '+x[i]+'. E: '+expected[i] );
t.strictEqual( y, NINF, 'x: '+x[i]+'. E: '+expected[i] );
continue;
}
if ( y === expected[ i ] ) {
Expand Down