From eae6f9603ed4f3c930e873aa1fd8784e23734408 Mon Sep 17 00:00:00 2001 From: vivek maurya Date: Wed, 15 Jan 2025 16:30:10 +0000 Subject: [PATCH 1/4] refactor: update math/base/special/hypot to follow latest project conventions --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/math/base/special/hypot/README.md | 14 ++++--- .../base/special/hypot/benchmark/benchmark.js | 20 ++++++---- .../hypot/benchmark/benchmark.native.js | 11 ++++-- .../hypot/benchmark/c/native/benchmark.c | 13 ++++--- .../math/base/special/hypot/examples/index.js | 14 ++++--- .../math/base/special/hypot/manifest.json | 9 +++-- .../math/base/special/hypot/src/hypot.c | 6 +-- .../math/base/special/hypot/test/test.js | 38 +++++++++---------- .../base/special/hypot/test/test.native.js | 38 +++++++++---------- 9 files changed, 91 insertions(+), 72 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/README.md b/lib/node_modules/@stdlib/math/base/special/hypot/README.md index f7dd7e3239d6..28378ad3405d 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/README.md +++ b/lib/node_modules/@stdlib/math/base/special/hypot/README.md @@ -119,20 +119,22 @@ h = hypot( 5.0, NaN ); ```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 hypot = require( '@stdlib/math/base/special/hypot' ); +var len; var x; var y; var h; var i; +len = 100; +x = discreteUniform( len, -50, 50 ); +y = discreteUniform( len, -50, 50 ); + 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( 'h(%d,%d) = %d', x, y, h ); + h = hypot( x[ i ], y[ i ] ); + console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], h ); } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js index 1ad88a69b8d4..110c3762f402 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var pkg = require( './../package.json' ).name; var hypot = require( './../lib' ); @@ -37,16 +37,19 @@ var opts = { // MAIN // bench( pkg, function benchmark( b ) { + var len; var x; var y; var z; var i; + len = 100; + x = discreteUniform( len, -50, 50 ); + y = discreteUniform( len, -50, 50 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100.0 ) - 50.0; - y = ( randu()*100.0 ) - 50.0; - z = hypot( x, y ); + z = hypot( x[ i % len ], y[ i % len ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } @@ -60,16 +63,19 @@ bench( pkg, function benchmark( b ) { }); bench( pkg+'::built-in', opts, function benchmark( b ) { + var len; var x; var y; var z; var i; + len = 100; + x = discreteUniform( len, -50, 50 ); + y = discreteUniform( len, -50, 50 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100.0 ) - 50.0; - y = ( randu()*100.0 ) - 50.0; - z = Math.hypot( x, y ); // eslint-disable-line stdlib/no-builtin-math + z = Math.hypot( x[ i % len ], y[ i % len ] ); // eslint-disable-line stdlib/no-builtin-math if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.native.js index a8dfef48eca9..790fa06bc041 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -39,16 +39,19 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { + var len; var x; var y; var z; var i; + len = 100; + x = discreteUniform( len, -50, 50 ); + y = discreteUniform( len, -50, 50 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100.0 ) - 50.0; - y = ( randu()*100.0 ) - 50.0; - z = hypot( x, y ); + z = hypot( x[ i % len ], y[ i % len ] ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/c/native/benchmark.c index ac9a91e3ddcf..2dfda8cc1856 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/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 ] = round( ( rand_double() * 100.0 ) - 50.0 ); + y[ i ] = round( ( rand_double() * 100.0 ) - 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_hypot( x, y ); + z = stdlib_base_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/hypot/examples/index.js b/lib/node_modules/@stdlib/math/base/special/hypot/examples/index.js index 51bd0803d70e..6ff0d0e5c5be 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/examples/index.js @@ -18,18 +18,20 @@ '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 hypot = require( './../lib' ); +var len; var x; var y; var h; var i; +len = 100; +x = discreteUniform( len, -50, 50 ); +y = discreteUniform( len, -50, 50 ); + 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( 'h(%d,%d) = %d', x, y, h ); + h = hypot( x[ i ], y[ i ] ); + console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], h ); } diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json b/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json index 33c41d36613f..25f036fbcf0e 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json @@ -41,7 +41,8 @@ "@stdlib/math/base/napi/binary", "@stdlib/math/base/assert/is-nan", "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/special/sqrt" + "@stdlib/math/base/special/sqrt", + "@stdlib/constants/float64/pinf" ] }, { @@ -59,7 +60,8 @@ "dependencies": [ "@stdlib/math/base/assert/is-nan", "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/special/sqrt" + "@stdlib/math/base/special/sqrt", + "@stdlib/constants/float64/pinf" ] }, { @@ -77,7 +79,8 @@ "dependencies": [ "@stdlib/math/base/assert/is-nan", "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/special/sqrt" + "@stdlib/math/base/special/sqrt", + "@stdlib/constants/float64/pinf" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/src/hypot.c b/lib/node_modules/@stdlib/math/base/special/hypot/src/hypot.c index 58a77e970c42..11ba026d6247 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/src/hypot.c +++ b/lib/node_modules/@stdlib/math/base/special/hypot/src/hypot.c @@ -20,7 +20,7 @@ #include "stdlib/math/base/assert/is_nan.h" #include "stdlib/math/base/assert/is_infinite.h" #include "stdlib/math/base/special/sqrt.h" -#include +#include "stdlib/constants/float64/pinf.h" /** * Computes the hypotenuse avoiding overflow and underflow. @@ -41,7 +41,7 @@ double stdlib_base_hypot( const double x, const double y ) { return 0.0 / 0.0; // NaN } if ( stdlib_base_is_infinite( x ) || stdlib_base_is_infinite( y ) ) { - return HUGE_VAL; + return STDLIB_CONSTANT_FLOAT64_PINF; } a = x; b = y; @@ -60,5 +60,5 @@ double stdlib_base_hypot( const double x, const double y ) { return 0.0; } b /= a; - return a * stdlib_base_sqrt( 1.0 + (b*b) ); + return a * stdlib_base_sqrt( 1.0 + ( b * b ) ); } diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/test/test.js b/lib/node_modules/@stdlib/math/base/special/hypot/test/test.js index 7e88764fab65..122526efbd49 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/test/test.js @@ -49,28 +49,28 @@ tape( 'the function returns `+infinity` if either argument is `+-infinity`', fun var h; h = hypot( PINF, 3.14 ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( 3.14, PINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( NINF, 3.14 ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( 3.14, NINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( PINF, PINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( NINF, PINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( PINF, NINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( NINF, NINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); t.end(); }); @@ -79,13 +79,13 @@ tape( 'the function returns `NaN` if either argument is `NaN`', function test( t var h; h = hypot( NaN, 3.14 ); - t.strictEqual( isnan( h ), true, 'returns NaN' ); + t.strictEqual( isnan( h ), true, 'returns expected value' ); h = hypot( 3.14, NaN ); - t.strictEqual( isnan( h ), true, 'returns NaN' ); + t.strictEqual( isnan( h ), true, 'returns expected value' ); h = hypot( NaN, NaN ); - t.strictEqual( isnan( h ), true, 'returns NaN' ); + t.strictEqual( isnan( h ), true, 'returns expected value' ); t.end(); }); @@ -94,16 +94,16 @@ tape( 'the function returns `+0` if both arguments are `+-0`', function test( t var h; h = hypot( +0.0, +0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); h = hypot( -0.0, +0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); h = hypot( +0.0, -0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); h = hypot( -0.0, -0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); t.end(); }); @@ -138,13 +138,13 @@ 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(); }); @@ -153,7 +153,7 @@ tape( 'the function avoids overflow', function test( t ) { var h; h = sqrt( pow( 1.0e308, 2 ) + pow( 1.0e308, 2 ) ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( 1.0e308, 1.0e308 ); t.strictEqual( h, 1.4142135623730951e308, 'avoids overflow' ); diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/hypot/test/test.native.js index 24d1c02f6219..575e0db62023 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/test/test.native.js @@ -58,28 +58,28 @@ tape( 'the function returns `+infinity` if either argument is `+-infinity`', opt var h; h = hypot( PINF, 3.14 ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( 3.14, PINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( NINF, 3.14 ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( 3.14, NINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( PINF, PINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( NINF, PINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( PINF, NINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( NINF, NINF ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); t.end(); }); @@ -88,13 +88,13 @@ tape( 'the function returns `NaN` if either argument is `NaN`', opts, function t var h; h = hypot( NaN, 3.14 ); - t.strictEqual( isnan( h ), true, 'returns NaN' ); + t.strictEqual( isnan( h ), true, 'returns expected value' ); h = hypot( 3.14, NaN ); - t.strictEqual( isnan( h ), true, 'returns NaN' ); + t.strictEqual( isnan( h ), true, 'returns expected value' ); h = hypot( NaN, NaN ); - t.strictEqual( isnan( h ), true, 'returns NaN' ); + t.strictEqual( isnan( h ), true, 'returns expected value' ); t.end(); }); @@ -103,16 +103,16 @@ tape( 'the function returns `+0` if both arguments are `+-0`', opts, function te var h; h = hypot( +0.0, +0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); h = hypot( -0.0, +0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); h = hypot( +0.0, -0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); h = hypot( -0.0, -0.0 ); - t.strictEqual( isPositiveZero( h ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( h ), true, 'returns expected value' ); t.end(); }); @@ -147,13 +147,13 @@ 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(); }); @@ -162,7 +162,7 @@ tape( 'the function avoids overflow', opts, function test( t ) { var h; h = sqrt( pow( 1.0e308, 2 ) + pow( 1.0e308, 2 ) ); - t.strictEqual( h, PINF, 'returns +infinity' ); + t.strictEqual( h, PINF, 'returns expected value' ); h = hypot( 1.0e308, 1.0e308 ); t.strictEqual( h, 1.4142135623730951e308, 'avoids overflow' ); From 3722f999d61494175256ab1e7a61493c06878185 Mon Sep 17 00:00:00 2001 From: vivek maurya Date: Thu, 16 Jan 2025 19:07:56 +0000 Subject: [PATCH 2/4] refactor: update math/base/special/hypot to follow latest project conventions --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../math/base/special/hypot/benchmark/benchmark.js | 10 +++++----- .../base/special/hypot/benchmark/benchmark.native.js | 6 +++--- .../base/special/hypot/benchmark/c/native/benchmark.c | 4 ++-- .../@stdlib/math/base/special/hypot/manifest.json | 6 +++--- .../math/base/special/hypot/src/{hypot.c => main.c} | 0 5 files changed, 13 insertions(+), 13 deletions(-) rename lib/node_modules/@stdlib/math/base/special/hypot/src/{hypot.c => main.c} (100%) diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js index 110c3762f402..0649d486ad90 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var pkg = require( './../package.json' ).name; var hypot = require( './../lib' ); @@ -44,8 +44,8 @@ bench( pkg, function benchmark( b ) { var i; len = 100; - x = discreteUniform( len, -50, 50 ); - y = discreteUniform( len, -50, 50 ); + x = uniform( len, -50, 50 ); + y = uniform( len, -50, 50 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -70,8 +70,8 @@ bench( pkg+'::built-in', opts, function benchmark( b ) { var i; len = 100; - x = discreteUniform( len, -50, 50 ); - y = discreteUniform( len, -50, 50 ); + x = uniform( len, -50, 50 ); + y = uniform( len, -50, 50 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.native.js index 790fa06bc041..530480ddcdf4 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/benchmark.native.js @@ -23,7 +23,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -46,8 +46,8 @@ bench( pkg+'::native', opts, function benchmark( b ) { var i; len = 100; - x = discreteUniform( len, -50, 50 ); - y = discreteUniform( len, -50, 50 ); + x = uniform( len, -50, 50 ); + y = uniform( len, -50, 50 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/c/native/benchmark.c index 2dfda8cc1856..4355b034728e 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/hypot/benchmark/c/native/benchmark.c @@ -98,8 +98,8 @@ static double benchmark( void ) { int i; for ( i = 0; i < 100; i++ ) { - x[ i ] = round( ( rand_double() * 100.0 ) - 50.0 ); - y[ i ] = round( ( rand_double() * 100.0 ) - 50.0 ); + x[ i ] = ( rand_double() * 100.0 ) - 50.0; + y[ i ] = ( rand_double() * 100.0 ) - 50.0; } t = tic(); diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json b/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json index 25f036fbcf0e..755db550a9d9 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/hypot/manifest.json @@ -28,7 +28,7 @@ { "task": "build", "src": [ - "./src/hypot.c" + "./src/main.c" ], "include": [ "./include" @@ -48,7 +48,7 @@ { "task": "benchmark", "src": [ - "./src/hypot.c" + "./src/main.c" ], "include": [ "./include" @@ -67,7 +67,7 @@ { "task": "examples", "src": [ - "./src/hypot.c" + "./src/main.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/src/hypot.c b/lib/node_modules/@stdlib/math/base/special/hypot/src/main.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/hypot/src/hypot.c rename to lib/node_modules/@stdlib/math/base/special/hypot/src/main.c From 465d42c04a0827674fbb2e9a5213d744eea9e0a2 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 17 Jan 2025 12:06:05 -0800 Subject: [PATCH 3/4] docs: update example Signed-off-by: Athan --- .../@stdlib/math/base/special/hypot/README.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/README.md b/lib/node_modules/@stdlib/math/base/special/hypot/README.md index 28378ad3405d..544978fdf947 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/README.md +++ b/lib/node_modules/@stdlib/math/base/special/hypot/README.md @@ -122,19 +122,13 @@ h = hypot( 5.0, NaN ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var hypot = require( '@stdlib/math/base/special/hypot' ); -var len; -var x; -var y; -var h; -var i; - -len = 100; -x = discreteUniform( len, -50, 50 ); -y = discreteUniform( len, -50, 50 ); +var len = 100; +var x = discreteUniform( len, -50, 50 ); +var y = discreteUniform( len, -50, 50 ); -for ( i = 0; i < 100; i++ ) { - h = hypot( x[ i ], y[ i ] ); - console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], h ); +var i; +for ( i = 0; i < len; i++ ) { + console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], hypot( x[ i ], y[ i ] ) ); } ``` From b9e8485cf3eafa083306bee3b5b0decf9800623c Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 17 Jan 2025 12:07:59 -0800 Subject: [PATCH 4/4] docs: update example Signed-off-by: Athan --- .../math/base/special/hypot/examples/index.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/hypot/examples/index.js b/lib/node_modules/@stdlib/math/base/special/hypot/examples/index.js index 6ff0d0e5c5be..2a1bff6903b3 100644 --- a/lib/node_modules/@stdlib/math/base/special/hypot/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/hypot/examples/index.js @@ -21,17 +21,11 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var hypot = require( './../lib' ); -var len; -var x; -var y; -var h; -var i; - -len = 100; -x = discreteUniform( len, -50, 50 ); -y = discreteUniform( len, -50, 50 ); +var len = 100; +var x = discreteUniform( len, -50, 50 ); +var y = discreteUniform( len, -50, 50 ); -for ( i = 0; i < 100; i++ ) { - h = hypot( x[ i ], y[ i ] ); - console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], h ); +var i; +for ( i = 0; i < len; i++ ) { + console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], hypot( x[ i ], y[ i ] ) ); }