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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var cos = require( './../lib' );
Expand All @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

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

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

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
y = Math.cos( x ); // eslint-disable-line stdlib/no-builtin-math
y = Math.cos( 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, -10.0, 10.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 20.0 ) - 10.0;
y = cos( x );
y = cos( 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 @@ -90,15 +90,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double y;
double t;
int i;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 20.0*rand_double() ) - 10.0;
y = cos( x );
y = cos( 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 @@ -95,15 +95,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double y;
double t;
int i;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 20.0*rand_double() ) - 10.0;
y = cos( x );
y = cos( 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 @@ -91,15 +91,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double y;
double t;
int i;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 20.0 * rand_double() ) - 10.0;
y = stdlib_base_cos( x );
y = stdlib_base_cos( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/math/base/special/cos/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,18 @@ tape( 'the function computes the cosine (huge positive values)', function test(

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

tape( 'the function returns `NaN` if provided a `+infinity`', function test( t ) {
var v = cos( PINF );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if provided a `-infinity`', function test( t ) {
var v = cos( NINF );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,18 @@ tape( 'the function computes the cosine (huge positive values)', opts, function

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

tape( 'the function returns `NaN` if provided a `+infinity`', opts, function test( t ) {
var v = cos( PINF );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if provided a `-infinity`', opts, function test( t ) {
var v = cos( NINF );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), 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 cosd = require( './../lib' );
Expand All @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*10.0 ) - 5.0;
y = cosd( x );
y = cosd( 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 @@ -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, -50.0, 5.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 10.0 ) - 5.0;
y = cosd( x );
y = cosd( 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 @@ -91,15 +91,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double y;
double t;
int i;

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

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

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

Expand Down Expand Up @@ -99,13 +99,13 @@ tape( 'the function computes the cosine of an angle measured in degrees (positiv

tape( 'if provided `+infinity`, the function returns `NaN`', function test( t ) {
var v = cosd( PINF );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );
t.end();
});

tape( 'if provided `-infinity`, the function returns `NaN`', function test( t ) {
var v = cosd( NINF );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );
t.end();
});

Expand Down
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 cosh = require( './../lib' );
Expand All @@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*10.0 ) - 5.0;
y = cosh( x );
y = cosh( 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, -5.0, 5.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*10.0 ) - 5.0;
y = Math.cosh( x ); // eslint-disable-line stdlib/no-builtin-math
y = Math.cosh( 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, -5.0, 5.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*10.0 ) - 5.0;
y = cosh( x );
y = cosh( 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 @@ -90,15 +90,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double y;
double t;
int i;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 10.0*rand_double() ) - 5.0;
y = cosh( x );
y = cosh( 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 @@ -95,15 +95,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double y;
double t;
int i;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 10.0*rand_double() ) - 5.0;
y = cosh( x );
y = cosh( 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 @@ -91,15 +91,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double y;
double t;
int i;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 10.0*rand_double() ) - 5.0;
y = stdlib_base_cosh( x );
y = stdlib_base_cosh( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Loading