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 gammaLanczosSumExpGScaled = 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 = gammaLanczosSumExpGScaled( x );
y = gammaLanczosSumExpGScaled( 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 = gammaLanczosSumExpGScaled( x );
y = gammaLanczosSumExpGScaled( 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 ] = ( 100.0 * rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100.0 * rand_double() ) - 50.0;
y = stdlib_base_gamma_lanczos_sum_expg_scaled( x );
y = stdlib_base_gamma_lanczos_sum_expg_scaled( 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 @@ -42,7 +42,7 @@ tape( 'main export is a function', function test( t ) {

tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) {
var v = gammaLanczosSumExpGScaled( NaN );
t.equal( isnan( v ), true, 'returns NaN when provided a 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 @@ -51,7 +51,7 @@ tape( 'main export is a function', opts, function test( t ) {

tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) {
var v = gammaLanczosSumExpGScaled( NaN );
t.equal( isnan( v ), true, 'returns NaN when provided a 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/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var gammaLanczosSum = 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 = gammaLanczosSum( x );
y = gammaLanczosSum( 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 = gammaLanczosSum( x );
y = gammaLanczosSum( 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 ] = ( 100.0 * rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100.0 * rand_double() ) - 50.0;
y = stdlib_base_gamma_lanczos_sum( x );
y = stdlib_base_gamma_lanczos_sum( 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 @@ -42,7 +42,7 @@ tape( 'main export is a function', function test( t ) {

tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) {
var v = gammaLanczosSum( NaN );
t.equal( isnan( v ), true, 'returns NaN when provided a 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 @@ -51,7 +51,7 @@ tape( 'main export is a function', opts, function test( t ) {

tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) {
var v = gammaLanczosSum( NaN );
t.equal( isnan( v ), true, 'returns NaN when provided a 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 gamma1pm1 = 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 = gamma1pm1( x );
y = gamma1pm1( 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, -5.0, 5.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 10.0 ) - 5.0;
y = gamma1pm1( x );
y = gamma1pm1( 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_gamma1pm1( x );
y = stdlib_base_gamma1pm1( 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 @@ -118,6 +118,6 @@ tape( 'the function accurately computes `gamma(x+1) - 1` for small positive numb

tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
var val = gamma1pm1( 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 @@ -127,6 +127,6 @@ tape( 'the function accurately computes `gamma(x+1) - 1` for small positive numb

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