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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isArray = require( '@stdlib/assert/is-array' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -35,10 +35,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = uniform( 100, -50.0, 50.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 100.0 ) - 50.0;
y = sici( x );
y = sici( x[ i%x.length ] );
if ( isnan( y[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -61,11 +62,11 @@ bench( pkg+':assign', function benchmark( b ) {
var i;

out = [ 0.0, 0.0 ];
x = uniform( 100, -50.0, 50.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 100.0 ) - 50.0;
y = sici.assign( x, out, 1, 0 );
y = sici.assign( x[ i%x.length ], out, 1, 0 );
if ( isnan( y[ 0 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,20 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double x;
double y;
double z;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 100.0*rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100.0*rand_double() ) - 50.0;
sici( x, &y, &z );
sici( x[ i%100 ], &y, &z );
if ( y != y || z != z ) {
printf( "should not return NaN\n" );
break;
Expand Down
24 changes: 12 additions & 12 deletions lib/node_modules/@stdlib/math/base/special/sici/test/test.assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ tape( 'the function returns `[0,-Infinity]` if provided `0`', function test( t )
out = [ 0.0, 0.0 ];
val = sici( 0.0, out, 1, 0 );
t.equal( val, out, 'returns output array' );
t.strictEqual( val[ 0 ], 0.0, 'first element equals NaN' );
t.strictEqual( val[ 1 ], NINF, 'second element equals -Infinity' );
t.strictEqual( val[ 0 ], 0.0, 'returns expected value' );
t.strictEqual( val[ 1 ], NINF, 'returns expected value' );
t.end();
});

Expand All @@ -279,8 +279,8 @@ tape( 'the function returns `[-PI/2,NaN]` if provided `-Infinity`', function tes
out = [ 0.0, 0.0 ];
val = sici( NINF, out, 1, 0 );
t.equal( val, out, 'returns output array' );
t.strictEqual( val[ 0 ], -HALF_PI, 'first element equals -PI/2' );
t.strictEqual( isnan( val[ 1 ] ), true, 'second element equals NaN' );
t.strictEqual( val[ 0 ], -HALF_PI, 'returns expected value' );
t.strictEqual( isnan( val[ 1 ] ), true, 'returns expected value' );
t.end();
});

Expand All @@ -291,8 +291,8 @@ tape( 'the function returns `[PI/2,0]` if provided `+Infinity`', function test(
out = [ 0.0, 0.0 ];
val = sici( PINF, out, 1, 0 );
t.equal( val, out, 'returns output array' );
t.strictEqual( val[ 0 ], HALF_PI, 'first element equals PI/2' );
t.strictEqual( val[ 1 ], 0, 'second element equals 0' );
t.strictEqual( val[ 0 ], HALF_PI, 'returns expected value' );
t.strictEqual( val[ 1 ], 0, 'returns expected value' );
t.end();
});

Expand All @@ -303,8 +303,8 @@ tape( 'the function returns `[NaN,NaN]` if provided `NaN`', function test( t ) {
out = [ 0.0, 0.0 ];
val = sici( NaN, out, 1, 0 );
t.equal( val, out, 'returns output array' );
t.strictEqual( isnan( val[ 0 ] ), true, 'first element equals NaN' );
t.strictEqual( isnan( val[ 1 ] ), true, 'second element equals NaN' );
t.strictEqual( isnan( val[ 0 ] ), true, 'returns expected value' );
t.strictEqual( isnan( val[ 1 ] ), true, 'returns expected value' );
t.end();
});

Expand All @@ -316,8 +316,8 @@ tape( 'the function supports providing an output object (array)', function test(
val = sici( 3.0, out, 1, 0 );

t.strictEqual( val, out, 'returns output object' );
t.strictEqual( val[ 0 ], 1.848652527999468, 'has expected first element' );
t.strictEqual( val[ 1 ], 0.11962978600800023, 'has expected second element' );
t.strictEqual( val[ 0 ], 1.848652527999468, 'returns expected value' );
t.strictEqual( val[ 1 ], 0.11962978600800023, 'returns expected value' );

t.end();
});
Expand All @@ -330,8 +330,8 @@ tape( 'the function supports providing an output object (typed array)', function
val = sici( 3.0, out, 1, 0 );

t.strictEqual( val, out, 'returns output object' );
t.strictEqual( val[ 0 ], 1.848652527999468, 'has expected first element' );
t.strictEqual( val[ 1 ], 0.11962978600800023, 'has expected second element' );
t.strictEqual( val[ 0 ], 1.848652527999468, 'returns expected value' );
t.strictEqual( val[ 1 ], 0.11962978600800023, 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,31 +242,31 @@ tape( 'the function computes the sine and cosine integrals for very large positi
tape( 'the function returns `[0,-Infinity]` if provided `0`', function test( t ) {
var val = sici( 0.0 );
t.strictEqual( isArray( val ), true, 'returns an array' );
t.strictEqual( val[ 0 ], 0.0, 'first element equals NaN' );
t.strictEqual( val[ 1 ], NINF, 'second element equals -Infinity' );
t.strictEqual( val[ 0 ], 0.0, 'returns expected value' );
t.strictEqual( val[ 1 ], NINF, 'returns expected value' );
t.end();
});

tape( 'the function returns `[-PI/2,NaN]` if provided `-Infinity`', function test( t ) {
var val = sici( NINF );
t.strictEqual( isArray( val ), true, 'returns an array' );
t.strictEqual( val[ 0 ], -HALF_PI, 'first element equals -PI/2' );
t.strictEqual( isnan( val[ 1 ] ), true, 'second element equals NaN' );
t.strictEqual( val[ 0 ], -HALF_PI, 'returns expected value' );
t.strictEqual( isnan( val[ 1 ] ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `[PI/2,0]` if provided `+Infinity`', function test( t ) {
var val = sici( PINF );
t.strictEqual( isArray( val ), true, 'returns an array' );
t.strictEqual( val[ 0 ], HALF_PI, 'first element equals PI/2' );
t.strictEqual( val[ 1 ], 0, 'second element equals 0' );
t.strictEqual( val[ 0 ], HALF_PI, 'returns expected value' );
t.strictEqual( val[ 1 ], 0, 'returns expected value' );
t.end();
});

tape( 'the function returns `[NaN,NaN]` if provided `NaN`', function test( t ) {
var val = sici( NaN );
t.strictEqual( isArray( val ), true, 'returns an array' );
t.strictEqual( isnan( val[ 0 ] ), true, 'first element equals NaN' );
t.strictEqual( isnan( val[ 1 ] ), true, 'second element equals NaN' );
t.strictEqual( isnan( val[ 0 ] ), true, 'returns expected value' );
t.strictEqual( isnan( val[ 1 ] ), true, 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var signum = require( './../lib' );
Expand All @@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = uniform( 100, -500.0, 500.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = signum( x );
y = signum( x[ i%x.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -62,10 +63,11 @@ bench( pkg+'::built-in', opts, function benchmark( b ) {
var y;
var i;

x = uniform( 100, -500.0, 500.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = Math.sign( x ); // eslint-disable-line stdlib/no-builtin-math
y = Math.sign( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

x = uniform( 100, -500.0, 500.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = signum( x );
y = signum( x[ i%x.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,19 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double x;
double y;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 1000.0 * rand_double() ) - 500.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0 * rand_double() ) - 500.0;
y = signbit( x );
y = signbit( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,19 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double x;
double t;
int y;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 1000.0*rand_double() ) - 500.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 500.0;
y = signbit( x );
y = signbit( x[ i%100 ] );
if ( y > 1 || y < -1 ) {
printf( "should not return a number greater than 1\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,19 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double x;
double y;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( rand_double()*1000.0 ) - 500.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( rand_double()*1000.0 ) - 500.0;
y = stdlib_base_signum( x );
y = stdlib_base_signum( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
20 changes: 10 additions & 10 deletions lib/node_modules/@stdlib/math/base/special/signum/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,38 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
var sign = signum( NaN );
t.equal( isnan( sign ), true, 'returns NaN' );
t.equal( isnan( sign ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `-0` if provided `-0`', function test( t ) {
var sign = signum( -0.0 );
t.equal( isNegativeZero( sign ), true, 'returns -0' );
t.equal( isNegativeZero( sign ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `0` if provided +0', function test( t ) {
var sign;

sign = signum( 0.0 );
t.equal( isPositiveZero( sign ), true, 'returns +0' );
t.equal( isPositiveZero( sign ), true, 'returns expected value' );

sign = signum( +0.0 );
t.equal( isPositiveZero( sign ), true, 'returns +0' );
t.equal( isPositiveZero( sign ), true, 'returns expected value' );

t.end();
});

tape( 'the function returns `-1` if provided a negative number', function test( t ) {
t.equal( signum( -10.0 ), -1.0, 'signum(-10) => -1' );
t.equal( signum( -PI ), -1.0, 'signum(-π) => -1' );
t.equal( signum( NINF ), -1.0, 'signum(-infinity) => -1' );
t.equal( signum( -10.0 ), -1.0, 'returns expected value' );
t.equal( signum( -PI ), -1.0, 'returns expected value' );
t.equal( signum( NINF ), -1.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `+1` if provided a positive number', function test( t ) {
t.equal( signum( 10.0 ), 1.0, 'signum(10) => 1' );
t.equal( signum( PI ), 1.0, 'signum(π) => 1' );
t.equal( signum( PINF ), 1.0, 'signum(infinity) => 1' );
t.equal( signum( 10.0 ), 1.0, 'returns expected value' );
t.equal( signum( PI ), 1.0, 'returns expected value' );
t.equal( signum( PINF ), 1.0, 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,38 @@ tape( 'main export is a function', opts, function test( t ) {

tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
var sign = signum( NaN );
t.equal( isnan( sign ), true, 'returns NaN' );
t.equal( isnan( sign ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) {
var sign = signum( -0.0 );
t.equal( isNegativeZero( sign ), true, 'returns -0' );
t.equal( isNegativeZero( sign ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `0` if provided +0', opts, function test( t ) {
var sign;

sign = signum( 0.0 );
t.equal( isPositiveZero( sign ), true, 'returns +0' );
t.equal( isPositiveZero( sign ), true, 'returns expected value' );

sign = signum( +0.0 );
t.equal( isPositiveZero( sign ), true, 'returns +0' );
t.equal( isPositiveZero( sign ), true, 'returns expected value' );

t.end();
});

tape( 'the function returns `-1` if provided a negative number', opts, function test( t ) {
t.equal( signum( -10.0 ), -1.0, 'signum(-10) => -1' );
t.equal( signum( -PI ), -1.0, 'signum(-π) => -1' );
t.equal( signum( NINF ), -1.0, 'signum(-infinity) => -1' );
t.equal( signum( -10.0 ), -1.0, 'returns expected value' );
t.equal( signum( -PI ), -1.0, 'returns expected value' );
t.equal( signum( NINF ), -1.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `+1` if provided a positive number', opts, function test( t ) {
t.equal( signum( 10.0 ), 1.0, 'signum(10) => 1' );
t.equal( signum( PI ), 1.0, 'signum(π) => 1' );
t.equal( signum( PINF ), 1.0, 'signum(infinity) => 1' );
t.equal( signum( 10.0 ), 1.0, 'returns expected value' );
t.equal( signum( PI ), 1.0, 'returns expected value' );
t.equal( signum( PINF ), 1.0, 'returns expected value' );
t.end();
});
Loading