From 24a53eebf9eb459a4ecb26f487d9059580113c37 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 12 Aug 2024 15:40:01 +0530 Subject: [PATCH 01/17] refactor: use `stdlib_base_pow` instead of built-in Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/ldexp/examples/c/example.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c index b24357093432..f841f94fcfa3 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c @@ -19,13 +19,11 @@ #include "stdlib/math/base/special/ldexp.h" #include "stdlib/math/base/special/frexp.h" +#include "stdlib/math/base/special/pow.h" #include #include #include #include -#include - -// TODO: replace use of `pow` with stdlib_base_pow() static double rand_double() { int r = rand(); From 39339fa159e7a53bf7ca2460181cce77d5b410b5 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 12 Aug 2024 15:42:25 +0530 Subject: [PATCH 02/17] style: fix indentation Signed-off-by: Gunj Joshi --- .../base/special/ldexp/examples/c/example.c | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c index f841f94fcfa3..d2b712162d38 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c @@ -32,29 +32,29 @@ static double rand_double() { int main( void ) { double sign; - double frac; - int32_t exp; - double x; - double v; - int i; - - for ( i = 0; i < 100; i++ ) { - if ( rand_double() < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - // Generate a random number: - frac = rand_double() * 10.0; - exp = (int32_t)( rand_double()*616.0 ) - 308; - x = sign * frac * pow( 10.0, exp ); - - // Break the number into a normalized fraction and an integer power of two: - stdlib_base_frexp( x, &frac, &exp ); - - // Reconstitute the original number: - v = stdlib_base_ldexp( frac, exp ); - - printf( "%e = %lf * 2^%" PRId32 " = %e\n", x, frac, exp, v ); - } + double frac; + int32_t exp; + double x; + double v; + int i; + + for ( i = 0; i < 100; i++ ) { + if ( rand_double() < 0.5 ) { + sign = -1.0; + } else { + sign = 1.0; + } + // Generate a random number: + frac = rand_double() * 10.0; + exp = (int32_t)( rand_double()*616.0 ) - 308; + x = sign * frac * pow( 10.0, exp ); + + // Break the number into a normalized fraction and an integer power of two: + stdlib_base_frexp( x, &frac, &exp ); + + // Reconstitute the original number: + v = stdlib_base_ldexp( frac, exp ); + + printf( "%e = %lf * 2^%" PRId32 " = %e\n", x, frac, exp, v ); + } } From a7132843cece8ab23190651d25adafe7c7505ea0 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 12 Aug 2024 15:44:42 +0530 Subject: [PATCH 03/17] Update manifest.json Signed-off-by: Gunj Joshi --- lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json b/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json index ef4b3055a2b0..c57e48fbb16e 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json @@ -79,7 +79,8 @@ "@stdlib/constants/float64/max-base2-exponent", "@stdlib/constants/float64/max-base2-exponent-subnormal", "@stdlib/constants/float64/exponent-bias", - "@stdlib/math/base/special/frexp" + "@stdlib/math/base/special/frexp", + "@stdlib/math/base/special/pow" ] }, { From ed05d9ce2e451d3faded0204207fb5efcdf34e89 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 12 Aug 2024 16:13:51 +0530 Subject: [PATCH 04/17] Update example.c --- .../@stdlib/math/base/special/ldexp/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c index d2b712162d38..f2dd4a11dac9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c @@ -47,7 +47,7 @@ int main( void ) { // Generate a random number: frac = rand_double() * 10.0; exp = (int32_t)( rand_double()*616.0 ) - 308; - x = sign * frac * pow( 10.0, exp ); + x = sign * frac * stdlib_base_pow( 10.0, exp ); // Break the number into a normalized fraction and an integer power of two: stdlib_base_frexp( x, &frac, &exp ); From 300cd0daf2179595e3e950550a8a16cf694d58a4 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 12 Aug 2024 18:02:13 +0530 Subject: [PATCH 05/17] Update README.md Signed-off-by: Gunj Joshi --- lib/node_modules/@stdlib/math/base/special/ldexp/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/README.md b/lib/node_modules/@stdlib/math/base/special/ldexp/README.md index d2b8a7180e0c..f089b7c91e07 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/README.md @@ -183,6 +183,7 @@ double stdlib_base_ldexp( const double frac, const int32_t exp ); ```c #include "stdlib/math/base/special/ldexp.h" #include "stdlib/math/base/special/frexp.h" +#include "stdlib/math/base/special/pow.h" #include #include #include @@ -208,10 +209,11 @@ int main( void ) { } else { sign = 1.0; } + // Generate a random number: frac = rand_double() * 10.0; - exp = (int32_t)( rand_double()*616.0 ) - 308; - x = sign * frac * pow( 10.0, exp ); + exp = (int32_t)( rand_double() * 616.0 ) - 308; + x = sign * frac * stdlib_base_pow( 10.0, (double)exp ); // Break the number into a normalized fraction and an integer power of two: stdlib_base_frexp( x, &frac, &exp ); From 8b4a8b859cb6fff12d1ffdaf6641ac3067851f7d Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 12 Aug 2024 18:02:59 +0530 Subject: [PATCH 06/17] Update example.c Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/ldexp/examples/c/example.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c index f2dd4a11dac9..80978a55c813 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c @@ -41,13 +41,14 @@ int main( void ) { for ( i = 0; i < 100; i++ ) { if ( rand_double() < 0.5 ) { sign = -1.0; - } else { + } else { sign = 1.0; } + // Generate a random number: frac = rand_double() * 10.0; exp = (int32_t)( rand_double()*616.0 ) - 308; - x = sign * frac * stdlib_base_pow( 10.0, exp ); + x = sign * frac * stdlib_base_pow( 10.0, (double)exp ); // Break the number into a normalized fraction and an integer power of two: stdlib_base_frexp( x, &frac, &exp ); From 305f2de5c5fb9176fc118bddd7e64a4e0e9c6938 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 25 Nov 2024 14:21:33 +0530 Subject: [PATCH 07/17] refactor: update examples --- .../base/special/ldexp/examples/c/example.c | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c index 80978a55c813..1aa206db30eb 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c @@ -16,46 +16,19 @@ * limitations under the License. */ - #include "stdlib/math/base/special/ldexp.h" -#include "stdlib/math/base/special/frexp.h" -#include "stdlib/math/base/special/pow.h" -#include #include #include -#include - -static double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} int main( void ) { - double sign; - double frac; - int32_t exp; - double x; - double v; + double y; int i; - for ( i = 0; i < 100; i++ ) { - if ( rand_double() < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - - // Generate a random number: - frac = rand_double() * 10.0; - exp = (int32_t)( rand_double()*616.0 ) - 308; - x = sign * frac * stdlib_base_pow( 10.0, (double)exp ); - - // Break the number into a normalized fraction and an integer power of two: - stdlib_base_frexp( x, &frac, &exp ); - - // Reconstitute the original number: - v = stdlib_base_ldexp( frac, exp ); + const double frac[] = { 0.5, 5.0, 0.0, 3.5, 7.9 }; + const int32_t exp[] = { 3, -2, 20, 39, 14 }; - printf( "%e = %lf * 2^%" PRId32 " = %e\n", x, frac, exp, v ); + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_ldexp( frac[ i ], exp[ i ] ); + printf( "ldexp(%lf, %d) = %lf\n", frac[ i ], exp[ i ], y ); } } From 61b28f3dbb6b099d8aa175af2f5345ef664ede51 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 25 Nov 2024 14:27:21 +0530 Subject: [PATCH 08/17] bench: update benchmarks --- .../math/base/special/ldexp/benchmark/benchmark.js | 11 ++++++----- .../special/ldexp/benchmark/benchmark.native.js | 11 ++++++----- .../math/base/special/ldexp/benchmark/c/benchmark.c | 13 ++++++++----- .../special/ldexp/benchmark/c/cephes/benchmark.c | 13 ++++++++----- .../special/ldexp/benchmark/c/native/benchmark.c | 13 ++++++++----- .../base/special/ldexp/benchmark/cpp/benchmark.cpp | 13 ++++++++----- 6 files changed, 44 insertions(+), 30 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js index 936f7b454a9f..4ba690a4863b 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +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 pkg = require( './../package.json' ).name; var ldexp = require( './../lib' ); @@ -36,11 +36,12 @@ bench( pkg, function benchmark( b ) { var z; var i; + x = uniform( 100, -10.0, 10.0 ); + y = discreteUniform( 100, -1020.0, 1020.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*20.0 ) - 10.0; - y = round( randu()*2040.0 ) - 1020.0; - z = ldexp( x, y ); + z = ldexp( 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/ldexp/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.native.js index e6e30afbeeea..b2aa12a99469 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.native.js @@ -22,8 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +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 tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -45,11 +45,12 @@ bench( pkg+'::native', opts, function benchmark( b ) { var z; var i; + x = uniform( 100, -10.0, 10.0 ); + y = discreteUniform( 100, -1020.0, 1020.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*20.0 ) - 10.0; - y = round( randu()*2040.0 ) - 1020.0; - z = ldexp( x, y ); + z = ldexp( 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/ldexp/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/benchmark.c index c07fc45d9886..7da27dd79633 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/benchmark.c @@ -90,17 +90,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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = ldexp( x, y ); + z = ldexp( 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/ldexp/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/cephes/benchmark.c index f85b2f85c03b..084dc4fd0f4b 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/cephes/benchmark.c @@ -95,17 +95,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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = ldexp( x, y ); + z = ldexp( 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/ldexp/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/native/benchmark.c index d6b9724305ad..ff5d6ddf7ffc 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = stdlib_base_ldexp( x, y ); + z = stdlib_base_ldexp( 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/ldexp/benchmark/cpp/benchmark.cpp b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp index 0e8de32b97e0..de40f7eb68ce 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp @@ -93,17 +93,20 @@ double rand_double() { */ double benchmark() { 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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = ldexp( x, y ); + z = ldexp( x[ i % 100 ], y[ i % 100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; From 5db702acaeeb717427da96bad931d86e62a91af5 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:10:00 +0530 Subject: [PATCH 09/17] docs: update examples Signed-off-by: Gunj Joshi --- .../base/special/ldexp/examples/c/example.c | 38 +++---------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c index 80978a55c813..f34e228150a1 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/examples/c/example.c @@ -18,44 +18,18 @@ #include "stdlib/math/base/special/ldexp.h" -#include "stdlib/math/base/special/frexp.h" -#include "stdlib/math/base/special/pow.h" -#include #include #include -#include - -static double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} int main( void ) { - double sign; - double frac; - int32_t exp; - double x; - double v; + double y; int i; - for ( i = 0; i < 100; i++ ) { - if ( rand_double() < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - - // Generate a random number: - frac = rand_double() * 10.0; - exp = (int32_t)( rand_double()*616.0 ) - 308; - x = sign * frac * stdlib_base_pow( 10.0, (double)exp ); - - // Break the number into a normalized fraction and an integer power of two: - stdlib_base_frexp( x, &frac, &exp ); - - // Reconstitute the original number: - v = stdlib_base_ldexp( frac, exp ); + const double frac[] = { 0.5, 5.0, 0.0, 3.5, 7.9 }; + const int32_t exp[] = { 3, -2, 20, 39, 14 }; - printf( "%e = %lf * 2^%" PRId32 " = %e\n", x, frac, exp, v ); + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_ldexp( frac[ i ], exp[ i ] ); + printf( "ldexp(%lf, %d) = %lf\n", frac[ i ], exp[ i ], y ); } } From 78b9ce8cf1b38a6739922bbdc1e623fa0053b16d Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:11:02 +0530 Subject: [PATCH 10/17] docs: update readme examples Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/ldexp/README.md | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/README.md b/lib/node_modules/@stdlib/math/base/special/ldexp/README.md index f089b7c91e07..bf5cb28c57e3 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/README.md @@ -182,46 +182,19 @@ double stdlib_base_ldexp( const double frac, const int32_t exp ); ```c #include "stdlib/math/base/special/ldexp.h" -#include "stdlib/math/base/special/frexp.h" -#include "stdlib/math/base/special/pow.h" -#include #include #include -#include -#include - -static double rand_double() { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} int main( void ) { - double sign; - double frac; - int32_t exp; - double x; - double v; + double y; int i; - for ( i = 0; i < 100; i++ ) { - if ( rand_double() < 0.5 ) { - sign = -1.0; - } else { - sign = 1.0; - } - - // Generate a random number: - frac = rand_double() * 10.0; - exp = (int32_t)( rand_double() * 616.0 ) - 308; - x = sign * frac * stdlib_base_pow( 10.0, (double)exp ); - - // Break the number into a normalized fraction and an integer power of two: - stdlib_base_frexp( x, &frac, &exp ); - - // Reconstitute the original number: - v = stdlib_base_ldexp( frac, exp ); + const double frac[] = { 0.5, 5.0, 0.0, 3.5, 7.9 }; + const int32_t exp[] = { 3, -2, 20, 39, 14 }; - printf( "%e = %lf * 2^%" PRId32 " = %e\n", x, frac, exp, v ); + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_ldexp( frac[ i ], exp[ i ] ); + printf( "ldexp(%lf, %d) = %lf\n", frac[ i ], exp[ i ], y ); } } ``` From 0ea6ddb825e14f568904fbce224de4c755f2698d Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:14:11 +0530 Subject: [PATCH 11/17] becnh: update examples Signed-off-by: Gunj Joshi --- .../special/ldexp/benchmark/c/cephes/benchmark.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/cephes/benchmark.c index f85b2f85c03b..084dc4fd0f4b 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/cephes/benchmark.c @@ -95,17 +95,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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = ldexp( x, y ); + z = ldexp( x[ i % 100 ], y[ i % 100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; From 6e66531d415e0cd474e65d1e4a33033097a000d4 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:14:47 +0530 Subject: [PATCH 12/17] bench: update benchmarks Signed-off-by: Gunj Joshi --- .../special/ldexp/benchmark/c/native/benchmark.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/native/benchmark.c index d6b9724305ad..ff5d6ddf7ffc 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = stdlib_base_ldexp( x, y ); + z = stdlib_base_ldexp( x[ i % 100 ], y[ i % 100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; From 5d794cb0d03e9de9417408078b47ea8ce8edf2d7 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:15:14 +0530 Subject: [PATCH 13/17] bench: update benchmarks Signed-off-by: Gunj Joshi --- .../math/base/special/ldexp/benchmark/c/benchmark.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/benchmark.c index c07fc45d9886..7da27dd79633 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/c/benchmark.c @@ -90,17 +90,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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = ldexp( x, y ); + z = ldexp( x[ i % 100 ], y[ i % 100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; From 5f09d068eac23a5e4b6c6da14fb643618789aefe Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:15:42 +0530 Subject: [PATCH 14/17] bench: update cpp benchmarks Signed-off-by: Gunj Joshi --- .../base/special/ldexp/benchmark/cpp/benchmark.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp index 0e8de32b97e0..de40f7eb68ce 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp @@ -93,17 +93,20 @@ double rand_double() { */ double benchmark() { 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 ] = ( rand_double() * 20.0 ) - 10.0; + y[ i ] = ( rand_double() * 2048.0 ) - 1024.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( rand_double()*20.0 ) - 10.0; - y = ( rand_double()*2048.0 ) - 1024.0; - z = ldexp( x, y ); + z = ldexp( x[ i % 100 ], y[ i % 100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; From 279c8e08a925ec2c371a737cd3f226647282713f Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:16:19 +0530 Subject: [PATCH 15/17] bench: update js benchmarks Signed-off-by: Gunj Joshi --- .../math/base/special/ldexp/benchmark/benchmark.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js index 936f7b454a9f..4ba690a4863b 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +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 pkg = require( './../package.json' ).name; var ldexp = require( './../lib' ); @@ -36,11 +36,12 @@ bench( pkg, function benchmark( b ) { var z; var i; + x = uniform( 100, -10.0, 10.0 ); + y = discreteUniform( 100, -1020.0, 1020.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*20.0 ) - 10.0; - y = round( randu()*2040.0 ) - 1020.0; - z = ldexp( x, y ); + z = ldexp( x[ i % x.length ], y[ i % y.length ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } From 58aafa99e9101508d79b5fe9c80a6e4c3122c985 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 25 Nov 2024 23:16:53 +0530 Subject: [PATCH 16/17] bench: update js benchmarks Signed-off-by: Gunj Joshi --- .../base/special/ldexp/benchmark/benchmark.native.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.native.js index e6e30afbeeea..b2aa12a99469 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/benchmark.native.js @@ -22,8 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +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 tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -45,11 +45,12 @@ bench( pkg+'::native', opts, function benchmark( b ) { var z; var i; + x = uniform( 100, -10.0, 10.0 ); + y = discreteUniform( 100, -1020.0, 1020.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*20.0 ) - 10.0; - y = round( randu()*2040.0 ) - 1020.0; - z = ldexp( x, y ); + z = ldexp( x[ i % x.length ], y[ i % y.length ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } From 6bb7a11037f1dbc017ec53042d56f7b692f923fe Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 25 Nov 2024 23:19:19 +0530 Subject: [PATCH 17/17] docs: remove unused dependencies --- .../@stdlib/math/base/special/ldexp/manifest.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json b/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json index 523811bcf2b0..a3c204ec1186 100644 --- a/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/ldexp/manifest.json @@ -81,9 +81,7 @@ "@stdlib/constants/float64/min-base2-exponent-subnormal", "@stdlib/constants/float64/max-base2-exponent", "@stdlib/constants/float64/max-base2-exponent-subnormal", - "@stdlib/constants/float64/exponent-bias", - "@stdlib/math/base/special/frexp", - "@stdlib/math/base/special/pow" + "@stdlib/constants/float64/exponent-bias" ] }, {