diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/benchmark.js index 41047d5eec8e..1fb90c0053ee 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/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 sqrt = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrt( x ); + y = sqrt( 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, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = Math.sqrt( x ); // eslint-disable-line stdlib/no-builtin-math + y = Math.sqrt( 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/sqrt/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/benchmark.native.js index 70a694022ea9..bc76dce34ffe 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/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, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrt( x ); + y = sqrt( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/benchmark.c index 1ae4fcad6413..14553ed266d5 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/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 ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = sqrt( x ); + y = sqrt( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/cephes/benchmark.c index d2d086df3c08..f6a067286fe0 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/cephes/benchmark.c @@ -96,16 +96,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 ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = sqrt( x ); + y = sqrt( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/native/benchmark.c index cc80bc617917..2df6cdd571d8 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/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 ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double() * 100000.0; - y = stdlib_base_sqrt( x ); + y = stdlib_base_sqrt( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.js b/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.js index e0250e038094..fa713c4f38c7 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.js @@ -237,48 +237,48 @@ tape( 'the function evaluates the principal square root of `x` (huge positive)', tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrt( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { var v = sqrt( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', function test( t ) { var v = sqrt( +0.0 ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', function test( t ) { var v = sqrt( -0.0 ); - t.equal( isNegativeZero( v ), true, 'returns -0' ); + t.equal( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', function test( t ) { var v = sqrt( -4.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrt( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', function test( t ) { var v = sqrt( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { var v = sqrt( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.native.js index 127bb21a8f64..93b2c016f945 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/test/test.native.js @@ -246,48 +246,48 @@ tape( 'the function evaluates the principal square root of `x` (huge positive)', tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrt( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = sqrt( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { var v = sqrt( +0.0 ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v = sqrt( -0.0 ); - t.equal( isNegativeZero( v ), true, 'returns -0' ); + t.equal( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) { var v = sqrt( -4.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrt( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', opts, function test( t ) { var v = sqrt( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = sqrt( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/benchmark.js index 6314f50c6859..ce7f72f8863c 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/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 sqrt1pm1 = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrt1pm1( x ); + y = sqrt1pm1( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/benchmark.native.js index 1dd0c3739954..97638745802b 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/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, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrt1pm1( x ); + y = sqrt1pm1( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/c/native/benchmark.c index 657c20c7baee..c79d51aba28a 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/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 ] = rand_double() * 100000.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*100000.0 ) - 0.0; - y = stdlib_base_sqrt1pm1( x ); + y = stdlib_base_sqrt1pm1( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/cpp/boost/benchmark.cpp b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/cpp/boost/benchmark.cpp index e57afa78ec42..712348485ce6 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/cpp/boost/benchmark.cpp +++ b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/benchmark/cpp/boost/benchmark.cpp @@ -85,8 +85,8 @@ double tic() { * @return elapsed time in seconds */ double benchmark() { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; @@ -97,10 +97,13 @@ double benchmark() { // Define a uniform distribution for generating pseudorandom numbers as "doubles" between a minimum value (inclusive) and a maximum value (exclusive): uniform_real_distribution<> randu( 0.0, 100000.0 ); + for ( i = 0; i < 100; i++ ) { + x[ i ] = randu( rng ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = randu( rng ); - y = boost::math::sqrt1pm1( x ); + y = boost::math::sqrt1pm1( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.js b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.js index 1e807fcdf8a5..896ea8892c84 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.js @@ -44,35 +44,35 @@ tape( 'main export is a function', function test( t ) { tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrt1pm1( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { var v = sqrt1pm1( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `0` if provided `0`', function test( t ) { var v = sqrt1pm1( 0.0 ); - t.equal( v, 0.0, 'returns zero' ); + t.equal( v, 0.0, 'returns expected value' ); t.end(); }); tape( 'the function returns `-1` if provided `-1`', function test( t ) { var v = sqrt1pm1( -1.0 ); - t.equal( v, -1.0, 'returns negative one' ); + t.equal( v, -1.0, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a `x < -1`', function test( t ) { var v = sqrt1pm1( -1.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); sqrt1pm1( -2.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); sqrt1pm1( -3.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.native.js index 21dd3c66496c..a1d00266113b 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrt1pm1/test/test.native.js @@ -53,35 +53,35 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrt1pm1( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = sqrt1pm1( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `0` if provided `0`', opts, function test( t ) { var v = sqrt1pm1( 0.0 ); - t.equal( v, 0.0, 'returns zero' ); + t.equal( v, 0.0, 'returns expected value' ); t.end(); }); tape( 'the function returns `-1` if provided `-1`', opts, function test( t ) { var v = sqrt1pm1( -1.0 ); - t.equal( v, -1.0, 'returns negative one' ); + t.equal( v, -1.0, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a `x < -1`', opts, function test( t ) { var v = sqrt1pm1( -1.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); sqrt1pm1( -2.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); sqrt1pm1( -3.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/benchmark.js index f58b3b0d5fcb..feeeb1dd0778 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/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 sqrtf = require( './../lib' ); @@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0, { + 'dtype': 'float32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrtf( x ); + y = sqrtf( x[ i % x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/benchmark.native.js index 1e8a86f9074a..75175d51edf1 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/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, 0.0, 100000.0, { + 'dtype': 'float32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrtf( x ); + y = sqrtf( x[ i % x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/c/benchmark.c index 1934af72d7dd..764cd323811e 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/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; - float x; - float y; double t; + float y; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_float() * 100000.0f; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_float() * 100000.0f; - y = sqrtf( x ); + y = sqrtf( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/c/native/benchmark.c index dd5893ec791f..34fedf3b48de 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/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; - float x; - float y; double t; + float y; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = rand_float() * 100000.0f; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_float() * 100000.0f; - y = stdlib_base_sqrtf( x ); + y = stdlib_base_sqrtf( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.js b/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.js index a06f2a483a2a..29f17304f5a3 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.js @@ -237,48 +237,48 @@ tape( 'the function evaluates the principal square root of `x` (huge positive)', tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrtf( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { var v = sqrtf( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', function test( t ) { var v = sqrtf( +0.0 ); - t.equal( isPositiveZerof( v ), true, 'returns 0' ); + t.equal( isPositiveZerof( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', function test( t ) { var v = sqrtf( -0.0 ); - t.equal( isNegativeZerof( v ), true, 'returns -0' ); + t.equal( isNegativeZerof( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', function test( t ) { var v = sqrtf( -4.0 ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrtf( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', function test( t ) { var v = sqrtf( NINF ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { var v = sqrtf( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.native.js index 03ef9501d04f..338aba8cc1bc 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/test/test.native.js @@ -246,48 +246,48 @@ tape( 'the function evaluates the principal square root of `x` (huge positive)', tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrtf( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = sqrtf( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { var v = sqrtf( +0.0 ); - t.equal( isPositiveZerof( v ), true, 'returns 0' ); + t.equal( isPositiveZerof( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v = sqrtf( -0.0 ); - t.equal( isNegativeZerof( v ), true, 'returns -0' ); + t.equal( isNegativeZerof( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) { var v = sqrtf( -4.0 ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrtf( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', opts, function test( t ) { var v = sqrtf( NINF ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = sqrtf( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/benchmark.js index 84040d237579..4d620cb1eea4 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/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 sqrtpi = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrtpi( x ); + y = sqrtpi( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/benchmark.native.js index d5b0c8ed13ae..398aeb7876ef 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/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, 0.0, 100000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; - y = sqrtpi( x ); + y = sqrtpi( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/c/native/benchmark.c index 55e3bad65f98..dc7f3dc32eff 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/benchmark/c/native/benchmark.c @@ -74,22 +74,35 @@ static double tic( void ) { return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + /** * Runs a benchmark. * * @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 ] = 100000.0 * rand_double(); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( (double)rand() * 100000.0 ) - 0.0; - y = stdlib_base_sqrtpi( x ); + y = stdlib_base_sqrtpi( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js index dd88f5eef17e..4b36dcee43b7 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js @@ -237,42 +237,42 @@ tape( 'the function evaluates the principal square root for huge positive number tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrtpi( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { var v = sqrtpi( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', function test( t ) { var v = sqrtpi( +0.0 ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', function test( t ) { var v = sqrtpi( -0.0 ); - t.equal( isNegativeZero( v ), true, 'returns -0' ); + t.equal( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', function test( t ) { var v = sqrtpi( -4.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrtpi( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', function test( t ) { var v = sqrtpi( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js index 6c9dd656d93e..1b398f8efabd 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js @@ -246,42 +246,42 @@ tape( 'the function evaluates the principal square root for huge positive number tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrtpi( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = sqrtpi( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { var v = sqrtpi( +0.0 ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v = sqrtpi( -0.0 ); - t.equal( isNegativeZero( v ), true, 'returns -0' ); + t.equal( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) { var v = sqrtpi( -4.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrtpi( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', opts, function test( t ) { var v = sqrtpi( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.js index dc25dabc0cc8..5c318b34ff11 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pkg = require( './../package.json' ).name; var sqrtpif = require( './../lib' ); @@ -34,7 +34,9 @@ bench( pkg, function benchmark( b ) { var y; var i; - x = randu( 100, 0.0, 100000.0 ); + x = uniform( 100, 0.0, 100000.0, { + 'dtype': 'float32' + }); b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.native.js index 6cd3cb237a34..1d12c6acbf44 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/array/discrete-uniform' ); +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,7 +43,9 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; - x = randu( 100, 0.0, 100000.0 ); + x = uniform( 100, 0.0, 100000.0, { + 'dtype': 'float32' + }); b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/c/benchmark.c index 00bcb0234332..a1f1e21f483d 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpif/benchmark/c/benchmark.c @@ -90,19 +90,19 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { - double elapsed; float x[ 100 ]; + double elapsed; double t; float y; int i; for ( i = 0; i < 100; i++ ) { - x[ i ] = ( 100000.0f * rand_float() ); + x[ i ] = 100000.0f * rand_float(); } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_sqrtpif( x[ i % 100 ] ); + y = stdlib_base_sqrtpif( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpif/test/test.js b/lib/node_modules/@stdlib/math/base/special/sqrtpif/test/test.js index 87ead75aefab..8a475b677bd1 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpif/test/test.js @@ -237,42 +237,42 @@ tape( 'the function evaluates the principal square root for huge positive number tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrtpif( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { var v = sqrtpif( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', function test( t ) { var v = sqrtpif( +0.0 ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', function test( t ) { var v = sqrtpif( -0.0 ); - t.equal( isNegativeZero( v ), true, 'returns -0' ); + t.equal( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', function test( t ) { var v = sqrtpif( -4.0 ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = sqrtpif( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', function test( t ) { var v = sqrtpif( NINF ); - 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/sqrtpif/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtpif/test/test.native.js index ea8333fe97a2..4101b07f912e 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpif/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpif/test/test.native.js @@ -246,42 +246,42 @@ tape( 'the function evaluates the principal square root for huge positive number tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrtpif( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = sqrtpif( PINF ); - t.equal( v, PINF, 'returns +infinity' ); + t.equal( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { var v = sqrtpif( +0.0 ); - t.equal( isPositiveZero( v ), true, 'returns 0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v = sqrtpif( -0.0 ); - t.equal( isNegativeZero( v ), true, 'returns -0' ); + t.equal( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) { var v = sqrtpif( -4.0 ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = sqrtpif( NaN ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided `-infinity`', opts, function test( t ) { var v = sqrtpif( NINF ); - t.equal( isnanf( v ), true, 'returns NaN' ); + t.equal( isnanf( v ), true, 'returns expected value' ); t.end(); });