diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.js index f01937cfec49..0cb30a31ab13 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var floor = require( '@stdlib/math/base/special/floor' ); +var Int32Array = require( '@stdlib/array/int32' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var TRIBONACCI = require( './../lib/tribonacci.json' ); @@ -36,10 +36,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = discreteUniform( 100, 0, 63 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*64.0 ); - y = tribonacci( x ); + y = tribonacci( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -57,10 +58,11 @@ bench( pkg+'::table', function benchmark( b ) { var y; var i; + x = discreteUniform( 100, 0, 63 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*64.0 ); - y = TRIBONACCI[ x ]; + y = TRIBONACCI[ x[ i % x.length ] ]; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -88,10 +90,11 @@ bench( pkg+'::naive_recursion', function benchmark( b ) { return tribonacci( n-1 ) + tribonacci( n-2 ) + tribonacci( n-3 ); } + x = discreteUniform( 100, 0, 10 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*10.0 ); // limit upper bound - y = tribonacci( x ); + y = tribonacci( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -111,7 +114,7 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 64 ); + arr = new Int32Array( 64 ); arr[ 0 ] = 0; arr[ 1 ] = 0; arr[ 2 ] = 1; @@ -125,10 +128,11 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) { return arr[ n ]; } + x = discreteUniform( 100, 0, 10 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*10.0 ); // limit upper bound - y = tribonacci( x ); + y = tribonacci( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -150,7 +154,7 @@ bench( pkg+'::naive_iterative', function benchmark( b ) { var arr; var i; - arr = new Array( n+1 ); + arr = new Int32Array( n+1 ); arr[ 0 ] = 0; arr[ 1 ] = 0; arr[ 2 ] = 1; @@ -160,10 +164,11 @@ bench( pkg+'::naive_iterative', function benchmark( b ) { return arr[ n ]; } + x = discreteUniform( 100, 0, 63 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*64.0 ); - y = tribonacci( x ); + y = tribonacci( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -200,10 +205,11 @@ bench( pkg+'::iterative', function benchmark( b ) { return c; } + x = discreteUniform( 100, 0, 63 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*64.0 ); - y = tribonacci( x ); + y = tribonacci( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -223,7 +229,7 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 64 ); + arr = new Int32Array( 64 ); arr[ 0 ] = 0; arr[ 1 ] = 0; arr[ 2 ] = 1; @@ -240,10 +246,11 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) { return arr[ n ]; } + x = discreteUniform( 100, 0, 63 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*64.0 ); - y = tribonacci( x ); + y = tribonacci( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.native.js index 85de33feda0e..c3216b7ce8f7 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var floor = require( '@stdlib/math/base/special/floor' ); +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; @@ -44,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = discreteUniform( 100, 0, 63 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floor( randu()*64.0 ); - y = tribonacci( x ); + y = tribonacci( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/benchmark.c index 6616700d4321..d6f61a52e739 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/benchmark.c @@ -115,15 +115,18 @@ int tribonacci( int n ) { */ static double benchmark( void ) { double elapsed; + int x[ 100 ]; double t; - int x; int y; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = (int)floor( 64.0*rand_double() ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = (int)floor( 64.0*rand_double() ); - y = tribonacci( x ); + y = tribonacci( x[ i%100 ] ); if ( y < 0 ) { printf( "should return a nonnegative integer\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/native/benchmark.c index a54c55283ea8..7fb56d97bd0f 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/benchmark/c/native/benchmark.c @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + int32_t x[ 100 ]; double elapsed; - int32_t x; double t; double y; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = (int32_t)floor( 40.0*rand_double() ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = (int32_t)floor( 40.0*rand_double() ); - y = stdlib_base_tribonacci( x ); + y = stdlib_base_tribonacci( x[ i%100 ] ); if ( y < 0 ) { printf( "should return a nonnegative integer\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.js b/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.js index b5e9425b3e60..75dfb3a5af38 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.js @@ -43,30 +43,30 @@ tape( 'if provided a negative number, the function returns `NaN`', function test var v; var i; - t.strictEqual( isnan( tribonacci( -3.14 ) ), true, 'returns NaN' ); + t.strictEqual( isnan( tribonacci( -3.14 ) ), true, 'returns expected value' ); for ( i = -1; i > -100; i-- ) { v = tribonacci( i ); - t.strictEqual( isnan( v ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnan( v ), true, 'returns expected value when provided ' + i ); } t.end(); }); tape( 'if provided positive infinity, the function returns `NaN`', function test( t ) { var v = tribonacci( PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN when provided +infinity' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var v = tribonacci( 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 a non-integer, the function returns `NaN`', function test( t ) { var v = tribonacci( 3.14 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -85,7 +85,7 @@ tape( 'if provided nonnegative integers greater than `63`, the function returns var v; for ( i = 64; i < 500; i++ ) { v = tribonacci( i ); - t.strictEqual( isnan( v ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnan( v ), true, 'returns expected value when provided ' + i ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.native.js index 9a25e6de044f..0b30215b39a8 100644 --- a/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/tribonacci/test/test.native.js @@ -53,7 +53,7 @@ tape( 'if provided a negative number, the function returns `NaN`', opts, functio for ( i = -1; i > -100; i-- ) { v = tribonacci( i ); - t.strictEqual( isnan( v ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnan( v ), true, 'returns expected value when provided ' + i ); } t.end(); }); @@ -73,7 +73,7 @@ tape( 'if provided nonnegative integers greater than `63`, the function returns var v; for ( i = 64; i < 500; i++ ) { v = tribonacci( i ); - t.strictEqual( isnan( v ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnan( v ), true, 'returns expected value when provided ' + i ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.js index 6d3307c5bc06..d82165ea83e3 100644 --- a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.js @@ -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; @@ -35,10 +35,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, EPS, 100.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100.0 ) + EPS; - y = trigamma( x ); + y = trigamma( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.native.js index 53f098b6e7f0..f911fd27f218 100644 --- a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/benchmark.native.js @@ -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 EPS = require( '@stdlib/constants/float64/eps' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -44,10 +44,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, EPS, 100.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 100.0 ) + EPS; - y = trigamma( x ); + y = trigamma( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/c/native/benchmark.c index 02c46808c0c8..d93f4e310185 100644 --- a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/c/native/benchmark.c @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 100.0 * rand_double() ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 100.0 * rand_double() ); - y = stdlib_base_trigamma( x ); + y = stdlib_base_trigamma( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/cpp/boost/benchmark.cpp b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/cpp/boost/benchmark.cpp index fd70542669df..29f6de0f97ed 100644 --- a/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/cpp/boost/benchmark.cpp +++ b/lib/node_modules/@stdlib/math/base/special/trigamma/benchmark/cpp/boost/benchmark.cpp @@ -85,8 +85,8 @@ double tic() { * @return elapsed time in seconds */ double benchmark() { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; @@ -97,10 +97,13 @@ double benchmark() { // Define a uniform distribution for generating pseudorandom numbers as "doubles" between a minimum value (inclusive) and a maximum value (exclusive): uniform_real_distribution<> randu( 0.1, 100.0 ); + for ( i = 0; i < 100; i++ ) { + x[ i ] = randu( rng ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = randu( rng ); - y = boost::math::trigamma( x ); + y = boost::math::trigamma( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.js b/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.js index fca26be0bb67..c2fc99559a1d 100644 --- a/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.js @@ -46,25 +46,25 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided a `NaN`, the function returns `NaN`', function test( t ) { var val = trigamma( NaN ); - t.strictEqual( isnan( val ), true, 'returns NaN' ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); t.end(); }); tape( 'if provided `0`, the function returns `NaN`', function test( t ) { var val = trigamma( 0.0 ); - t.strictEqual( isnan( val ), true, 'returns NaN' ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); t.end(); }); tape( 'if provided positive infinity, the function returns `0`', function test( t ) { var val = trigamma( PINF ); - t.strictEqual( val, 0.0, 'returns 0' ); + t.strictEqual( val, 0.0, 'returns expected value' ); t.end(); }); tape( 'if provided negative infinity, the function returns `NaN`', function test( t ) { var val = trigamma( NINF ); - t.strictEqual( isnan( val ), true, 'returns NaN' ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); t.end(); }); @@ -76,7 +76,7 @@ tape( 'if provided a negative integer, the function returns `NaN`', function tes values = incrspace( -1.0, -100.0, -1.0 ); for ( i = 0; i < values.length; i++ ) { val = trigamma( values[ i ] ); - t.strictEqual( isnan( val ), true, 'returns NaN' ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.native.js index 18fdc0e201a0..bd38991eb3c5 100644 --- a/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/trigamma/test/test.native.js @@ -67,7 +67,7 @@ tape( 'if provided `0`, the function returns `NaN`', opts, function test( t ) { tape( 'if provided positive infinity, the function returns `0`', opts, function test( t ) { var val = trigamma( PINF ); - t.strictEqual( val, 0.0, 'returns 0' ); + t.strictEqual( val, 0.0, 'returns expected value' ); t.end(); });