Skip to content
Closed
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 exp = require( './../lib' );
Expand All @@ -34,10 +34,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 = exp( x );
y = exp( 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, -50.0, 50.0 );

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*100.0 ) - 50.0;
y = exp( x );
y = exp( 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 ] = ( 100.0*rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100.0*rand_double() ) - 50.0;
y = exp( x );
y = exp( 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 ] = ( 100.0*rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100.0*rand_double() ) - 50.0;
y = exp( x );
y = exp( 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 ] = ( 100.0*rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100.0*rand_double() ) - 50.0;
y = stdlib_base_exp( x );
y = stdlib_base_exp( 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/exp/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ tape( 'the function accurately computes the natural exponential function for ver

tape( 'the function returns `0` if provided a `-infinity`', function test( t ) {
var val = exp( NINF );
t.equal( val, 0.0, 'returns 0' );
t.equal( val, 0.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `+infinity` if provided a `+infinity`', function test( t ) {
var val = exp( PINF );
t.equal( val, PINF, 'returns +infinity' );
t.equal( val, PINF, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) {
var val = exp( NaN );
t.equal( isnan( val ), true, 'returns NaN' );
t.equal( isnan( val ), true, 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ tape( 'the function accurately computes the natural exponential function for ver

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

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

tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t ) {
var val = exp( NaN );
t.equal( isnan( val ), true, 'returns NaN' );
t.equal( isnan( val ), 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 exp10 = require( './../lib' );
Expand All @@ -34,10 +34,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 = exp10( x );
y = exp10( 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, 50.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*100.0 ) - 50.0;
y = exp10( x );
y = exp10( 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 @@ -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 ] = ( rand_double()*100.0 ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( rand_double()*100.0 ) - 50.0;
y = exp10( x );
y = exp10( 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 ] = ( 100.0*rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100.0*rand_double() ) - 50.0;
y = stdlib_base_exp10( x );
y = stdlib_base_exp10( 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/exp10/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,37 +147,37 @@ tape( 'the function accurately computes `10**x` for very small `x`', function te
});

tape( 'the function returns `+infinity` for very large `x`', function test( t ) {
t.equal( exp10( 400.0 ), PINF, 'equals +infinity' );
t.equal( exp10( 500.0 ), PINF, 'equals +infinity' );
t.equal( exp10( 600.0 ), PINF, 'equals +infinity' );
t.equal( exp10( 400.0 ), PINF, 'returns expected value' );
t.equal( exp10( 500.0 ), PINF, 'returns expected value' );
t.equal( exp10( 600.0 ), PINF, 'returns expected value' );
t.end();
});

tape( 'the function returns `0.0` for negative large `x`', function test( t ) {
t.equal( exp10( -400.0 ), 0.0, 'equals 0' );
t.equal( exp10( -500.0 ), 0.0, 'equals 0' );
t.equal( exp10( -600.0 ), 0.0, 'equals 0' );
t.equal( exp10( -400.0 ), 0.0, 'returns expected value' );
t.equal( exp10( -500.0 ), 0.0, 'returns expected value' );
t.equal( exp10( -600.0 ), 0.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `0.0` if provided `-infinity`', function test( t ) {
t.equal( exp10( NINF ), 0.0, 'equals 0' );
t.equal( exp10( NINF ), 0.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) {
t.equal( exp10( PINF ), PINF, 'equals +infinity' );
t.equal( exp10( PINF ), PINF, 'returns expected value' );
t.end();
});

tape( 'the function returns `1` if provided `0`', function test( t ) {
var v = exp10( 0.0 );
t.equal( v, 1.0, 'equals 1' );
t.equal( v, 1.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
var val = exp10( NaN );
t.equal( isnan( val ), true, 'equals NaN' );
t.equal( isnan( val ), true, 'returns expected value' );
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -156,37 +156,37 @@ tape( 'the function accurately computes `10**x` for very small `x`', opts, funct
});

tape( 'the function returns `+infinity` for very large `x`', opts, function test( t ) {
t.equal( exp10( 400.0 ), PINF, 'equals +infinity' );
t.equal( exp10( 500.0 ), PINF, 'equals +infinity' );
t.equal( exp10( 600.0 ), PINF, 'equals +infinity' );
t.equal( exp10( 400.0 ), PINF, 'returns expected value' );
t.equal( exp10( 500.0 ), PINF, 'returns expected value' );
t.equal( exp10( 600.0 ), PINF, 'returns expected value' );
t.end();
});

tape( 'the function returns `0.0` for negative large `x`', opts, function test( t ) {
t.equal( exp10( -400.0 ), 0.0, 'equals 0' );
t.equal( exp10( -500.0 ), 0.0, 'equals 0' );
t.equal( exp10( -600.0 ), 0.0, 'equals 0' );
t.equal( exp10( -400.0 ), 0.0, 'returns expected value' );
t.equal( exp10( -500.0 ), 0.0, 'returns expected value' );
t.equal( exp10( -600.0 ), 0.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `0.0` if provided `-infinity`', opts, function test( t ) {
t.equal( exp10( NINF ), 0.0, 'equals 0' );
t.equal( exp10( NINF ), 0.0, 'returns expected value' );
t.end();
});

tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) {
t.equal( exp10( PINF ), PINF, 'equals +infinity' );
t.equal( exp10( PINF ), PINF, 'returns expected value' );
t.end();
});

tape( 'the function returns `1` if provided `0`', opts, function test( t ) {
var v = exp10( 0.0 );
t.equal( v, 1.0, 'equals 1' );
t.equal( v, 1.0, 'returns expected value' );
t.end();
});

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

x = uniform( 100, 0.0, 1.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = randu();
y = expit( x );
y = expit( x[ i%x.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Loading
Loading