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

x = uniform( 100, 0.0, 171.0 );

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

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 171.0 * rand_double() ) - 0.0;
y = stdlib_base_gammasgn( x );
y = stdlib_base_gammasgn( 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 @@ -125,19 +125,19 @@ tape( 'the function computes the sign of the gamma function for medium negative

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

tape( 'the function returns `+0` if provided `+0`', function test( t ) {
var v = gammasgn( +0.0 );
t.equal( isPositiveZero( v ), true, 'returns 0' );
t.equal( isPositiveZero( v ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `+0` if provided `-0`', function test( t ) {
var v = gammasgn( -0.0 );
t.equal( isPositiveZero( v ), true, 'returns 0' );
t.equal( isPositiveZero( v ), true, 'returns expected value' );
t.end();
});

Expand All @@ -147,7 +147,7 @@ tape( 'the function returns `+0` if provided a negative integer', function test(

for ( i = 0; i >= -100; i-- ) {
v = gammasgn( i );
t.equal( isPositiveZero( v ), true, 'returns 0' );
t.equal( isPositiveZero( v ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ tape( 'the function computes the sign of the gamma function for medium negative

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

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

tape( 'the function returns `+0` if provided `-0`', opts, function test( t ) {
var v = gammasgn( -0.0 );
t.equal( isPositiveZero( v ), true, 'returns 0' );
t.equal( isPositiveZero( v ), true, 'returns expected value' );
t.end();
});

Expand All @@ -156,7 +156,7 @@ tape( 'the function returns `+0` if provided a negative integer', opts, function

for ( i = 0; i >= -100; i-- ) {
v = gammasgn( i );
t.equal( isPositiveZero( v ), true, 'returns 0' );
t.equal( isPositiveZero( v ), 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 EPS = require( '@stdlib/constants/float64/eps' );
var pkg = require( './../package.json' ).name;
Expand All @@ -37,13 +37,14 @@
var b;
var i;

x = uniform( 100, 0.0, 1.0 );
a = uniform( 100, EPS, 1000.0 );
b = uniform( 100, EPS, 1000.0 );

out = [ 0.0, 0.0 ];
assert.tic();
for ( i = 0; i < assert.iterations; i++ ) {
x = randu();
a = ( randu()*1000.0 ) + EPS;
b = ( randu()*1000.0 ) + EPS;
out = kernelBetainc( x, a, b, true, true, out, 1, 0 );
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], true, true, out, 1, 0 );

Check warning on line 47 in lib/node_modules/@stdlib/math/base/special/kernel-betainc/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 104. Maximum allowed is 80
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
assert.fail( 'should not return NaN' );
}
Expand All @@ -63,13 +64,14 @@
var b;
var i;

x = uniform( 100, 0.0, 1.0 );
a = uniform( 100, EPS, 1000.0 );
b = uniform( 100, EPS, 1000.0 );

out = [ 0.0, 0.0 ];
assert.tic();
for ( i = 0; i < assert.iterations; i++ ) {
x = randu();
a = ( randu()*1000.0 ) + EPS;
b = ( randu()*1000.0 ) + EPS;
out = kernelBetainc( x, a, b, false, true, out, 1, 0 );
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], false, true, out, 1, 0 );

Check warning on line 74 in lib/node_modules/@stdlib/math/base/special/kernel-betainc/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 105. Maximum allowed is 80
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
assert.fail( 'should not return NaN' );
}
Expand All @@ -89,13 +91,14 @@
var b;
var i;

x = uniform( 100, 0.0, 1.0 );
a = uniform( 100, EPS, 1000.0 );
b = uniform( 100, EPS, 1000.0 );

out = [ 0.0, 0.0 ];
assert.tic();
for ( i = 0; i < assert.iterations; i++ ) {
x = randu();
a = ( randu()*1000.0 ) + EPS;
b = ( randu()*1000.0 ) + EPS;
out = kernelBetainc( x, a, b, true, false, out, 1, 0 );
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], true, false, out, 1, 0 );

Check warning on line 101 in lib/node_modules/@stdlib/math/base/special/kernel-betainc/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 105. Maximum allowed is 80
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
assert.fail( 'should not return NaN' );
}
Expand All @@ -115,13 +118,14 @@
var b;
var i;

x = uniform( 100, 0.0, 1.0 );
a = uniform( 100, EPS, 1000.0 );
b = uniform( 100, EPS, 1000.0 );

out = [ 0.0, 0.0 ];
assert.tic();
for ( i = 0; i < assert.iterations; i++ ) {
x = randu();
a = ( randu()*1000.0 ) + EPS;
b = ( randu()*1000.0 ) + EPS;
out = kernelBetainc( x, a, b, false, false, out, 1, 0 );
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], false, false, out, 1, 0 );

Check warning on line 128 in lib/node_modules/@stdlib/math/base/special/kernel-betainc/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 106. Maximum allowed is 80
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
assert.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,74 +36,74 @@

tape( 'the function returns `[ NaN, NaN ]` if `x` is outside `[0,1]`', function test( t ) {
var val = kernelBetainc( -0.2, 1.0, 1.0, true, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( -0.2, 1.0, 1.0, false, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( -0.2, 1.0, 1.0, true, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( -0.2, 1.0, 1.0, false, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 1.1, 1.0, 1.0, true, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 1.1, 1.0, 1.0, false, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 1.1, 1.0, 1.0, false, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 1.1, 1.0, 1.0, true, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

t.end();
});

tape( 'the function returns `[ NaN, NaN ]` if `x` is `NaN`', function test( t ) {
var val = kernelBetainc( NaN, 1.0, 1.0, true, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `[ NaN, NaN ]` if negative `a` or `b`', function test( t ) {
var val = kernelBetainc( 0.5, -1.0, 1.0, true, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, -1.0, 1.0, false, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, -1.0, 1.0, true, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, -1.0, 1.0, false, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, 1.0, -1.0, true, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, 1.0, -1.0, false, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, 1.0, -1.0, true, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, 1.0, -1.0, false, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, -1.0, -1.0, true, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, -1.0, -1.0, false, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, -1.0, -1.0, false, true );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

val = kernelBetainc( 0.5, -1.0, -1.0, true, false );
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
t.equal( isNaNArray( val ), true, 'returns expected value' );

t.end();
});
Expand All @@ -122,4 +122,4 @@
t.end();
});

// TODO: Add fixtures

Check warning on line 125 in lib/node_modules/@stdlib/math/base/special/kernel-betainc/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: Add fixtures'
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 isNumberArray = require( '@stdlib/assert/is-number-array' );
var EPS = require( '@stdlib/constants/float64/eps' );
var pkg = require( './../package.json' ).name;
Expand All @@ -37,12 +37,13 @@
var b;
var i;

p = uniform( 100, 0.0, 1.0 );
a = uniform( 100, EPS, 1000.0 );
b = uniform( 100, EPS, 1000.0 );

assert.tic();
for ( i = 0; i < assert.iterations; i++ ) {
p = randu();
a = ( randu()*1000.0 ) + EPS;
b = ( randu()*1000.0 ) + EPS;
y = kernelBetaincinv( a, b, p, 1.0-p );
y = kernelBetaincinv( a[ i%a.length ], b[ i%b.length ], p[ i%p.length ], 1.0-p );

Check warning on line 46 in lib/node_modules/@stdlib/math/base/special/kernel-betaincinv/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 89. Maximum allowed is 80
if ( !isNumberArray( y ) ) {
assert.fail( 'should return an array of numbers' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var lcm = require( './../lib' );
Expand All @@ -36,11 +35,12 @@ bench( pkg, function benchmark( b ) {
var z;
var i;

x = discreteUniform( 100, 0, 50 );
y = discreteUniform( 100, 0, 50 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = round( randu()*50.0 );
y = round( randu()*50.0 );
z = lcm( x, y );
z = lcm( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-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 @@ -45,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var z;
var i;

x = discreteUniform( 100, 0, 50 );
y = discreteUniform( 100, 0, 50 );

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