diff --git a/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/benchmark.js index 201c0a1a012d..4924732f25af 100644 --- a/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/flipsignf/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 flipsignf = require( './../lib' ); @@ -35,11 +35,16 @@ bench( pkg, function benchmark( b ) { var z; var i; + x = uniform( 100, -5.0e6, 5.0e6, { + 'dtype': 'float32' + }); + y = uniform( 100, -5.0e6, 5.0e6, { + 'dtype': 'float32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1.0e7 ) - 5.0e6; - y = ( randu()*1.0e7 ) - 5.0e6; - z = flipsignf( x, y ); + z = flipsignf( x[ i%x.length ], y[ i%y.length ] ); if ( isnanf( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/benchmark.native.js index 0ab8df63f5e9..bfca1c464e4a 100644 --- a/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/flipsignf/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; @@ -44,11 +44,16 @@ bench( pkg+'::native', opts, function benchmark( b ) { var z; var i; + x = uniform( 100, -5.0e6, 5.0e6, { + 'dtype': 'float32' + }); + y = uniform( 100, -5.0e6, 5.0e6, { + 'dtype': 'float32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1.0e7 ) - 5.0e6; - y = ( randu()*1.0e7 ) - 5.0e6; - z = flipsignf( x, y ); + z = flipsignf( x[ i%x.length ], y[ i%y.length ] ); if ( isnanf( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/c/native/benchmark.c index 465f605565ce..97bf3efc2a57 100644 --- a/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/flipsignf/benchmark/c/native/benchmark.c @@ -92,16 +92,19 @@ static float rand_float( void ) { static double benchmark( void ) { double elapsed; double t; - float x; - float y; + float x[ 100 ]; + float y[ 100 ]; float z; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( rand_float()*1000.0f ) - 500.0f; + y[ i ] = ( rand_float()*1000.0f ) - 500.0f; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0f*rand_float() ) - 500.0f; - y = ( 1000.0f*rand_float() ) - 500.0f; - z = stdlib_base_flipsignf( x, y ); + z = stdlib_base_flipsignf( x[ i%100 ], y[ i%100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.js b/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.js index 258baacc632c..c0be41792260 100644 --- a/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.js @@ -63,10 +63,10 @@ tape( 'if `x` is `NaN`, the function returns `NaN`', function test( t ) { var z; z = flipsignf( NaN, -1.0 ); - t.equal( isnanf( z ), true, 'returns NaN' ); + t.equal( isnanf( z ), true, 'returns expected value' ); z = flipsignf( NaN, 1.0 ); - t.equal( isnanf( z ), true, 'returns NaN' ); + t.equal( isnanf( z ), true, 'returns expected value' ); t.end(); }); @@ -75,10 +75,10 @@ tape( 'if `y` is `NaN`, the function could (theoretically) return either a posit var z; z = flipsignf( -1.0, NaN ); - t.equal( isnanf( z ), false, 'does not return NaN' ); + t.equal( isnanf( z ), false, 'returns expected value' ); z = flipsignf( 1.0, NaN ); - t.equal( isnanf( z ), false, 'does not return NaN' ); + t.equal( isnanf( z ), false, 'returns expected value' ); t.end(); }); @@ -87,10 +87,10 @@ tape( 'if `x` is `+infinity`, the function returns an infinite number', function var z; z = flipsignf( PINF, -1.0 ); - t.equal( z, NINF, 'returns -infinity' ); + t.equal( z, NINF, 'returns expected value' ); z = flipsignf( PINF, 1.0 ); - t.equal( z, PINF, 'returns +infinity' ); + t.equal( z, PINF, 'returns expected value' ); t.end(); }); @@ -99,10 +99,10 @@ tape( 'if `y` is `+infinity`, the function returns `x`', function test( t ) { var z; z = flipsignf( -1.0, PINF ); - t.equal( z, -1.0, 'returns -1' ); + t.equal( z, -1.0, 'returns expected value' ); z = flipsignf( 1.0, PINF ); - t.equal( z, 1.0, 'returns +1' ); + t.equal( z, 1.0, 'returns expected value' ); t.end(); }); @@ -111,10 +111,10 @@ tape( 'if `x` is `-infinity`, the function returns an infinite number', function var z; z = flipsignf( NINF, -1.0 ); - t.equal( z, PINF, 'returns +infinity' ); + t.equal( z, PINF, 'returns expected value' ); z = flipsignf( NINF, 1.0 ); - t.equal( z, NINF, 'returns -infinity' ); + t.equal( z, NINF, 'returns expected value' ); t.end(); }); @@ -123,10 +123,10 @@ tape( 'if `y` is `-infinity`, the function returns `-x`', function test( t ) { var z; z = flipsignf( -1.0, NINF ); - t.equal( z, +1.0, 'returns +1' ); + t.equal( z, +1.0, 'returns expected value' ); z = flipsignf( 1.0, NINF ); - t.equal( z, -1.0, 'returns -1' ); + t.equal( z, -1.0, 'returns expected value' ); t.end(); }); @@ -138,10 +138,10 @@ tape( 'the function supports using `+-0` to flip a sign', function test( t ) { x = 3.0; z = flipsignf( x, 0.0 ); - t.equal( z, 3.0, 'returns +3.0' ); + t.equal( z, 3.0, 'returns expected value' ); z = flipsignf( x, -0.0 ); - t.equal( z, -3.0, 'returns -3.0' ); + t.equal( z, -3.0, 'returns expected value' ); t.end(); }); @@ -150,16 +150,16 @@ tape( 'the function supports `x` being `+-0`', function test( t ) { var z; z = flipsignf( -0.0, 1.0 ); - t.equal( isNegativeZerof( z ), true, 'returns -0' ); + t.equal( isNegativeZerof( z ), true, 'returns expected value' ); z = flipsignf( -0.0, -1.0 ); - t.equal( isPositiveZerof( z ), true, 'returns +0' ); + t.equal( isPositiveZerof( z ), true, 'returns expected value' ); z = flipsignf( 0.0, 1.0 ); - t.equal( isPositiveZerof( z ), true, 'returns +0' ); + t.equal( isPositiveZerof( z ), true, 'returns expected value' ); z = flipsignf( 0.0, -1.0 ); - t.equal( isNegativeZerof( z ), true, 'returns -0' ); + t.equal( isNegativeZerof( z ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.native.js index e5e6cbaad52d..3ef5a68d3e1e 100644 --- a/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/flipsignf/test/test.native.js @@ -72,10 +72,10 @@ tape( 'if `x` is `NaN`, the function returns `NaN`', opts, function test( t ) { var z; z = flipsignf( NaN, -1.0 ); - t.equal( isnanf( z ), true, 'returns NaN' ); + t.equal( isnanf( z ), true, 'returns expected value' ); z = flipsignf( NaN, 1.0 ); - t.equal( isnanf( z ), true, 'returns NaN' ); + t.equal( isnanf( z ), true, 'returns expected value' ); t.end(); }); @@ -84,10 +84,10 @@ tape( 'if `y` is `NaN`, the function could (theoretically) return either a posit var z; z = flipsignf( -1.0, NaN ); - t.equal( isnanf( z ), false, 'does not return NaN' ); + t.equal( isnanf( z ), false, 'returns expected value' ); z = flipsignf( 1.0, NaN ); - t.equal( isnanf( z ), false, 'does not return NaN' ); + t.equal( isnanf( z ), false, 'returns expected value' ); t.end(); }); @@ -96,10 +96,10 @@ tape( 'if `x` is `+infinity`, the function returns an infinite number', opts, fu var z; z = flipsignf( PINF, -1.0 ); - t.equal( z, NINF, 'returns -infinity' ); + t.equal( z, NINF, 'returns expected value' ); z = flipsignf( PINF, 1.0 ); - t.equal( z, PINF, 'returns +infinity' ); + t.equal( z, PINF, 'returns expected value' ); t.end(); }); @@ -108,10 +108,10 @@ tape( 'if `y` is `+infinity`, the function returns `x`', opts, function test( t var z; z = flipsignf( -1.0, PINF ); - t.equal( z, -1.0, 'returns -1' ); + t.equal( z, -1.0, 'returns expected value' ); z = flipsignf( 1.0, PINF ); - t.equal( z, 1.0, 'returns +1' ); + t.equal( z, 1.0, 'returns expected value' ); t.end(); }); @@ -120,10 +120,10 @@ tape( 'if `x` is `-infinity`, the function returns an infinite number', opts, fu var z; z = flipsignf( NINF, -1.0 ); - t.equal( z, PINF, 'returns +infinity' ); + t.equal( z, PINF, 'returns expected value' ); z = flipsignf( NINF, 1.0 ); - t.equal( z, NINF, 'returns -infinity' ); + t.equal( z, NINF, 'returns expected value' ); t.end(); }); @@ -132,10 +132,10 @@ tape( 'if `y` is `-infinity`, the function returns `-x`', opts, function test( t var z; z = flipsignf( -1.0, NINF ); - t.equal( z, +1.0, 'returns +1' ); + t.equal( z, +1.0, 'returns expected value' ); z = flipsignf( 1.0, NINF ); - t.equal( z, -1.0, 'returns -1' ); + t.equal( z, -1.0, 'returns expected value' ); t.end(); }); @@ -147,10 +147,10 @@ tape( 'the function supports using `+-0` to flip a sign', opts, function test( t x = 3.0; z = flipsignf( x, 0.0 ); - t.equal( z, 3.0, 'returns +3.0' ); + t.equal( z, 3.0, 'returns expected value' ); z = flipsignf( x, -0.0 ); - t.equal( z, -3.0, 'returns -3.0' ); + t.equal( z, -3.0, 'returns expected value' ); t.end(); }); @@ -159,16 +159,16 @@ tape( 'the function supports `x` being `+-0`', opts, function test( t ) { var z; z = flipsignf( -0.0, 1.0 ); - t.equal( isNegativeZerof( z ), true, 'returns -0' ); + t.equal( isNegativeZerof( z ), true, 'returns expected value' ); z = flipsignf( -0.0, -1.0 ); - t.equal( isPositiveZerof( z ), true, 'returns +0' ); + t.equal( isPositiveZerof( z ), true, 'returns expected value' ); z = flipsignf( 0.0, 1.0 ); - t.equal( isPositiveZerof( z ), true, 'returns +0' ); + t.equal( isPositiveZerof( z ), true, 'returns expected value' ); z = flipsignf( 0.0, -1.0 ); - t.equal( isNegativeZerof( z ), true, 'returns -0' ); + t.equal( isNegativeZerof( z ), true, 'returns expected value' ); t.end(); });