diff --git a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/acos/benchmark/benchmark.js index 01722c44ccc5..09ec2b5f0802 100644 --- a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/acos/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 acos = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, -1.0, 1.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*2.0 ) - 1.0; - y = acos( x ); + y = acos( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -55,10 +56,11 @@ bench( pkg+'::built-in', function benchmark( b ) { var y; var i; + x = uniform( 100, -1.0, 1.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*2.0 ) - 1.0; - y = Math.acos( x ); // eslint-disable-line stdlib/no-builtin-math + y = Math.acos( x[ i % x.length ] ); // eslint-disable-line stdlib/no-builtin-math if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/acos/benchmark/benchmark.native.js index b0cfb35d4a0f..9bde49a371e5 100644 --- a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acos/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, -1.0, 1.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*2.0 ) - 1.0; - y = acos( x ); + y = acos( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/benchmark.c index 597d3bed70fe..69b01ca7bd06 100644 --- a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/benchmark.c @@ -89,16 +89,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 ] = ( 2.0*rand_double() ) - 1.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 2.0*rand_double() ) - 1.0; - y = acos( x ); + y = acos( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/cephes/benchmark.c index fd6fc9e3f24d..57a81dd626f4 100644 --- a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/cephes/benchmark.c @@ -94,16 +94,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 ] = ( 2.0*rand_double() ) - 1.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 2.0*rand_double() ) - 1.0; - y = acos( x ); + y = acos( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/native/benchmark.c index 68a0be90e181..48550b071cc1 100644 --- a/lib/node_modules/@stdlib/math/base/special/acos/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/acos/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 ] = ( 2.0*rand_double() ) - 1.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 2.0*rand_double() ) - 1.0; - y = stdlib_base_acos( x ); + y = stdlib_base_acos( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/acos/test/test.js b/lib/node_modules/@stdlib/math/base/special/acos/test/test.js index 68419387238f..c3e034c3c74d 100644 --- a/lib/node_modules/@stdlib/math/base/special/acos/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/acos/test/test.js @@ -117,7 +117,7 @@ tape( 'the function computes the arccosine (small positive numbers)', function t tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) { var v = acos( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -126,7 +126,7 @@ tape( 'the function returns `NaN` if provided a value less than `-1`', function var i; for ( i = 0; i < 1e4; i++ ) { v = -(randu()*1.0e6) - (1.0+EPS); - t.equal( isnan( acos( v ) ), true, 'returns NaN when provided '+v ); + t.equal( isnan( acos( v ) ), true, 'returns expected value when provided '+v ); } t.end(); }); @@ -136,7 +136,7 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', functi var i; for ( i = 0; i < 1e4; i++ ) { v = (randu()*1.0e6) + 1.0 + EPS; - t.equal( isnan( acos( v ) ), true, 'returns NaN when provided '+v ); + t.equal( isnan( acos( v ) ), true, 'returns expected value when provided '+v ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/acos/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/acos/test/test.native.js index 95563832606e..b3f90b231a21 100644 --- a/lib/node_modules/@stdlib/math/base/special/acos/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acos/test/test.native.js @@ -126,7 +126,7 @@ tape( 'the function computes the arccosine (small positive numbers)', opts, func tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t ) { var v = acos( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -135,7 +135,7 @@ tape( 'the function returns `NaN` if provided a value less than `-1`', opts, fun var i; for ( i = 0; i < 1e4; i++ ) { v = -(randu()*1.0e6) - (1.0+EPS); - t.equal( isnan( acos( v ) ), true, 'returns NaN when provided '+v ); + t.equal( isnan( acos( v ) ), true, 'returns expected value when provided '+v ); } t.end(); }); @@ -145,7 +145,7 @@ tape( 'the function returns `NaN` if provided a value greater than `+1`', opts, var i; for ( i = 0; i < 1e4; i++ ) { v = (randu()*1.0e6) + 1.0 + EPS; - t.equal( isnan( acos( v ) ), true, 'returns NaN when provided '+v ); + t.equal( isnan( acos( v ) ), true, 'returns expected value when provided '+v ); } t.end(); });