From e3753b6d110818b5bc29ec6084330ba28978a93a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 1 Jan 2025 17:05:42 +0530 Subject: [PATCH 01/23] feat: add math/base/special/roundsd --- .../math/base/special/roundsd/README.md | 87 ++++++ .../roundsd/benchmark/benchmark.native.js | 62 +++++ .../base/special/roundsd/benchmark/c/Makefile | 146 ++++++++++ .../special/roundsd/benchmark/c/benchmark.c | 137 ++++++++++ .../math/base/special/roundsd/binding.gyp | 170 ++++++++++++ .../base/special/roundsd/examples/c/Makefile | 146 ++++++++++ .../base/special/roundsd/examples/c/example.c | 31 +++ .../math/base/special/roundsd/include.gypi | 53 ++++ .../stdlib/math/base/special/roundsd.h | 40 +++ .../math/base/special/roundsd/lib/native.js | 60 ++++ .../math/base/special/roundsd/manifest.json | 102 +++++++ .../math/base/special/roundsd/src/Makefile | 70 +++++ .../math/base/special/roundsd/src/addon.c | 22 ++ .../math/base/special/roundsd/src/main.c | 102 +++++++ .../base/special/roundsd/test/test.native.js | 257 ++++++++++++++++++ 15 files changed, 1485 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md index 2afbc3bfaaa3..b1e9c367e513 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md @@ -87,6 +87,93 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/roundsd.h" +``` + +#### stdlib_base_roundsd( x, n, b ) + +Rounds a numeric value to the nearest number with \\(n\\) significant figures. + +```c + double v = roundsd( 3.141592653589793, 3, 10 ); + // returns 3.14 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **n**: `[in] int32_t` number of significant figures. +- **b**: `[in] int32_t` base. + +```c +double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/roundsd..h" +#include + +int main( void ) { + const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 }; + + double y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_roundsd( x[ i ], -2 ); + printf( "roundsd(%lf) = %lf\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + From 76f13c525d3e310cec54c9c7f78abff10bc9d54f Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 5 Apr 2025 15:27:27 +0530 Subject: [PATCH 04/23] fix: jsdoc Co-authored-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/math/base/special/roundsd/lib/native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js index 217d57f4f5cc..5fe025744db7 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js @@ -31,7 +31,7 @@ var addon = require( './../src/addon.node' ); * @private * @param {number} x - input value * @param {PositiveInteger} n - number of significant figures -* @param {PositiveInteger} [b=10] - base +* @param {PositiveInteger} b - base * @returns {number} rounded value * * @example From 28139c7eb517e0d9e0b782a1dca974d8efde45cb Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 5 Apr 2025 15:28:52 +0530 Subject: [PATCH 05/23] fix: jsdoc to doxygen Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../math/base/special/roundsd/src/main.c | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index a5907d165f5a..2a0615444679 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -36,26 +36,14 @@ /** * Rounds a numeric value to the nearest number with \\(n\\) significant figures. * -* @param x - input value -* @param n - number of significant figures -* @param b=10 - base -* @returns {number} rounded value +* @param x input value +* @param n number of significant figures +* @param b base +* @returns rounded value * * @example * double v = roundsd( 3.141592653589793, 3, 10 ); * // returns 3.14 -* -* @example -* double v = roundsd( 3.141592653589793, 1, 10 ); -* // returns 3.0 -* -* @example -* double v = roundsd( 12368.0, 2, 10 ); -* // returns 12000.0 -* -* @example -* double v = roundsd( 0.0313, 2, 2 ); -* // returns 0.03125 */ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ) { double exp; From 70bc4c825b1be0f33364248276c779e2d445960c Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 5 Apr 2025 15:30:36 +0530 Subject: [PATCH 06/23] chore: update doxygen Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index 2a0615444679..5ba26beb3a2d 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -42,7 +42,7 @@ * @returns rounded value * * @example -* double v = roundsd( 3.141592653589793, 3, 10 ); +* double v = stdlib_base_roundsd( 3.141592653589793, 3, 10 ); * // returns 3.14 */ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ) { From 7557c42ebd3302502dcd218382cbcd5aaae7bc2a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 5 Apr 2025 16:32:42 +0530 Subject: [PATCH 07/23] chore: add suggestions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/roundsd/README.md | 8 +- .../roundsd/benchmark/benchmark.native.js | 7 +- .../roundsd/benchmark/c/{ => native}/Makefile | 0 .../benchmark/c/{ => native}/benchmark.c | 8 +- .../math/base/special/roundsd/src/main.c | 10 +- .../base/special/roundsd/test/test.native.js | 109 +++++++----------- 6 files changed, 58 insertions(+), 84 deletions(-) rename lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/{ => native}/Makefile (100%) rename lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/{ => native}/benchmark.c (94%) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md index 2f9264dae93c..18ddc4413447 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md @@ -113,11 +113,11 @@ logEachMap( 'x: %0.4f. y: %d. Rounded: %0.4f.', x, 5, roundsd ); #### stdlib_base_roundsd( x, n, b ) -Rounds a numeric value to the nearest number with \\(n\\) significant figures. +Rounds a `numeric` value to the nearest `number` with `n` significant figures. ```c - double v = roundsd( 3.141592653589793, 3, 10 ); - // returns 3.14 +double v = stdlib_base_roundsd( 3.141592653589793, 3, 10 ); +// returns 3.14 ``` The function accepts the following arguments: @@ -158,7 +158,7 @@ int main( void ) { double y; int i; for ( i = 0; i < 4; i++ ) { - y = stdlib_base_roundsd( x[ i ], -2 ); + y = stdlib_base_roundsd( x[ i ], -2, 10 ); printf( "roundsd(%lf) = %lf\n", x[ i ], y ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js index 92bbe512c933..9dcd87391a0d 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/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, -5.0e6, 5.0e6 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = roundsd( x, 2, 2 ); + y = roundsd( x[ i%x.length ], 2, 2 ); if ( isnan( y ) ) { console.log('Generated value:', x); b.fail( 'should not return NaN' ); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/Makefile rename to lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c similarity index 94% rename from lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/benchmark.c rename to lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c index 9ff8eb3155b2..9c13c1d8c0ee 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c @@ -93,17 +93,15 @@ static double benchmark( void ) { double elapsed; double t; double v; - double n; - double b; + double n; + double b; double y; int i; t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { v = ( 1000.0*rand_double() ) - 500.0; - n = ( 1000.0*rand_double() ) - 500.0; - b = ( 1000.0*rand_double() ) - 500.0; - y = stdlib_base_roundsd( v, n, b ); + y = stdlib_base_roundsd( v, 5, 10 ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index 5ba26beb3a2d..cdf4ff0a1d2f 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -49,12 +49,8 @@ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ) { double exp; double s; double y; - if ( - stdlib_base_is_nan( x ) || - stdlib_base_is_nan( n ) || - n < 1 || - stdlib_base_is_infinite( n ) - ) { + + if ( stdlib_base_is_nan( x ) || n < 1 ) { return 0.0/0.0; //NaN } if ( stdlib_base_is_infinite( x ) || x == 0.0 ) { @@ -70,7 +66,7 @@ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ) { exp = stdlib_base_ln( stdlib_base_abs(x) ) / stdlib_base_ln( b ); } exp = stdlib_base_floor( exp - n + 1.0 ); - s = stdlib_base_pow( b, abs( exp ) ); + s = stdlib_base_pow( b, stdlib_base_abs( exp ) ); // Check for overflow: if ( stdlib_base_is_infinite( s ) ) { diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js index b03abfc701de..9c13e44ebb9e 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js @@ -20,6 +20,7 @@ // MODULES // +var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var PI = require( '@stdlib/constants/float64/pi' ); var PINF = require( '@stdlib/constants/float64/pinf' ); @@ -27,7 +28,15 @@ var NINF = require( '@stdlib/constants/float64/ninf' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); -var roundsd = require( './../lib' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var roundsd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( roundsd instanceof Error ) +}; // FIXTURES // @@ -38,64 +47,34 @@ var base16 = require( './fixtures/julia/base_16_sigfigs_4.json' ); // TESTS // -tape( 'main export is a function', function test( t ) { +tape( 'main export is a function', opts, function test( t ) { t.ok( true, __filename ); t.strictEqual( typeof roundsd, 'function', 'main export is a function' ); t.end(); }); -tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v; - v = roundsd( NaN, 2 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = roundsd( 12368.0, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = roundsd( NaN, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = roundsd( NaN, NaN, 10 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = roundsd( NaN, 2, 10 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = roundsd( 3.14, NaN, 10 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = roundsd( 3.14, 2, NaN ); + v = roundsd( NaN, 2, 2 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function returns `NaN` if provided `n = +-infinity`', function test( t ) { +tape( 'the function returns `NaN` if provided `n < 1`', opts, function test( t ) { var v; - v = roundsd( PI, PINF ); + v = roundsd( PI, 0, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = roundsd( PI, NINF ); + v = roundsd( PI, -1, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function returns `NaN` if provided `n < 1`', function test( t ) { - var v; - - v = roundsd( PI, 0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = roundsd( PI, -1 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - t.end(); -}); - -tape( 'the function returns `NaN` if provided `b = +-infinity`', function test( t ) { +tape( 'the function returns `NaN` if provided `b = +-infinity`', opts, function test( t ) { var v; v = roundsd( PI, 2, PINF ); @@ -107,7 +86,7 @@ tape( 'the function returns `NaN` if provided `b = +-infinity`', function test( t.end(); }); -tape( 'the function returns `NaN` if provided `b <= 0`', function test( t ) { +tape( 'the function returns `NaN` if provided `b <= 0`', opts, function test( t ) { var v; v = roundsd( PI, 2, 0 ); @@ -119,58 +98,58 @@ tape( 'the function returns `NaN` if provided `b <= 0`', function test( t ) { t.end(); }); -tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { - var v = roundsd( PINF, 5 ); +tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { + var v = roundsd( PINF, 5, 10 ); t.strictEqual( v, PINF, 'returns +infinity' ); t.end(); }); -tape( 'the function returns `-infinity` if provided `-infinity`', function test( t ) { - var v = roundsd( NINF, 3 ); +tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) { + var v = roundsd( NINF, 3, 10 ); t.strictEqual( v, NINF, 'returns -infinity' ); t.end(); }); -tape( 'the function returns `-0` if provided `-0`', function test( t ) { +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v; - v = roundsd( -0.0, 1 ); + v = roundsd( -0.0, 1, 10 ); t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); - v = roundsd( -0.0, 2 ); + v = roundsd( -0.0, 2, 10 ); t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); t.end(); }); -tape( 'the function returns `+0` if provided `+0`', function test( t ) { +tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { var v; - v = roundsd( 0.0, 1 ); + v = roundsd( 0.0, 1, 10 ); t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); - v = roundsd( +0.0, 2 ); + v = roundsd( +0.0, 2, 10 ); t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); t.end(); }); -tape( 'the function supports rounding a numeric value with a specified number of significant figures', function test( t ) { - t.strictEqual( roundsd( PI, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( roundsd( -PI, 1 ), -3.0, 'returns expected value' ); - t.strictEqual( roundsd( PI, 2 ), 3.1, 'returns expected value' ); - t.strictEqual( roundsd( -PI, 2 ), -3.1, 'returns expected value' ); - t.strictEqual( roundsd( PI, 3 ), 3.14, 'returns expected value' ); - t.strictEqual( roundsd( -PI, 3 ), -3.14, 'returns expected value' ); - t.strictEqual( roundsd( 0.0, 2 ), 0.0, 'returns expected value' ); - t.strictEqual( roundsd( 12368.0, 3 ), 12400.0, 'returns expected value' ); - t.strictEqual( roundsd( -12368.0, 3 ), -12400.0, 'returns expected value' ); - t.strictEqual( roundsd( 12368.0, 2 ), 12000.0, 'returns expected value' ); - t.strictEqual( roundsd( -12368.0, 2 ), -12000.0, 'returns expected value' ); +tape( 'the function supports rounding a numeric value with a specified number of significant figures', opts, function test( t ) { + t.strictEqual( roundsd( PI, 1, 10 ), 3.0, 'returns expected value' ); + t.strictEqual( roundsd( -PI, 1, 10 ), -3.0, 'returns expected value' ); + t.strictEqual( roundsd( PI, 2, 10 ), 3.1, 'returns expected value' ); + t.strictEqual( roundsd( -PI, 2, 10 ), -3.1, 'returns expected value' ); + t.strictEqual( roundsd( PI, 3, 10 ), 3.14, 'returns expected value' ); + t.strictEqual( roundsd( -PI, 3, 10 ), -3.14, 'returns expected value' ); + t.strictEqual( roundsd( 0.0, 2, 10 ), 0.0, 'returns expected value' ); + t.strictEqual( roundsd( 12368.0, 3, 10 ), 12400.0, 'returns expected value' ); + t.strictEqual( roundsd( -12368.0, 3, 10 ), -12400.0, 'returns expected value' ); + t.strictEqual( roundsd( 12368.0, 2, 10 ), 12000.0, 'returns expected value' ); + t.strictEqual( roundsd( -12368.0, 2, 10 ), -12000.0, 'returns expected value' ); t.end(); }); -tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 10)', function test( t ) { +tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 10)', opts, function test( t ) { t.strictEqual( roundsd( PI, 1, 10 ), 3.0, 'returns expected value' ); t.strictEqual( roundsd( -PI, 1, 10 ), -3.0, 'returns expected value' ); t.strictEqual( roundsd( PI, 2, 10 ), 3.1, 'returns expected value' ); @@ -185,7 +164,7 @@ tape( 'the function supports rounding a numeric value with a specified number of t.end(); }); -tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 2)', function test( t ) { +tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 2)', opts, function test( t ) { var expected; var x; var y; @@ -215,7 +194,7 @@ tape( 'the function supports rounding a numeric value with a specified number of t.end(); }); -tape( 'the function supports rounding a numeric value with a specified number of significant figures using an arbitrary base', function test( t ) { +tape( 'the function supports rounding a numeric value with a specified number of significant figures using an arbitrary base', opts, function test( t ) { var expected; var x; var y; @@ -233,7 +212,7 @@ tape( 'the function supports rounding a numeric value with a specified number of t.end(); }); -tape( 'if the function encounters overflow, the function returns the input value', function test( t ) { +tape( 'if the function encounters overflow, the function returns the input value', opts, function test( t ) { var x; var v; From 4c9ac9461aa3a4e013edb70b1d82edada58ece95 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 5 Apr 2025 16:42:37 +0530 Subject: [PATCH 08/23] fix: lint error --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsd/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/package.json b/lib/node_modules/@stdlib/math/base/special/roundsd/package.json index 0f457f87c52c..233856dad3ae 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/package.json +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/package.json @@ -14,11 +14,14 @@ } ], "main": "./lib", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", From e07c69a7f9f5d23ca5976426c862a45fce1c775f Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 5 Apr 2025 16:50:42 +0530 Subject: [PATCH 09/23] fix: lint error --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index cdf4ff0a1d2f..4c6ee01a30c5 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -28,7 +28,7 @@ #include "stdlib/math/base/special/floor.h" #include "stdlib/number/float64/base/exponent.h" #include "stdlib/math/base/special/round.h" -#include "stdlib.h" +#include // MAIN // From 34ab3774975b0b4ff201819f01c2dc6957df7355 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 5 Apr 2025 18:18:10 +0530 Subject: [PATCH 10/23] remove: unused variables Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../math/base/special/roundsd/benchmark/c/native/benchmark.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c index 9c13c1d8c0ee..5a82f491f244 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c @@ -93,8 +93,6 @@ static double benchmark( void ) { double elapsed; double t; double v; - double n; - double b; double y; int i; From 5b3ac40b55f3357091b0860df1a244a0c968c07d Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 6 Apr 2025 10:48:02 +0530 Subject: [PATCH 11/23] chore: remove console Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../math/base/special/roundsd/benchmark/benchmark.native.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js index 9dcd87391a0d..90cb77325690 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/benchmark.native.js @@ -49,13 +49,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { for ( i = 0; i < b.iterations; i++ ) { y = roundsd( x[ i%x.length ], 2, 2 ); if ( isnan( y ) ) { - console.log('Generated value:', x); b.fail( 'should not return NaN' ); } } b.toc(); if ( isnan( y ) ) { - console.log('Generated value:', x); b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From 72ccb457d5cd7ab9674b54ba993298b4d777ca35 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 15 Apr 2025 01:34:22 -0700 Subject: [PATCH 12/23] test: update test messages --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/roundsd/test/test.js | 8 ++--- .../base/special/roundsd/test/test.native.js | 34 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.js b/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.js index c4555d2b73eb..134672a62568 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.js @@ -239,19 +239,19 @@ tape( 'if the function encounters overflow, the function returns the input value x = 3.1468234343023397; v = roundsd( x, 1000, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); x = -3.1468234343023397; v = roundsd( x, 1000, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); x = 9007199254740000; v = roundsd( x, 320, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); x = -9007199254740000; v = roundsd( x, 320, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js index 9c13e44ebb9e..276fe956ea0a 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/test/test.native.js @@ -57,7 +57,7 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v; v = roundsd( NaN, 2, 2 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -66,10 +66,10 @@ tape( 'the function returns `NaN` if provided `n < 1`', opts, function test( t ) var v; v = roundsd( PI, 0, 10 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = roundsd( PI, -1, 10 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -78,10 +78,10 @@ tape( 'the function returns `NaN` if provided `b = +-infinity`', opts, function var v; v = roundsd( PI, 2, PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = roundsd( PI, 2, NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -90,23 +90,23 @@ tape( 'the function returns `NaN` if provided `b <= 0`', opts, function test( t var v; v = roundsd( PI, 2, 0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); v = roundsd( PI, 2, -1 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = roundsd( PINF, 5, 10 ); - t.strictEqual( v, PINF, 'returns +infinity' ); + t.strictEqual( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) { var v = roundsd( NINF, 3, 10 ); - t.strictEqual( v, NINF, 'returns -infinity' ); + t.strictEqual( v, NINF, 'returns expected value' ); t.end(); }); @@ -114,10 +114,10 @@ tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v; v = roundsd( -0.0, 1, 10 ); - t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); v = roundsd( -0.0, 2, 10 ); - t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); @@ -126,10 +126,10 @@ tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { var v; v = roundsd( 0.0, 1, 10 ); - t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); v = roundsd( +0.0, 2, 10 ); - t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); t.end(); }); @@ -218,19 +218,19 @@ tape( 'if the function encounters overflow, the function returns the input value x = 3.1468234343023397; v = roundsd( x, 1000, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); x = -3.1468234343023397; v = roundsd( x, 1000, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); x = 9007199254740000; v = roundsd( x, 320, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); x = -9007199254740000; v = roundsd( x, 320, 10 ); - t.strictEqual( v, x, 'returns the input value' ); + t.strictEqual( v, x, 'returns expected value' ); t.end(); }); From 7c2e6b46cf4b9c9b8553cb69860a67f2d09a59c4 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 15 Apr 2025 01:35:04 -0700 Subject: [PATCH 13/23] bench: move random number generation outside the benchmarking loops --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/special/roundsd/benchmark/c/native/benchmark.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c index 5a82f491f244..f133a75aab15 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double v[ 100 ]; double elapsed; double t; - double v; double y; int i; + for ( i = 0; i < 100; i++ ) { + v[ i ] = ( 1000.0*rand_double() ) - 500.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - v = ( 1000.0*rand_double() ) - 500.0; - y = stdlib_base_roundsd( v, 5, 10 ); + y = stdlib_base_roundsd( v[ i%100 ], 5, 10 ); if ( y != y ) { printf( "should not return NaN\n" ); break; From 860ebb1f0df32c2be7b84e4577d863772e2c898d Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 15 Apr 2025 01:35:52 -0700 Subject: [PATCH 14/23] docs: fix C script for generating examples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsd/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md index 18ddc4413447..c77d1c98b692 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md @@ -149,16 +149,16 @@ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ); ### Examples ```c -#include "stdlib/math/base/special/roundsd..h" +#include "stdlib/math/base/special/roundsd.h" #include int main( void ) { - const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 }; + const double x[] = { 3.143546, -3.142635, 0.0, 0.0/0.0 }; double y; int i; for ( i = 0; i < 4; i++ ) { - y = stdlib_base_roundsd( x[ i ], -2, 10 ); + y = stdlib_base_roundsd( x[ i ], 2, 10 ); printf( "roundsd(%lf) = %lf\n", x[ i ], y ); } } From d9eefe3f7f71279dd8ef81ba4d8ae7abce406f88 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 19 Apr 2025 10:03:23 +0530 Subject: [PATCH 15/23] chore: add minor changes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/roundsd/README.md | 21 +- .../math/base/special/roundsd/docs/repl.txt | 3 +- .../special/roundsd/docs/types/index.d.ts | 2 +- .../stdlib/math/base/special/roundsd.h | 2 +- .../math/base/special/roundsd/lib/index.js | 2 +- .../math/base/special/roundsd/lib/main.js | 2 +- .../math/base/special/roundsd/lib/native.js | 2 +- .../math/base/special/roundsd/manifest.json | 200 +++++++++--------- .../math/base/special/roundsd/package.json | 2 +- .../math/base/special/roundsd/src/main.c | 11 +- 10 files changed, 131 insertions(+), 116 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md index c77d1c98b692..ebcbda3fc560 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md @@ -20,7 +20,7 @@ limitations under the License. # roundsd -> Round a numeric value to the nearest number with `n` significant figures. +> Rounds a double-precision floating-point number to the nearest value with `n` significant figures.
@@ -113,7 +113,7 @@ logEachMap( 'x: %0.4f. y: %d. Rounded: %0.4f.', x, 5, roundsd ); #### stdlib_base_roundsd( x, n, b ) -Rounds a `numeric` value to the nearest `number` with `n` significant figures. +Rounds a double-precision floating-point number to the nearest value with `n` significant figures. ```c double v = stdlib_base_roundsd( 3.141592653589793, 3, 10 ); @@ -176,6 +176,15 @@ int main( void ) { @@ -186,6 +195,14 @@ int main( void ) { +[@stdlib/math/base/special/ceilsd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ceilsd + +[@stdlib/math/base/special/floorsd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/floorsd + +[@stdlib/math/base/special/round]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/round + +[@stdlib/math/base/special/truncsd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/truncsd +
diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt index f93cfae50f92..6b8d8b134412 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt @@ -1,6 +1,7 @@ {{alias}}( x, n[, b] ) - Rounds a numeric value to the nearest number with `n` significant figures. + Rounds a double-precision floating-point number to the nearest + value with `n` significant figures. Parameters ---------- diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/roundsd/docs/types/index.d.ts index 1d8e6909a884..067da3159d3a 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/docs/types/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* Rounds a numeric value to the nearest number with \\(n\\) significant figures. +* Rounds a double-precision floating-point number to the nearest value with `n` significant figures. * * @param x - input value * @param n - number of significant figures diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h b/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h index 505acff829aa..862243fd8037 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h @@ -29,7 +29,7 @@ extern "C" { #endif /** -* Rounds a numeric value to the nearest number with \\(n\\) significant figures. +* Rounds a double-precision floating-point number to the nearest value with \\(n\\) significant figures. */ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/index.js b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/index.js index bb4438254976..2d44940e4ae2 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Round a numeric value to the nearest number with `n` significant figures. +* Round a double-precision floating-point number to the nearest value with `n` significant figures. * * @module @stdlib/math/base/special/roundsd * diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/main.js b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/main.js index 549eccd55067..711585553429 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/main.js @@ -34,7 +34,7 @@ var round = require( '@stdlib/math/base/special/round' ); // MAIN // /** -* Rounds a numeric value to the nearest number with \\(n\\) significant figures. +* Rounds a double-precision floating-point number to the nearest value with `n` significant figures. * * @param {number} x - input value * @param {PositiveInteger} n - number of significant figures diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js index 5fe025744db7..5db03b781340 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Rounds a numeric value to the nearest number with \\(n\\) significant figures. +* Rounds a double-precision floating-point number to the nearest value with `n` significant figures. * * @private * @param {number} x - input value diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/manifest.json b/lib/node_modules/@stdlib/math/base/special/roundsd/manifest.json index ddebb5155941..c87297416f66 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/manifest.json @@ -1,102 +1,102 @@ { - "options": { - "task": "build" + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "task": "build", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/napi/ternary", - "@stdlib/math/base/special/abs", - "@stdlib/math/base/special/pow", - "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/ln", - "@stdlib/math/base/special/floor", - "@stdlib/number/float64/base/exponent", - "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/special/round", - "@stdlib/math/base/assert/is-nan" - ] - }, - { - "task": "benchmark", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/special/abs", - "@stdlib/math/base/special/pow", - "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/ln", - "@stdlib/math/base/special/floor", - "@stdlib/number/float64/base/exponent", - "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/special/round", - "@stdlib/math/base/assert/is-nan" - ] - }, - { - "task": "examples", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/special/abs", - "@stdlib/math/base/special/pow", - "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/ln", - "@stdlib/math/base/special/floor", - "@stdlib/number/float64/base/exponent", - "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/special/round", - "@stdlib/math/base/assert/is-nan" - ] - } - ] - } + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/ternary", + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/pow", + "@stdlib/math/base/special/log10", + "@stdlib/math/base/special/ln", + "@stdlib/math/base/special/floor", + "@stdlib/number/float64/base/exponent", + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/special/round", + "@stdlib/math/base/assert/is-nan" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/pow", + "@stdlib/math/base/special/log10", + "@stdlib/math/base/special/ln", + "@stdlib/math/base/special/floor", + "@stdlib/number/float64/base/exponent", + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/special/round", + "@stdlib/math/base/assert/is-nan" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs", + "@stdlib/math/base/special/pow", + "@stdlib/math/base/special/log10", + "@stdlib/math/base/special/ln", + "@stdlib/math/base/special/floor", + "@stdlib/number/float64/base/exponent", + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/special/round", + "@stdlib/math/base/assert/is-nan" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/package.json b/lib/node_modules/@stdlib/math/base/special/roundsd/package.json index 233856dad3ae..46b090f319e7 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/package.json +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/roundsd", "version": "0.0.0", - "description": "Round a numeric value to the nearest number with N significant figures.", + "description": "Rounds a double-precision floating-point number to the nearest value with N significant figures.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index 4c6ee01a30c5..6f98f1535a76 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -16,7 +16,6 @@ * limitations under the License. */ - // MODULES // #include "stdlib/math/base/assert/is_nan.h" @@ -34,12 +33,12 @@ // MAIN // /** -* Rounds a numeric value to the nearest number with \\(n\\) significant figures. +* Rounds a double-precision floating-point number to the nearest value with \\(n\\) significant figures. * * @param x input value * @param n number of significant figures * @param b base -* @returns rounded value +* @return rounded value * * @example * double v = stdlib_base_roundsd( 3.141592653589793, 3, 10 ); @@ -58,11 +57,9 @@ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ) { } if ( b == 10 ) { exp = stdlib_base_log10( stdlib_base_abs( x ) ); - } - else if ( b == 2 ) { + } else if ( b == 2 ) { exp = stdlib_base_float64_exponent( stdlib_base_abs( x ) ); - } - else { + } else { exp = stdlib_base_ln( stdlib_base_abs(x) ) / stdlib_base_ln( b ); } exp = stdlib_base_floor( exp - n + 1.0 ); From cf8cced9f7565b6e90e69c88d030197fbd856194 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 18 Apr 2025 23:59:39 -0700 Subject: [PATCH 16/23] docs: update description Signed-off-by: Athan --- lib/node_modules/@stdlib/math/base/special/roundsd/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md index ebcbda3fc560..cb39d9f6977f 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md @@ -32,7 +32,7 @@ var roundsd = require( '@stdlib/math/base/special/roundsd' ); #### roundsd( x, n\[, b] ) -Rounds a `numeric` value to the nearest `number` with `n` significant figures. +Rounds a double-precision floating-point number to the nearest value with `n` significant figures. ```javascript var v = roundsd( 3.141592653589793, 3 ); From 5e16e2914990573fa9b25575b14f602ed9d7099e Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 00:00:03 -0700 Subject: [PATCH 17/23] docs: fix description Signed-off-by: Athan --- lib/node_modules/@stdlib/math/base/special/roundsd/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md index cb39d9f6977f..f219dc7a20ce 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/README.md @@ -20,7 +20,7 @@ limitations under the License. # roundsd -> Rounds a double-precision floating-point number to the nearest value with `n` significant figures. +> Round a double-precision floating-point number to the nearest value with `n` significant figures.
From fa48133a10e7d6ac990ae011b69e9c58091f06bf Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 00:00:54 -0700 Subject: [PATCH 18/23] docs: fix line wrapping Signed-off-by: Athan --- .../@stdlib/math/base/special/roundsd/docs/repl.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt index 6b8d8b134412..d652cccd9e3e 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( x, n[, b] ) - Rounds a double-precision floating-point number to the nearest - value with `n` significant figures. + Rounds a double-precision floating-point number to the nearest value with + `n` significant figures. Parameters ---------- From 0d5ce2ac03ea9222fbd55b3a62abd30896953124 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 00:01:54 -0700 Subject: [PATCH 19/23] style: remove TeX and use backticks to be consistent with elsewhere Signed-off-by: Athan --- .../special/roundsd/include/stdlib/math/base/special/roundsd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h b/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h index 862243fd8037..9bf90f45534c 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/include/stdlib/math/base/special/roundsd.h @@ -29,7 +29,7 @@ extern "C" { #endif /** -* Rounds a double-precision floating-point number to the nearest value with \\(n\\) significant figures. +* Rounds a double-precision floating-point number to the nearest value with `n` significant figures. */ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ); From 56061f52635496f1ffb2666d283246e5e4d342c7 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 00:02:54 -0700 Subject: [PATCH 20/23] docs: fix description Signed-off-by: Athan --- lib/node_modules/@stdlib/math/base/special/roundsd/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/package.json b/lib/node_modules/@stdlib/math/base/special/roundsd/package.json index 46b090f319e7..14b96f4bdd49 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/package.json +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/roundsd", "version": "0.0.0", - "description": "Rounds a double-precision floating-point number to the nearest value with N significant figures.", + "description": "Round a double-precision floating-point number to the nearest value with N significant figures.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From 77905690d0303e068f0553ca451ff2052e44ee7a Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 00:03:29 -0700 Subject: [PATCH 21/23] style: use consistent markup Signed-off-by: Athan --- lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index 6f98f1535a76..aacfe659d12e 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -33,7 +33,7 @@ // MAIN // /** -* Rounds a double-precision floating-point number to the nearest value with \\(n\\) significant figures. +* Rounds a double-precision floating-point number to the nearest value with `n` significant figures. * * @param x input value * @param n number of significant figures From 423088748995efa66e0c479c8ba6fc9bc7923c63 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 00:04:06 -0700 Subject: [PATCH 22/23] style: use consistent spacing Signed-off-by: Athan --- lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index aacfe659d12e..f0396dee9ceb 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -60,7 +60,7 @@ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ) { } else if ( b == 2 ) { exp = stdlib_base_float64_exponent( stdlib_base_abs( x ) ); } else { - exp = stdlib_base_ln( stdlib_base_abs(x) ) / stdlib_base_ln( b ); + exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( b ); } exp = stdlib_base_floor( exp - n + 1.0 ); s = stdlib_base_pow( b, stdlib_base_abs( exp ) ); From ecf314febf781a6edaecdcedc5e00e4e5b3ca80a Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 19 Apr 2025 00:04:26 -0700 Subject: [PATCH 23/23] style: add missing space Signed-off-by: Athan --- lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c index f0396dee9ceb..723f5b326c9d 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsd/src/main.c @@ -50,7 +50,7 @@ double stdlib_base_roundsd( const double x, const int32_t n, const int32_t b ) { double y; if ( stdlib_base_is_nan( x ) || n < 1 ) { - return 0.0/0.0; //NaN + return 0.0/0.0; // NaN } if ( stdlib_base_is_infinite( x ) || x == 0.0 ) { return x;