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 @@ -22,7 +22,7 @@

var bench = require( '@stdlib/bench' );
var gamma = require( '@stdlib/math/base/special/gamma' );
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 gammaDeltaRatio = require( './../lib' );
Expand All @@ -36,11 +36,12 @@
var y;
var i;

z = uniform( 100, 0.0, 100.0 );
delta = uniform( 100, 0.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = randu()*100.0;
delta = randu()*100.0;
y = gammaDeltaRatio( z, delta );
y = gammaDeltaRatio( z[ i%z.length ], delta[ i%delta.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -59,11 +60,12 @@
var y;
var i;

z = uniform( 100, 0.0, 100.0 );
delta = uniform( 100, 0.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = randu()*100.0;
delta = randu()*100.0;
y = gamma( z ) / gamma( z + delta );
y = gamma( z[ i%z.length ] ) / gamma( z[ i%z.length ] + delta[ i%delta.length ] );

Check warning on line 68 in lib/node_modules/@stdlib/math/base/special/gamma-delta-ratio/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 90. Maximum allowed is 80
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 @@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

z = uniform( 100, 0.0, 100.0 );
delta = uniform( 100, 0.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = randu() * 100.0;
delta = randu() * 100.0;
y = gammaDeltaRatio( z, delta );
y = gammaDeltaRatio( z[ i%z.length ], delta[ i%delta.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,17 +91,20 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double delta;
double z;
double delta[ 100 ];
double z[ 100 ];
double y;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
z[ i ] = ( rand_double() * 100.0 );
delta[ i ] = ( rand_double() * 100.0 );
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
z = ( rand_double() * 100.0 );
delta = ( rand_double() * 100.0 );
y = stdlib_base_gamma_delta_ratio( z, delta );
y = stdlib_base_gamma_delta_ratio( z[ i%100 ], delta[ 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 @@ -49,13 +49,13 @@ tape( 'the function returns `NaN` if provided `NaN` for either parameter', funct
var v;

v = gammaDeltaRatio( NaN, 5.0 );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );

v = gammaDeltaRatio( 1.0, NaN );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );

v = gammaDeltaRatio( NaN, NaN );
t.equal( isnan( v ), true, 'returns NaN' );
t.equal( isnan( v ), true, 'returns expected value' );

t.end();
});
Expand All @@ -64,10 +64,10 @@ tape( 'the function returns `0` for very large `z` and negligible `delta`', func
var v;

v = gammaDeltaRatio( 1.0e100, 20.7 );
t.equal( v, 0.0, 'returns 0' );
t.equal( v, 0.0, 'returns expected value' );

v = gammaDeltaRatio( 1.0e120, 100.1 );
t.equal( v, 0.0, 'returns 0' );
t.equal( v, 0.0, 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ tape( 'the function returns `0` for very large `z` and negligible `delta`', opts
var v;

v = gammaDeltaRatio( 1.0e100, 20.7 );
t.equal( v, 0.0, 'returns 0' );
t.equal( v, 0.0, 'returns expected value' );

v = gammaDeltaRatio( 1.0e120, 100.1 );
t.equal( v, 0.0, 'returns 0' );
t.equal( v, 0.0, '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/array/uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var gammaBoost = require( './../lib/boost/gamma.js' );
Expand All @@ -35,7 +35,7 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = randu( 100, 0.0, 171.0 );
x = uniform( 100, 0.0, 171.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand All @@ -57,7 +57,7 @@ bench( pkg+'::boost', function benchmark( b ) {
var y;
var i;

x = randu( 100, 0.0, 171.0 );
x = uniform( 100, 0.0, 171.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
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/array/uniform' );
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,7 +43,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

x = randu( 100, 0.0, 171.0 );
x = uniform( 100, 0.0, 171.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ tape( 'if provided a negative integer, the function returns `NaN`', function tes

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( isnan( v ), true, 'returns NaN when provided ' + values[ i ] );
t.equal( isnan( v ), true, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});

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

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

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

tape( 'if provided `+0`, the function returns positive infinity', function test( t ) {
var v = gamma( 0.0 );
t.equal( v, PINF, 'returns +infinity' );
t.equal( v, PINF, 'returns expected value' );
t.end();
});

Expand All @@ -88,7 +88,7 @@ tape( 'if `x >= 171.63...`, the function returns positive infinity', function te

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( v, PINF, 'returns +infinity when provided ' + values[ i ] );
t.equal( v, PINF, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});
Expand All @@ -100,7 +100,7 @@ tape( 'if `x <= -170.65`, the function returns zero', function test( t ) {

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( v, 0, 'returns 0 when provided ' + values[ i ] );
t.equal( v, 0, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});
Expand Down
14 changes: 7 additions & 7 deletions lib/node_modules/@stdlib/math/base/special/gamma/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,32 @@ tape( 'if provided a negative integer, the function returns `NaN`', function tes

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( isnan( v ), true, 'returns NaN when provided ' + values[ i ] );
t.equal( isnan( v ), true, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});

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

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

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

tape( 'if provided `+0`, the function returns positive infinity', function test( t ) {
var v = gamma( 0.0 );
t.equal( v, PINF, 'returns +infinity' );
t.equal( v, PINF, 'returns expected value' );
t.end();
});

Expand All @@ -89,7 +89,7 @@ tape( 'if `x > 171.6144...`, the function returns positive infinity', function t

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( v, PINF, 'returns +infinity when provided ' + values[ i ] );
t.equal( v, PINF, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});
Expand All @@ -101,7 +101,7 @@ tape( 'if `x < -170.56749...`, the function returns zero', function test( t ) {

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( v, 0.0, 'returns 0 when provided ' + values[ i ] );
t.equal( v, 0.0, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,32 @@ tape( 'if provided a negative integer, the function returns `NaN`', opts, functi

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( isnan( v ), true, 'returns NaN when provided ' + values[ i ] );
t.equal( isnan( v ), true, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});

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

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

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

tape( 'if provided `+0`, the function returns positive infinity', opts, function test( t ) {
var v = gamma( 0.0 );
t.equal( v, PINF, 'returns +infinity' );
t.equal( v, PINF, 'returns expected value' );
t.end();
});

Expand All @@ -98,7 +98,7 @@ tape( 'if `x > 171.6144...`, the function returns positive infinity', opts, func

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( v, PINF, 'returns +infinity when provided ' + values[ i ] );
t.equal( v, PINF, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});
Expand All @@ -110,7 +110,7 @@ tape( 'if `x < -170.56749...`, the function returns zero', opts, function test(

for ( i = 0; i < values.length; i++ ) {
v = gamma( values[ i ] );
t.equal( v, 0.0, 'returns 0 when provided ' + values[ i ] );
t.equal( v, 0.0, 'returns expected value when provided ' + values[ i ] );
}
t.end();
});
Expand Down