From b9a33e9945a9c21f54cb366585dbe0ac3abf5818 Mon Sep 17 00:00:00 2001 From: hrshya Date: Tue, 25 Mar 2025 23:49:25 +0530 Subject: [PATCH] bench: update random value generation --- .../math/base/special/log10/benchmark/benchmark.js | 12 +++++++----- .../special/log10/benchmark/benchmark.native.js | 7 ++++--- .../math/base/special/log10/benchmark/c/benchmark.c | 9 ++++++--- .../special/log10/benchmark/c/cephes/benchmark.c | 9 ++++++--- .../special/log10/benchmark/c/native/benchmark.c | 9 ++++++--- .../@stdlib/math/base/special/log10/test/test.js | 8 ++++---- .../math/base/special/log10/test/test.native.js | 8 ++++---- .../base/special/log1pexp/benchmark/benchmark.js | 7 ++++--- .../special/log1pexp/benchmark/benchmark.native.js | 7 ++++--- .../base/special/log1pexp/benchmark/c/benchmark.c | 9 ++++++--- .../special/log1pexp/benchmark/c/native/benchmark.c | 9 ++++++--- .../@stdlib/math/base/special/log1pexp/test/test.js | 2 +- .../math/base/special/log1pexp/test/test.natve.js | 2 +- .../base/special/log1pmx/benchmark/benchmark.js | 7 ++++--- .../base/special/log1pmx/benchmark/c/benchmark.c | 9 ++++++--- .../math/base/special/log2/benchmark/benchmark.js | 12 +++++++----- .../base/special/log2/benchmark/benchmark.native.js | 7 ++++--- .../math/base/special/log2/benchmark/c/benchmark.c | 9 ++++++--- .../special/log2/benchmark/c/cephes/benchmark.c | 9 ++++++--- .../special/log2/benchmark/c/native/benchmark.c | 9 ++++++--- .../@stdlib/math/base/special/log2/test/test.js | 8 ++++---- .../math/base/special/log2/test/test.native.js | 8 ++++---- .../base/special/logaddexp/benchmark/benchmark.js | 9 +++++---- .../special/logaddexp/benchmark/benchmark.native.js | 9 +++++---- .../base/special/logaddexp/benchmark/c/benchmark.c | 13 ++++++++----- .../logaddexp/benchmark/c/native/benchmark.c | 13 ++++++++----- 26 files changed, 132 insertions(+), 88 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/benchmark.js index 42b5dda9afd4..12f3141ce44c 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/log10/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 log10 = require( './../lib' ); @@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 0.0; - y = log10( x ); + y = log10( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -62,10 +63,11 @@ bench( pkg+'::built-in', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 0.0; - y = Math.log10( x ); // eslint-disable-line stdlib/no-builtin-math + y = Math.log10( 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/log10/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/benchmark.native.js index 8818b8d85d54..d9a864fe1e07 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log10/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, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 0.0; - y = log10( x ); + y = log10( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/benchmark.c index f9342de463c6..3d01990d471b 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/benchmark.c @@ -90,15 +90,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 0.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 0.0; - y = log10( x ); + y = log10( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/cephes/benchmark.c index dd152eb071fa..ce56d8bb0653 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/cephes/benchmark.c @@ -95,15 +95,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 0.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 0.0; - y = log10( x ); + y = log10( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/native/benchmark.c index c553ea392429..6045c7d623b3 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log10/benchmark/c/native/benchmark.c @@ -91,15 +91,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 0.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 0.0; - y = stdlib_base_log10( x ); + y = stdlib_base_log10( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log10/test/test.js b/lib/node_modules/@stdlib/math/base/special/log10/test/test.js index 2e7b53554d9e..66805bcf9cae 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/log10/test/test.js @@ -211,23 +211,23 @@ tape( 'the function evaluates the common logarithm of `x` (subnormal values)', f }); tape( 'the function returns `-infinity` if provided `0`', function test( t ) { - t.equal( log10( 0.0 ), NINF, 'equals -infinity' ); + t.equal( log10( 0.0 ), NINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { - t.equal( log10( PINF ), PINF, 'equals +infinity' ); + t.equal( log10( PINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', function test( t ) { var v = log10( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns positive zero if provided `1.0`', function test( t ) { var v = log10( 1.0 ); - t.equal( isPositiveZero( v ), true, 'returns +0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js index 441dac4b0879..0fe0b180bf3e 100644 --- a/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log10/test/test.native.js @@ -220,23 +220,23 @@ tape( 'the function evaluates the common logarithm of `x` (subnormal values)', o }); tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) { - t.equal( log10( 0.0 ), NINF, 'equals -infinity' ); + t.equal( log10( 0.0 ), NINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { - t.equal( log10( PINF ), PINF, 'equals +infinity' ); + t.equal( log10( PINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) { var v = log10( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns positive zero if provided `1.0`', opts, function test( t ) { var v = log10( 1.0 ); - t.equal( isPositiveZero( v ), true, 'returns +0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/benchmark.js index 783223ac4b1d..c4f7e2751cc0 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/log1pexp/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 log1pexp = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, -500.0, 500.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = log1pexp( x ); + y = log1pexp( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/benchmark.native.js index 95081e60ce2b..8acdb86201d5 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log1pexp/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, -500.0, 500.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = log1pexp( x ); + y = log1pexp( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/benchmark.c index 922041c26a33..71c83ed74635 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/benchmark.c @@ -111,15 +111,18 @@ double log1pexp( double x ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 500.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; - y = log1pexp( x ); + y = log1pexp( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/native/benchmark.c index b68946f67cdc..01734827808d 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log1pexp/benchmark/c/native/benchmark.c @@ -91,15 +91,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 500.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; - y = stdlib_base_log1pexp( x ); + y = stdlib_base_log1pexp( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.js b/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.js index a6737a846743..4bcb58886ee1 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.js @@ -45,7 +45,7 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var v = log1pexp( NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN when provided a NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.natve.js b/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.natve.js index b1203f35d53d..53493cacbdbc 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.natve.js +++ b/lib/node_modules/@stdlib/math/base/special/log1pexp/test/test.natve.js @@ -54,7 +54,7 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { var v = log1pexp( NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN when provided a NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log1pmx/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/log1pmx/benchmark/benchmark.js index 65f40b0a9852..27966fbe5fd7 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pmx/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/log1pmx/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 log1pmx = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, -1.0, 99.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100.0 ) - 1.0; - y = log1pmx( x ); + y = log1pmx( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/log1pmx/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log1pmx/benchmark/c/benchmark.c index 5a1a4f7c49e3..55993ba9e803 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pmx/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log1pmx/benchmark/c/benchmark.c @@ -110,15 +110,18 @@ double log1pmx( double x ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 0.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 0.0; - y = log1pmx( x ); + y = log1pmx( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/benchmark.js index b8ee88ad52f4..a438f2925759 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/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 log2 = require( './../lib' ); @@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 0.0; - y = log2( x ); + y = log2( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -62,10 +63,11 @@ bench( pkg+'::built-in', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, 0.0, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 0.0; - y = Math.log2( x ); // eslint-disable-line stdlib/no-builtin-math + y = Math.log2( 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/log2/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/benchmark.native.js index ebdc3e9396aa..935fa1712fa0 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/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, 1000.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 0.0; - y = log2( x ); + y = log2( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/benchmark.c index b935e960308e..b8e69fac155d 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/benchmark.c @@ -90,15 +90,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 0.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 0.0; - y = log2( x ); + y = log2( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/cephes/benchmark.c index bb52f3cbcbe5..ec7c351f137d 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/cephes/benchmark.c @@ -95,15 +95,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 0.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 0.0; - y = log2( x ); + y = log2( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c index c715c0f5c89b..0789fa6a32af 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c @@ -91,15 +91,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; + double x[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 0.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 0.0; - y = stdlib_base_log2( x ); + y = stdlib_base_log2( x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/log2/test/test.js b/lib/node_modules/@stdlib/math/base/special/log2/test/test.js index 6c38bfd320fe..f87ef530a3e7 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/test/test.js @@ -211,23 +211,23 @@ tape( 'the function evaluates the binary logarithm of `x` (subnormal values)', f }); tape( 'the function returns `-infinity` if provided `0`', function test( t ) { - t.equal( log2( 0.0 ), NINF, 'equals -infinity' ); + t.equal( log2( 0.0 ), NINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { - t.equal( log2( PINF ), PINF, 'equals +infinity' ); + t.equal( log2( PINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', function test( t ) { var v = log2( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns positive zero if provided `1.0`', function test( t ) { var v = log2( 1.0 ); - t.equal( isPositiveZero( v ), true, 'returns +0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js index 7bcb2226e842..fe115c3d93b1 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/test/test.native.js @@ -220,23 +220,23 @@ tape( 'the function evaluates the binary logarithm of `x` (subnormal values)', o }); tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) { - t.equal( log2( 0.0 ), NINF, 'equals -infinity' ); + t.equal( log2( 0.0 ), NINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { - t.equal( log2( PINF ), PINF, 'equals +infinity' ); + t.equal( log2( PINF ), PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) { var v = log2( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns positive zero if provided `1.0`', opts, function test( t ) { var v = log2( 1.0 ); - t.equal( isPositiveZero( v ), true, 'returns +0' ); + t.equal( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/benchmark.js index 8ff4fef33a61..b3ab15ac021f 100644 --- a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/logaddexp/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 logaddexp = require( './../lib' ); @@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) { var v; var i; + x = uniform( 100, -500.0, 500.0 ); + y = uniform( 100, -500.0, 500.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = ( randu()*1000.0 ) - 500.0; - v = logaddexp( x, y ); + v = logaddexp( x[ i%x.length ], y[ i%y.length ] ); if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/benchmark.native.js index cb15dcba1412..de835945269e 100644 --- a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/logaddexp/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; @@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) { var v; var i; + x = uniform( 100, -100.0, 100.0 ); + y = uniform( 100, -100.0, 100.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*200.0 ) - 100.0; - y = ( randu()*200.0 ) - 100.0; - v = logaddexp( x, y ); + v = logaddexp( x[ i%x.length ], y[ i%y.length ] ); if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/benchmark.c index d868455d6ace..bb7be5af954f 100644 --- a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/benchmark.c @@ -112,17 +112,20 @@ double logaddexp( double x, double y ) { */ static double benchmark( void ) { double elapsed; - double x; - double y; + double x[ 100 ]; + double y[ 100 ]; double v; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 500.0; + y[ i ] = ( 1000.0*rand_double() ) - 500.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; - y = ( 1000.0*rand_double() ) - 500.0; - v = logaddexp( x, y ); + v = logaddexp( x[ i%100 ], y[ i%100 ] ); if ( v != v ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/native/benchmark.c index a2b92784b7af..cbe885d9f747 100644 --- a/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/logaddexp/benchmark/c/native/benchmark.c @@ -92,17 +92,20 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double x; - double y; + double x[ 100 ]; + double y[ 100 ]; double v; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 200.0*rand_double() ) - 100.0;; + y[ i ] = ( 200.0*rand_double() ) - 100.0;; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 200.0*rand_double() ) - 100.0; - y = ( 200.0*rand_double() ) - 100.0; - v = stdlib_base_logaddexp( x, y ); + v = stdlib_base_logaddexp( x[ i%100 ], y[ i%100 ] ); if ( v != v ) { printf( "should not return NaN\n" ); break;