diff --git a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/benchmark.js index 8b2aab638b6c..73a5b447f563 100644 --- a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/haversin/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 pkg = require( './../package.json' ).name; var haversin = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, -10.0, 10.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*20.0 ) - 10.0; - y = haversin( x ); + y = haversin( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/benchmark.native.js index e82771508f3c..8e16b8b32496 100644 --- a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/haversin/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 tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, -10.0, 10.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 20.0 ) - 10.0; - y = haversin( x ); + y = haversin( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/benchmark.c index feda1e39ccb7..ad642cf0adbd 100644 --- a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/benchmark.c @@ -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 ] = ( 20.0*rand_double() ) - 10.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 20.0*rand_double() ) - 10.0; - y = ( 1.0 - cos( x ) ) / 2.0; + y = ( 1.0 - cos( x[ i%100 ] ) ) / 2.0; if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/native/benchmark.c index 5988ac85a491..fa3df0b9f09f 100644 --- a/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/haversin/benchmark/c/native/benchmark.c @@ -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 ] = ( 20.0 * rand_double() ) - 10.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 20.0 * rand_double() ) - 10.0; - y = stdlib_base_haversin( x ); + y = stdlib_base_haversin( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/haversin/test/test.js b/lib/node_modules/@stdlib/math/base/special/haversin/test/test.js index 5b845e734ca2..5e9e8f6d9e7e 100644 --- a/lib/node_modules/@stdlib/math/base/special/haversin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/haversin/test/test.js @@ -199,18 +199,18 @@ tape( 'the function computes the half-value versed sine (for x >= 2**60 (PI/2) ) tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) { var v = haversin( NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `+infinity`', function test( t ) { var v = haversin( PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', function test( t ) { var v = haversin( NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/benchmark.js index 3082350cd8a0..1608be5263b4 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/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 pkg = require( './../package.json' ).name; var heaviside = require( './../lib' ); @@ -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 = heaviside( x ); + y = heaviside( x[ i%x.length ] ); if ( y > 1.0 ) { b.fail( 'should not return a value greater than 1' ); } @@ -55,10 +56,11 @@ bench( pkg+'::left-continuous', 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 = heaviside( x, 'left-continuous' ); + y = heaviside( x[ i%x.length ], 'left-continuous' ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -76,10 +78,11 @@ bench( pkg+'::right-continuous', 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 = heaviside( x, 'right-continuous' ); + y = heaviside( x[ i%x.length ], 'right-continuous' ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -97,10 +100,11 @@ bench( pkg+'::half-maximum', 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 = heaviside( x, 'half-maximum' ); + y = heaviside( x[ i%x.length ], 'half-maximum' ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/benchmark.c index 4cf3265ae5bd..77516b044516 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/benchmark.c @@ -103,15 +103,18 @@ double heaviside( 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 ] = ( 100.0*rand_double() ) - 50.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 100.0*rand_double() ) - 50.0; - y = heaviside( x ); + y = heaviside( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js index adbcca86964e..34d5477dd251 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js @@ -46,7 +46,7 @@ tape( 'the function returns `0` if `x` is negative', function test( t ) { for ( i = 0; i < 1e3; i++ ) { x = -( randu()*100.0 ) - EPS; v = heaviside( x ); - t.equal( isPositiveZero( v ), true, 'returns 0 when provided '+x ); + t.equal( isPositiveZero( v ), true, 'returns expected value when provided '+x ); } t.end(); }); @@ -59,7 +59,7 @@ tape( 'the function returns `1` if `x` is positive', function test( t ) { for ( i = 0; i < 1e3; i++ ) { x = ( randu()*100.0 ) + EPS; v = heaviside( x ); - t.equal( v, 1.0, 'returns 1 when provided '+x ); + t.equal( v, 1.0, 'returns expected value when provided '+x ); } t.end(); }); @@ -68,10 +68,10 @@ tape( 'by default, the function returns `NaN` if provided `+-0`', function test( var v; v = heaviside( -0.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = heaviside( +0.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -80,10 +80,10 @@ tape( 'if the `continuity` option is `half-maximum`, the function returns `0.5` var v; v = heaviside( -0.0, 'half-maximum' ); - t.equal( v, 0.5, 'returns 1/2' ); + t.equal( v, 0.5, 'returns expected value' ); v = heaviside( +0.0, 'half-maximum' ); - t.equal( v, 0.5, 'returns 1/2' ); + t.equal( v, 0.5, 'returns expected value' ); t.end(); }); @@ -92,10 +92,10 @@ tape( 'if the `continuity` option is `left-continuous`, the function returns `0. var v; v = heaviside( -0.0, 'left-continuous' ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); v = heaviside( +0.0, 'left-continuous' ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); @@ -104,28 +104,28 @@ tape( 'if the `continuity` option is `right-continuous`, the function returns `1 var v; v = heaviside( -0.0, 'right-continuous' ); - t.equal( v, 1, 'returns 1' ); + t.equal( v, 1, 'returns expected value' ); v = heaviside( +0.0, 'right-continuous' ); - t.equal( v, 1, 'returns 1' ); + t.equal( v, 1, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = heaviside( 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 `-infinity`', function test( t ) { var v = heaviside( NINF ); - t.equal( v, 0.0, 'returns 0' ); + t.equal( v, 0.0, 'returns expected value' ); t.end(); }); tape( 'the function returns `+1` if provided `+infinity`', function test( t ) { var v = heaviside( PINF ); - t.equal( v, 1.0, 'returns 1' ); + t.equal( v, 1.0, 'returns expected value' ); t.end(); });