diff --git a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/benchmark.js index 32157f2339b0..6e207579105a 100644 --- a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/abs2f/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pkg = require( './../package.json' ).name; var abs2f = 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 = abs2f( x ); + y = abs2f( x[ i % x.length ] ); if ( isnanf( 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 = x * x; + y = x[ i % x.length ] * x[ i % x.length ]; if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/benchmark.native.js index 72e61e73746e..e4592d69a8e8 100644 --- a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/abs2f/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); 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 = abs2f( x ); + y = abs2f( x[ i % x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/benchmark.c index 7319cc67ed21..644e0cfc33f3 100644 --- a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/benchmark.c @@ -99,16 +99,19 @@ float abs2f( float x ) { * @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 = abs2f( x ); + y = abs2f( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/native/benchmark.c index 07ce3d6427a7..1153a7e6f904 100644 --- a/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/abs2f/benchmark/c/native/benchmark.c @@ -90,16 +90,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_abs2f( x ); + y = stdlib_base_abs2f( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.js index aafb6d360b76..a53a29bd3879 100644 --- a/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.js @@ -37,25 +37,25 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function computes the squared absolute value of a number', function test( t ) { - t.strictEqual( abs2f( -2.0 ), 4.0, 'negative number' ); - t.strictEqual( abs2f( 3.0 ), 9.0, 'positive number' ); - t.strictEqual( abs2f( 0.0 ), 0.0, 'zero' ); + t.strictEqual( abs2f( -2.0 ), 4.0, 'returns expected value' ); + t.strictEqual( abs2f( 3.0 ), 9.0, 'returns expected value' ); + t.strictEqual( abs2f( 0.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'the function computes the squared absolute value of negative zero', function test( t ) { - t.strictEqual( isPositiveZerof( abs2f( -0.0 ) ), true, 'returns positive zero' ); + t.strictEqual( isPositiveZerof( abs2f( -0.0 ) ), true, 'returns expected value' ); t.end(); }); tape( 'the function computes the squared absolute value of infinity', function test( t ) { - t.strictEqual( abs2f( PINF ), PINF, 'returns +infinity' ); - t.strictEqual( abs2f( NINF ), PINF, 'returns +infinity' ); + t.strictEqual( abs2f( PINF ), PINF, 'returns expected value' ); + t.strictEqual( abs2f( NINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var v = abs2f( NaN ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.native.js index aad7a22724d1..d5beff711d4e 100644 --- a/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/abs2f/test/test.native.js @@ -46,25 +46,25 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function computes the squared absolute value of a number', opts, function test( t ) { - t.strictEqual( abs2f( -2.0 ), 4.0, 'negative number' ); - t.strictEqual( abs2f( 3.0 ), 9.0, 'positive number' ); - t.strictEqual( abs2f( 0.0 ), 0.0, 'zero' ); + t.strictEqual( abs2f( -2.0 ), 4.0, 'returns expected value' ); + t.strictEqual( abs2f( 3.0 ), 9.0, 'returns expected value' ); + t.strictEqual( abs2f( 0.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'the function computes the squared absolute value of negative zero', opts, function test( t ) { - t.strictEqual( isPositiveZerof( abs2f( -0.0 ) ), true, 'returns positive zero' ); + t.strictEqual( isPositiveZerof( abs2f( -0.0 ) ), true, 'returns expected value' ); t.end(); }); tape( 'the function computes the squared absolute value of infinity', opts, function test( t ) { - t.strictEqual( abs2f( PINF ), PINF, 'returns +infinity' ); - t.strictEqual( abs2f( NINF ), PINF, 'returns +infinity' ); + t.strictEqual( abs2f( PINF ), PINF, 'returns expected value' ); + t.strictEqual( abs2f( NINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { var v = abs2f( NaN ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); t.end(); });