diff --git a/lib/node_modules/@stdlib/math/base/special/fast/hypot/README.md b/lib/node_modules/@stdlib/math/base/special/fast/hypot/README.md index f833b9fe66b2..529dab50f81c 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/hypot/README.md +++ b/lib/node_modules/@stdlib/math/base/special/fast/hypot/README.md @@ -86,21 +86,17 @@ var h = hypot( -5.0, 12.0 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var hypot = require( '@stdlib/math/base/special/fast/hypot' ); -var x; -var y; -var h; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 100, -50, 50, opts ); +var y = discreteUniform( 100, -50, 50, opts ); -for ( i = 0; i < 100; i++ ) { - x = round( randu()*100.0 ) - 50.0; - y = round( randu()*100.0 ) - 50.0; - h = hypot( x, y ); - console.log( 'hypot(%d,%d) = %d', x, y, h ); -} +logEachMap( 'hypot(%d,%d) = %0.4f', x, y, hypot ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/benchmark.js index 06b52a1e193c..a951ac35cfe9 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/hypot/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 hypot = require( './../lib' ); @@ -30,16 +30,21 @@ var hypot = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { + var opts; var x; var y; var h; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, -50.0, 50.0, opts ); + y = uniform( 100, -50.0, 50.0, opts ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100.0 ) - 50.0; - y = ( randu()*100.0 ) - 50.0; - h = hypot( x, y ); + h = hypot( x[ i%x.length ], y[ i%y.length ] ); if ( isnan( h ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/benchmark.native.js index 3226b2f73b66..e5ab3182632a 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/hypot/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; @@ -39,16 +39,21 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { + var opts; var x; var y; var h; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, -50.0, 50.0, opts ); + y = uniform( 100, -50.0, 50.0, opts ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 100.0 ) - 50.0; - y = ( randu() * 100.0 ) - 50.0; - h = hypot( x, y ); + h = hypot( x[ i%x.length ], y[ i%y.length ] ); if ( isnan( h ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/c/native/benchmark.c index 583440370b3d..2d179f1ed953 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/fast/hypot/benchmark/c/native/benchmark.c @@ -91,17 +91,20 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; - double y; + double x[ 100 ]; + double y[ 100 ]; double z; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 100.0 * rand_double() ) - 50.0; + y[ i ] = ( 100.0 * rand_double() ) - 50.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 100.0 * rand_double() ) - 50.0; - y = ( 100.0 * rand_double() ) - 50.0; - z = stdlib_base_fast_hypot( x, y ); + z = stdlib_base_fast_hypot( 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/fast/hypot/examples/index.js b/lib/node_modules/@stdlib/math/base/special/fast/hypot/examples/index.js index 12697534b1e4..a1ca149c205d 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/hypot/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/hypot/examples/index.js @@ -18,18 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var hypot = require( './../lib' ); -var x; -var y; -var h; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 100, -50, 50, opts ); +var y = discreteUniform( 100, -50, 50, opts ); -for ( i = 0; i < 100; i++ ) { - x = round( randu()*100.0 ) - 50.0; - y = round( randu()*100.0 ) - 50.0; - h = hypot( x, y ); - console.log( 'hypot(%d,%d) = %d', x, y, h ); -} +logEachMap( 'hypot(%d,%d) = %0.4f', x, y, hypot ); diff --git a/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.js b/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.js index a5b37a4dbd0e..30363cc64e64 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.js @@ -70,25 +70,25 @@ tape( 'the function computes the hypotenuse (canonical inputs)', function test( var h; h = hypot( 3.0, 4.0 ); - t.strictEqual( h, 5.0, 'returns 5.0' ); + t.strictEqual( h, 5.0, 'returns expected value' ); h = hypot( 6.0, 8.0 ); - t.strictEqual( h, 10.0, 'returns 10.0' ); + t.strictEqual( h, 10.0, 'returns expected value' ); h = hypot( 5.0, 12.0 ); - t.strictEqual( h, 13.0, 'returns 13.0' ); + t.strictEqual( h, 13.0, 'returns expected value' ); t.end(); }); tape( 'the function can overflow', function test( t ) { var h = hypot( 1.0e308, 1.0e308 ); - t.strictEqual( h, PINF, 'overflows' ); + t.strictEqual( h, PINF, 'returns expected value' ); t.end(); }); tape( 'the function can underflow', function test( t ) { var h = hypot( 1.0e-200, 1.0e-200 ); - t.strictEqual( h, 0.0, 'underflows' ); + t.strictEqual( h, 0.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.native.js index ef5b61693b88..576d3b1d0d39 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/hypot/test/test.native.js @@ -79,25 +79,25 @@ tape( 'the function computes the hypotenuse (canonical inputs)', opts, function var h; h = hypot( 3.0, 4.0 ); - t.strictEqual( h, 5.0, 'returns 5.0' ); + t.strictEqual( h, 5.0, 'returns expected value' ); h = hypot( 6.0, 8.0 ); - t.strictEqual( h, 10.0, 'returns 10.0' ); + t.strictEqual( h, 10.0, 'returns expected value' ); h = hypot( 5.0, 12.0 ); - t.strictEqual( h, 13.0, 'returns 13.0' ); + t.strictEqual( h, 13.0, 'returns expected value' ); t.end(); }); tape( 'the function can overflow', opts, function test( t ) { var h = hypot( 1.0e308, 1.0e308 ); - t.strictEqual( h, PINF, 'overflows' ); + t.strictEqual( h, PINF, 'returns expected value' ); t.end(); }); tape( 'the function can underflow', opts, function test( t ) { var h = hypot( 1.0e-200, 1.0e-200 ); - t.strictEqual( h, 0.0, 'underflows' ); + t.strictEqual( h, 0.0, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.js index cebe03bc24dc..f1e828736604 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.js @@ -21,9 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var floor = require( '@stdlib/math/base/special/floor' ); var pkg = require( './../package.json' ).name; var pow = require( './../lib' ); @@ -31,16 +31,21 @@ var pow = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { + var opts; var x; var y; var z; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, -50.0, 50.0, opts ); + y = discreteUniform( 100, -50.0, 50.0, opts ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100.0 ) - 50.0; - y = floor( randu()*100.0 ) - 50; - z = pow( x, y ); + z = pow( x[ i%x.length ], y[ i%y.length ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.native.js index b6ca0a6a6b6c..a2ad1b6f04ba 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/benchmark.native.js @@ -22,9 +22,9 @@ 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var floor = require( '@stdlib/math/base/special/floor' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,16 +40,21 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { + var opts; var x; var y; var z; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, -50.0, 50.0, opts ); + y = discreteUniform( 100, -50.0, 50.0, opts ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 100.0 ) - 50.0; - y = floor( randu() * 100.0 ) - 50; - z = pow( x, y ); + z = pow( x[ i%x.length ], y[ i%y.length ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/c/native/benchmark.c index bdad7c104328..a8c03d15e0d9 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/benchmark/c/native/benchmark.c @@ -91,17 +91,20 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - int32_t x; + int32_t x[ 100 ]; + double y[ 100 ]; double t; - double y; double z; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 100.0 * rand_double() ) - 50.0; + y[ i ] = floor( 100.0 * rand_double() ) - 50.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 100.0 * rand_double() ) - 50.00; - y = floor( 100.0 * rand_double() ) - 50.00; - z = stdlib_base_fast_pow( x, y ); + z = stdlib_base_fast_pow( 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/fast/pow-int/test/test.js b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.js index aadf9f745cc9..47c097dd00ab 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.js @@ -137,13 +137,13 @@ tape( 'the function returns `NaN` if provided `NaN` for the base', function test var v; v = pow( NaN, 5 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = pow( NaN, 1 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = pow( NaN, 0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -295,7 +295,7 @@ tape( 'the function returns `0` if `+infinity` is raised to any negative finite for ( i = 0; i < 100; i++ ) { y = -round( randu()*1.0e5 ) - 1; v = pow( PINF, y ); - t.strictEqual( isPositiveZero( v ), true, 'returns 0' ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); } t.end(); }); @@ -307,7 +307,7 @@ tape( 'the function returns `+infinity` if `+infinity` is raised to any positive for ( i = 0; i < 100; i++ ) { y = round( randu()*1.0e5 ) + 1; v = pow( PINF, y ); - t.strictEqual( v, PINF, 'returns +infinity' ); + t.strictEqual( v, PINF, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.native.js index 1031640f7fbb..75fd4bb75cc9 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/pow-int/test/test.native.js @@ -146,13 +146,13 @@ tape( 'the function returns `NaN` if provided `NaN` for the base', opts, functio var v; v = pow( NaN, 5 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = pow( NaN, 1 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = pow( NaN, 0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -304,7 +304,7 @@ tape( 'the function returns `0` if `+infinity` is raised to any negative finite for ( i = 0; i < 100; i++ ) { y = -round( randu() * 1.0e5 ) - 1; v = pow( PINF, y ); - t.strictEqual( isPositiveZero( v ), true, 'returns 0' ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); } t.end(); }); @@ -316,7 +316,7 @@ tape( 'the function returns `+infinity` if `+infinity` is raised to any positive for ( i = 0; i < 100; i++ ) { y = round( randu() * 1.0e5 ) + 1; v = pow( PINF, y ); - t.strictEqual( v, PINF, 'returns +infinity' ); + t.strictEqual( v, PINF, 'returns expected value' ); } t.end(); });