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/array/uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pkg = require( './../package.json' ).name;
Expand All @@ -36,7 +36,7 @@ bench( pkg, function benchmark( b ) {
var z;
var i;

x = randu( 100, -10.0, 10.0 );
x = uniform( 100, -10.0, 10.0 );
y = discreteUniform( 100, -1020.0, 1020.0 );

b.tic();
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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var tryRequire = require( '@stdlib/utils/try-require' );
Expand All @@ -45,7 +45,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var z;
var i;

x = randu( 100, -10.0, 10.0 );
x = uniform( 100, -10.0, 10.0 );
y = discreteUniform( 100, -1020.0, 1020.0 );

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

x = uniform( 100, 0.0, 10000.0 );

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 10000.0 ) - 0.0;
y = lnf( x );
y = lnf( 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 @@ -92,14 +92,17 @@ static float rand_float( void ) {
static double benchmark( void ) {
double elapsed;
double t;
float x;
float x[ 100 ];
float y;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 10000.0f * rand_float() ) - 0.0f;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 10000.0f * rand_float() ) - 0.0f;
y = stdlib_base_lnf( x );
y = stdlib_base_lnf( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/math/base/special/lnf/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
});

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
});

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

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

x = uniform( 100, 0.0, 1000.0 );

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 0.0;
y = log1mexp( x );
y = log1mexp( 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 @@ -109,15 +109,18 @@ double log1mexp( double x ) {
*/
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 ] = ( 1000.0*rand_double() ) - 0.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 0.0;
y = log1mexp( x );
y = log1mexp( 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 @@ -92,15 +92,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 ] = ( 1000.0*rand_double() ) - 0.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 0.0;
y = stdlib_base_log1mexp( x );
y = stdlib_base_log1mexp( 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 @@ -50,18 +50,18 @@ tape( 'main export is a function', function test( t ) {

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

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

v = log1mexp( 0.0 );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, 'returns expected value' );

v = log1mexp( -0.0 );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ tape( 'main export is a function', opts, function test( t ) {

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

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

v = log1mexp( 0.0 );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, 'returns expected value' );

v = log1mexp( -0.0 );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, '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 log1p = require( './../lib' );
Expand All @@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = uniform( 100, 0.0, 1000.0 );

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

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

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

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

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

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