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 sin = require( '@stdlib/math/base/special/sin' );
var cos = require( '@stdlib/math/base/special/cos' );
Expand All @@ -36,10 +36,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 = sincos( x );
y = sincos( x[ i%x.length ] );
if ( isnan( y[0] ) || isnan( y[1] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -57,11 +58,12 @@ bench( pkg+'::separate-evaluation', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
y = [ sin( x ), cos( x ) ];
y = [ sin( x[ i%x.length ] ), cos( x[ i%x.length ] ) ];
if ( isnan( y[0] ) || isnan( y[1] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -79,11 +81,12 @@ bench( pkg+':assign', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
sincos.assign( x, y, 1, 0 );
sincos.assign( x[ i%x.length ], y, 1, 0 );
if ( isnan( y[0] ) || isnan( y[1] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -101,12 +104,13 @@ bench( pkg+'::separate-evaluation,in-place', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
y[0] = sin( x );
y[1] = cos( x );
y[0] = sin( x[ i%x.length ] );
y[1] = cos( x[ i%x.length ] );
if ( isnan( y[0] ) || isnan( y[1] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -124,10 +128,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.sin( x ), Math.cos( x ) ]; // eslint-disable-line stdlib/no-builtin-math
y = [ Math.sin( x[ i%x.length ] ), Math.cos( x[ i%x.length ] ) ]; // eslint-disable-line stdlib/no-builtin-math
if ( isnan( y[0] ) || isnan( y[1] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -145,12 +150,13 @@ bench( pkg+'::built-in,in-place', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
y[0] = Math.sin( x ); // eslint-disable-line stdlib/no-builtin-math
y[1] = Math.cos( x ); // eslint-disable-line stdlib/no-builtin-math
y[0] = Math.sin( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
y[1] = Math.cos( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
if ( isnan( y[0] ) || isnan( y[1] ) ) {
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 = sincos( x );
y = sincos( x[ i%x.length ] );
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,21 @@ 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 ] = ( 20.0 * rand_double() ) - 10.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 20.0 * rand_double() ) - 10.0;
y = sin( x );
z = cos( x );
y = sin( x[ i%100 ] );
z = cos( x[ i%100 ] );
if ( y != y || z != z ) {
printf( "should not return NaN\n" );
break;
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 ] = ( 20.0*rand_double() ) - 10.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 20.0*rand_double() ) - 10.0;
sincos( x, &y, &z, 0 );
sincos( x[ i%100 ], &y, &z, 0 );
if ( y != y || z != z ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,20 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double cosine;
double sine;
double x;
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;
stdlib_base_sincos( x, &sine, &cosine );
stdlib_base_sincos( x[ i%100 ], &sine, &cosine );
if ( cosine != cosine || sine != sine ) {
printf( "unexpected results\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,20 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double cosine;
double sine;
double x;
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;
stdlib_base_sincosd( x, &sine, &cosine );
stdlib_base_sincosd( x[ i%100 ], &sine, &cosine );
if ( cosine != cosine || sine != sine ) {
printf( "unexpected results\n" );
break;
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 sinpi = require( '@stdlib/math/base/special/sinpi' );
var cospi = require( '@stdlib/math/base/special/cospi' );
Expand All @@ -37,10 +37,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 = sincospi( x );
y = sincospi( x[ i%x.length ] );
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -58,11 +59,12 @@ bench( pkg+'::separate-evaluation', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
y = [ sinpi( x ), cospi( x ) ];
y = [ sinpi( x[ i%x.length ] ), cospi( x[ i%x.length ] ) ];
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -80,11 +82,12 @@ bench( pkg+':assign', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
sincospi.assign( x, y, 1, 0 );
sincospi.assign( x[ i%x.length ], y, 1, 0 );
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -102,12 +105,13 @@ bench( pkg+'::separate-evaluation,in-place', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
y[ 0 ] = sinpi( x );
y[ 1 ] = cospi( x );
y[ 0 ] = sinpi( x[ i%x.length ] );
y[ 1 ] = cospi( x[ i%x.length ] );
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -125,10 +129,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.sin( PI*x ), Math.cos( PI*x ) ]; // eslint-disable-line stdlib/no-builtin-math
y = [ Math.sin( PI*x[ i%x.length ] ), Math.cos( PI*x[ i%x.length ] ) ]; // eslint-disable-line stdlib/no-builtin-math
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -146,12 +151,13 @@ bench( pkg+'::built-in,in-place', function benchmark( b ) {
var y;
var i;

x = uniform( 100, -10.0, 10.0 );
y = [ 0.0, 0.0 ];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*20.0 ) - 10.0;
y[ 0 ] = Math.sin( PI*x ); // eslint-disable-line stdlib/no-builtin-math
y[ 1 ] = Math.cos( PI*x ); // eslint-disable-line stdlib/no-builtin-math
y[ 0 ] = Math.sin( PI*x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
y[ 1 ] = Math.cos( PI*x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
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 = sincospi( x );
y = sincospi( x[ i%x.length ] );
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,21 @@ 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 ] = ( 20.0 * rand_double() ) - 10.0;
}

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