diff --git a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/benchmark.js index d3dbb60786b6..35d909359c30 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/absf/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 absf = require( './../lib' ); @@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = absf( x ); + y = absf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -55,10 +58,13 @@ bench( pkg+'::built-in', function benchmark( b ) { var y; var i; + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = Math.abs( x ); // eslint-disable-line stdlib/no-builtin-math + y = Math.abs( 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/absf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/benchmark.native.js index 04bf17d07802..e27de01cf625 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/absf/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,13 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = absf( x ); + y = absf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/benchmark.c index 10db8e508051..33273acf0f82 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/benchmark.c @@ -89,16 +89,19 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + float x[ 100 ]; double elapsed; double t; - float x; float y; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0f*rand_float() ) - 500.0f; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0f*rand_float() ) - 500.0f; - y = fabsf( x ); + y = fabsf( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/cephes/benchmark.c index eab870991f1f..769bfa4e7ea3 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/cephes/benchmark.c @@ -94,16 +94,19 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + float x[ 100 ]; double elapsed; double t; - float x; float y; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0f*rand_float() ) - 500.0f; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0f*rand_float() ) - 500.0f; - y = fabsf( x ); + y = fabsf( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/native/benchmark.c index a268a23642af..316779dcde00 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/absf/benchmark/c/native/benchmark.c @@ -91,16 +91,19 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + float x[ 100 ]; double elapsed; double t; - float x; float y; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0f*rand_float() ) - 500.0f; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0f*rand_float() ) - 500.0f; - y = stdlib_base_absf( x ); + y = stdlib_base_absf( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/absf/test/test.abs.js b/lib/node_modules/@stdlib/math/base/special/absf/test/test.abs.js index 2ffc04c15b75..7aff6fe91010 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/test/test.abs.js +++ b/lib/node_modules/@stdlib/math/base/special/absf/test/test.abs.js @@ -37,25 +37,25 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function computes the absolute value of a number', function test( t ) { - t.equal( absf( -2.0 ), 2.0, 'negative number' ); - t.equal( absf( 3.0 ), 3.0, 'positive number' ); - t.equal( absf( 0.0 ), 0.0, 'zero' ); + t.equal( absf( -2.0 ), 2.0, 'returns expected value' ); + t.equal( absf( 3.0 ), 3.0, 'returns expected value' ); + t.equal( absf( 0.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'the function computes the absolute value of negative zero', function test( t ) { - t.equal( isPositiveZerof( absf( -0.0 ) ), true, 'returns positive zero' ); + t.equal( isPositiveZerof( absf( -0.0 ) ), true, 'returns expected value' ); t.end(); }); tape( 'the function computes the absolute value of infinity', function test( t ) { - t.equal( absf( PINF ), PINF, 'returns +infinity' ); - t.equal( absf( NINF ), PINF, 'returns +infinity' ); + t.equal( absf( PINF ), PINF, 'returns expected value' ); + t.equal( absf( NINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var v = absf( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/absf/test/test.js b/lib/node_modules/@stdlib/math/base/special/absf/test/test.js index a510ecc8228d..9e649193f94d 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/absf/test/test.js @@ -37,25 +37,25 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function computes the absolute value of a number', function test( t ) { - t.equal( absf( -2.0 ), 2.0, 'negative number' ); - t.equal( absf( 3.0 ), 3.0, 'positive number' ); - t.equal( absf( 0.0 ), 0.0, 'zero' ); + t.equal( absf( -2.0 ), 2.0, 'returns expected value' ); + t.equal( absf( 3.0 ), 3.0, 'returns expected value' ); + t.equal( absf( 0.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'the function computes the absolute value of negative zero', function test( t ) { - t.equal( isPositiveZerof( absf( -0.0 ) ), true, 'returns positive zero' ); + t.equal( isPositiveZerof( absf( -0.0 ) ), true, 'returns expected value' ); t.end(); }); tape( 'the function computes the absolute value of infinity', function test( t ) { - t.equal( absf( PINF ), PINF, 'returns +infinity' ); - t.equal( absf( NINF ), PINF, 'returns +infinity' ); + t.equal( absf( PINF ), PINF, 'returns expected value' ); + t.equal( absf( NINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var v = absf( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/absf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/absf/test/test.native.js index bbe8d40d00b8..fa950df13d24 100644 --- a/lib/node_modules/@stdlib/math/base/special/absf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/absf/test/test.native.js @@ -46,25 +46,25 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function computes the absolute value of a number', opts, function test( t ) { - t.equal( absf( -2.0 ), 2.0, 'negative number' ); - t.equal( absf( 3.0 ), 3.0, 'positive number' ); - t.equal( absf( 0.0 ), 0.0, 'zero' ); + t.equal( absf( -2.0 ), 2.0, 'returns expected value' ); + t.equal( absf( 3.0 ), 3.0, 'returns expected value' ); + t.equal( absf( 0.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'the function computes the absolute value of negative zero', opts, function test( t ) { - t.equal( isPositiveZerof( absf( -0.0 ) ), true, 'returns positive zero' ); + t.equal( isPositiveZerof( absf( -0.0 ) ), true, 'returns expected value' ); t.end(); }); tape( 'the function computes the absolute value of infinity', opts, function test( t ) { - t.equal( absf( PINF ), PINF, 'returns +infinity' ); - t.equal( absf( NINF ), PINF, 'returns +infinity' ); + t.equal( absf( PINF ), PINF, 'returns expected value' ); + t.equal( absf( NINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { var v = absf( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); });