From a0c1fc412ba52e8a08951c4858e30660f24d2f3f Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 13 Jul 2024 10:55:51 +0530 Subject: [PATCH 01/10] docs: update boost version in math/base/special/digamma --- lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js | 2 +- lib/node_modules/@stdlib/math/base/special/digamma/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js b/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js index c847a65e8fc0..8dd7c1d8f52d 100644 --- a/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js @@ -18,7 +18,7 @@ * * ## Notice * -* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html}. The implementation follows the original but has been modified for JavaScript. +* The original C++ code and copyright notice are from the [Boost library]{@link https://www.boost.org/doc/libs/1_85_0/boost/math/special_functions/digamma.hpp}. The implementation follows the original but has been modified for JavaScript. * * ```text * (C) Copyright John Maddock 2006. diff --git a/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c b/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c index bd1ed84759f6..54049b38d317 100644 --- a/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c @@ -18,7 +18,7 @@ * * ## Notice * -* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html}. The implementation follows the original but has been modified for JavaScript. +* The original C++ code and copyright notice are from the [Boost library]{@link https://www.boost.org/doc/libs/1_85_0/boost/math/special_functions/digamma.hpp}. The implementation follows the original but has been modified for JavaScript. * * ```text * (C) Copyright John Maddock 2006. From 2b9a7bcfabd4cb809b4b4041ead9b0a817dc0084 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 13 Jul 2024 10:58:46 +0530 Subject: [PATCH 02/10] Revert "docs: update boost version in math/base/special/digamma" This reverts commit a0c1fc412ba52e8a08951c4858e30660f24d2f3f. --- lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js | 2 +- lib/node_modules/@stdlib/math/base/special/digamma/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js b/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js index 8dd7c1d8f52d..c847a65e8fc0 100644 --- a/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/digamma/lib/main.js @@ -18,7 +18,7 @@ * * ## Notice * -* The original C++ code and copyright notice are from the [Boost library]{@link https://www.boost.org/doc/libs/1_85_0/boost/math/special_functions/digamma.hpp}. The implementation follows the original but has been modified for JavaScript. +* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html}. The implementation follows the original but has been modified for JavaScript. * * ```text * (C) Copyright John Maddock 2006. diff --git a/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c b/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c index 54049b38d317..bd1ed84759f6 100644 --- a/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/digamma/src/main.c @@ -18,7 +18,7 @@ * * ## Notice * -* The original C++ code and copyright notice are from the [Boost library]{@link https://www.boost.org/doc/libs/1_85_0/boost/math/special_functions/digamma.hpp}. The implementation follows the original but has been modified for JavaScript. +* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/digamma.html}. The implementation follows the original but has been modified for JavaScript. * * ```text * (C) Copyright John Maddock 2006. From b345bfe5a9ccfdc0b17b045a8ecffaf45b609f5b Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 20 Aug 2024 19:13:34 +0530 Subject: [PATCH 03/10] refactor: use stdlib fmod and DDD_D napi function --- .../math/base/special/wrap/lib/main.js | 3 +- .../math/base/special/wrap/manifest.json | 44 ++++++++- .../math/base/special/wrap/src/addon.c | 96 +------------------ .../@stdlib/math/base/special/wrap/src/main.c | 13 ++- 4 files changed, 53 insertions(+), 103 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js index b38447fe4896..c722a7cc5389 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js @@ -22,6 +22,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var trunc = require( '@stdlib/math/base/special/trunc' ); +var fmod = require( '@stdlib/math/base/special/fmod' ); // MAIN // @@ -91,7 +92,7 @@ function wrap( v, min, max ) { if ( v < min ) { v += delta * ( trunc( (min-v)/delta ) + 1.0 ); } - return min + ( (v-min) % delta ); + return min + ( fmod( ( v - min ), delta ) ); } diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json index d89e21f11198..618251f2c7d3 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json @@ -1,5 +1,7 @@ { - "options": {}, + "options": { + "task": "build" + }, "fields": [ { "field": "src", @@ -24,6 +26,7 @@ ], "confs": [ { + "task": "build", "src": [ "./src/main.c" ], @@ -33,8 +36,45 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/math/base/napi/ternary", "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/trunc" + "@stdlib/math/base/special/trunc", + "@stdlib/math/base/special/fmod", + "@stdlib/math/base/special/abs" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/trunc", + "@stdlib/math/base/special/fmod", + "@stdlib/math/base/special/abs" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/trunc", + "@stdlib/math/base/special/fmod", + "@stdlib/math/base/special/abs" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c b/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c index da1c76652da1..a2404d55ee2c 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c @@ -17,97 +17,7 @@ */ #include "stdlib/math/base/special/wrap.h" -#include -#include +#include "stdlib/math/base/napi/ternary.h" -/** -* Receives JavaScript callback invocation data. -* -* @param env environment under which the function is invoked -* @param info callback data -* @return Node-API value -*/ -static napi_value addon( napi_env env, napi_callback_info info ) { - napi_status status; - - // Get callback arguments: - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - // Check whether we were provided the correct number of arguments: - if ( argc < 3 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Insufficient arguments." ); - assert( status == napi_ok ); - return NULL; - } - if ( argc > 3 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Too many arguments." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double v; - status = napi_get_value_double( env, argv[ 0 ], &v ); - assert( status == napi_ok ); - - double min; - status = napi_get_value_double( env, argv[ 1 ], &min ); - assert( status == napi_ok ); - - double max; - status = napi_get_value_double( env, argv[ 2 ], &max ); - assert( status == napi_ok ); - - double out = stdlib_base_wrap( v, min, max ); - - napi_value w; - status = napi_create_double( env, out, &w ); - assert( status == napi_ok ); - - return w; -} - -/** -* Initializes a Node-API module. -* -* @param env environment under which the function is invoked -* @param exports exports object -* @return main export -*/ -static napi_value init( napi_env env, napi_value exports ) { - napi_value fcn; - napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; -} - -NAPI_MODULE( NODE_GYP_MODULE_NAME, init ) +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_wrap ) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c b/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c index df46f5f9f30c..83cfde819a72 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c @@ -19,9 +19,8 @@ #include "stdlib/math/base/special/wrap.h" #include "stdlib/math/base/assert/is_nan.h" #include "stdlib/math/base/special/trunc.h" -#include - -// TODO: remove header and fmod once we have stdlib equivalent +#include "stdlib/math/base/special/fmod.h" +#include "stdlib/math/base/special/abs.h" /** * Wraps a value on the half-open interval [min,max). @@ -49,13 +48,13 @@ double stdlib_base_wrap( const double v, const double min, const double max ) { vc = v; // Normalize +-0 to +0... - if ( vc == 0.0 ) { + if ( stdlib_base_abs( vc ) == 0.0 ) { vc = 0.0; } - if ( minc == 0.0 ) { + if ( stdlib_base_abs( minc ) == 0.0 ) { minc = 0.0; } - if ( maxc == 0.0 ) { + if ( stdlib_base_abs( maxc ) == 0.0 ) { maxc = 0.0; } // Simple case where value is already within range... @@ -67,5 +66,5 @@ double stdlib_base_wrap( const double v, const double min, const double max ) { if ( vc < minc ) { vc += delta * ( stdlib_base_trunc( ( minc - vc ) / delta ) + 1.0 ); } - return minc + ( fmod( vc - minc, delta ) ); + return minc + ( stdlib_base_fmod( vc - minc, delta ) ); } From 71ff8eed88baf2afef52b27e0ee491d30e10830d Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 20 Aug 2024 19:15:18 +0530 Subject: [PATCH 04/10] refactor: use stdlib fmod and DDD_D napi function --- .../@stdlib/math/base/special/wrap/lib/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js index c722a7cc5389..035be858433a 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js @@ -23,6 +23,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var trunc = require( '@stdlib/math/base/special/trunc' ); var fmod = require( '@stdlib/math/base/special/fmod' ); +var abs = require( '@stdlib/math/base/special/abs' ); // MAIN // @@ -74,13 +75,13 @@ function wrap( v, min, max ) { return NaN; } // Normalize +-0 to +0... - if ( v === 0.0 ) { + if ( abs( v ) === 0.0 ) { v = 0.0; } - if ( min === 0.0 ) { + if ( abs( min ) === 0.0 ) { min = 0.0; } - if ( max === 0.0 ) { + if ( abs( max ) === 0.0 ) { max = 0.0; } // Simple case where value is already within range... From 4fb46d2b7f9a14e94fbc4f4cec82bb595eefd9e7 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 20 Aug 2024 21:22:08 +0530 Subject: [PATCH 05/10] Revert "refactor: use stdlib fmod and DDD_D napi function" This reverts commit 71ff8eed88baf2afef52b27e0ee491d30e10830d. --- .../@stdlib/math/base/special/wrap/lib/main.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js index 035be858433a..c722a7cc5389 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js @@ -23,7 +23,6 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var trunc = require( '@stdlib/math/base/special/trunc' ); var fmod = require( '@stdlib/math/base/special/fmod' ); -var abs = require( '@stdlib/math/base/special/abs' ); // MAIN // @@ -75,13 +74,13 @@ function wrap( v, min, max ) { return NaN; } // Normalize +-0 to +0... - if ( abs( v ) === 0.0 ) { + if ( v === 0.0 ) { v = 0.0; } - if ( abs( min ) === 0.0 ) { + if ( min === 0.0 ) { min = 0.0; } - if ( abs( max ) === 0.0 ) { + if ( max === 0.0 ) { max = 0.0; } // Simple case where value is already within range... From 64a15d3c65bc312b85d3ef35745e0637c2d6ad4c Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 20 Aug 2024 21:22:37 +0530 Subject: [PATCH 06/10] Revert "refactor: use stdlib fmod and DDD_D napi function" This reverts commit b345bfe5a9ccfdc0b17b045a8ecffaf45b609f5b. --- .../math/base/special/wrap/lib/main.js | 3 +- .../math/base/special/wrap/manifest.json | 44 +-------- .../math/base/special/wrap/src/addon.c | 96 ++++++++++++++++++- .../@stdlib/math/base/special/wrap/src/main.c | 13 +-- 4 files changed, 103 insertions(+), 53 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js index c722a7cc5389..b38447fe4896 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/wrap/lib/main.js @@ -22,7 +22,6 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var trunc = require( '@stdlib/math/base/special/trunc' ); -var fmod = require( '@stdlib/math/base/special/fmod' ); // MAIN // @@ -92,7 +91,7 @@ function wrap( v, min, max ) { if ( v < min ) { v += delta * ( trunc( (min-v)/delta ) + 1.0 ); } - return min + ( fmod( ( v - min ), delta ) ); + return min + ( (v-min) % delta ); } diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json index 618251f2c7d3..d89e21f11198 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json @@ -1,7 +1,5 @@ { - "options": { - "task": "build" - }, + "options": {}, "fields": [ { "field": "src", @@ -26,7 +24,6 @@ ], "confs": [ { - "task": "build", "src": [ "./src/main.c" ], @@ -36,45 +33,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/napi/ternary", "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/trunc", - "@stdlib/math/base/special/fmod", - "@stdlib/math/base/special/abs" - ] - }, - { - "task": "benchmark", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/trunc", - "@stdlib/math/base/special/fmod", - "@stdlib/math/base/special/abs" - ] - }, - { - "task": "examples", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/trunc", - "@stdlib/math/base/special/fmod", - "@stdlib/math/base/special/abs" + "@stdlib/math/base/special/trunc" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c b/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c index a2404d55ee2c..da1c76652da1 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/wrap/src/addon.c @@ -17,7 +17,97 @@ */ #include "stdlib/math/base/special/wrap.h" -#include "stdlib/math/base/napi/ternary.h" +#include +#include -// cppcheck-suppress shadowFunction -STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_wrap ) +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + napi_status status; + + // Get callback arguments: + size_t argc = 3; + napi_value argv[ 3 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + // Check whether we were provided the correct number of arguments: + if ( argc < 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Insufficient arguments." ); + assert( status == napi_ok ); + return NULL; + } + if ( argc > 3 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Too many arguments." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double v; + status = napi_get_value_double( env, argv[ 0 ], &v ); + assert( status == napi_ok ); + + double min; + status = napi_get_value_double( env, argv[ 1 ], &min ); + assert( status == napi_ok ); + + double max; + status = napi_get_value_double( env, argv[ 2 ], &max ); + assert( status == napi_ok ); + + double out = stdlib_base_wrap( v, min, max ); + + napi_value w; + status = napi_create_double( env, out, &w ); + assert( status == napi_ok ); + + return w; +} + +/** +* Initializes a Node-API module. +* +* @param env environment under which the function is invoked +* @param exports exports object +* @return main export +*/ +static napi_value init( napi_env env, napi_value exports ) { + napi_value fcn; + napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn ); + assert( status == napi_ok ); + return fcn; +} + +NAPI_MODULE( NODE_GYP_MODULE_NAME, init ) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c b/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c index 83cfde819a72..df46f5f9f30c 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/wrap/src/main.c @@ -19,8 +19,9 @@ #include "stdlib/math/base/special/wrap.h" #include "stdlib/math/base/assert/is_nan.h" #include "stdlib/math/base/special/trunc.h" -#include "stdlib/math/base/special/fmod.h" -#include "stdlib/math/base/special/abs.h" +#include + +// TODO: remove header and fmod once we have stdlib equivalent /** * Wraps a value on the half-open interval [min,max). @@ -48,13 +49,13 @@ double stdlib_base_wrap( const double v, const double min, const double max ) { vc = v; // Normalize +-0 to +0... - if ( stdlib_base_abs( vc ) == 0.0 ) { + if ( vc == 0.0 ) { vc = 0.0; } - if ( stdlib_base_abs( minc ) == 0.0 ) { + if ( minc == 0.0 ) { minc = 0.0; } - if ( stdlib_base_abs( maxc ) == 0.0 ) { + if ( maxc == 0.0 ) { maxc = 0.0; } // Simple case where value is already within range... @@ -66,5 +67,5 @@ double stdlib_base_wrap( const double v, const double min, const double max ) { if ( vc < minc ) { vc += delta * ( stdlib_base_trunc( ( minc - vc ) / delta ) + 1.0 ); } - return minc + ( stdlib_base_fmod( vc - minc, delta ) ); + return minc + ( fmod( vc - minc, delta ) ); } From b088cacbda37c8015494687d65afb4c821a3969a Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 20 Aug 2024 20:58:37 +0530 Subject: [PATCH 07/10] refactor: use stdlib fmod instead of built-in --- .../@stdlib/math/base/special/gcd/lib/binary_gcd.js | 10 +++++++--- .../@stdlib/math/base/special/gcd/manifest.json | 3 +++ .../@stdlib/math/base/special/gcd/src/main.c | 8 ++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js b/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js index ec498d96cb13..c8776de26d8f 100644 --- a/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js +++ b/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js @@ -18,6 +18,10 @@ 'use strict'; +// MODULES // + +var fmod = require( '@stdlib/math/base/special/fmod' ); + /** * Computes the greatest common divisor (gcd) using the binary GCD algorithm. * @@ -48,19 +52,19 @@ function gcd( a, b ) { return a; } // Reduce `a` and/or `b` to odd numbers and keep track of the greatest power of 2 dividing both `a` and `b`... - while ( a%2 === 0 && b%2 === 0 ) { + while ( fmod( a, 2 ) === 0 && fmod( b, 2 ) === 0 ) { a /= 2; // right shift b /= 2; // right shift k *= 2; // left shift } // Reduce `a` to an odd number... - while ( a%2 === 0 ) { + while ( fmod( a, 2 ) === 0 ) { a /= 2; // right shift } // Henceforth, `a` is always odd... while ( b ) { // Remove all factors of 2 in `b`, as they are not common... - while ( b%2 === 0 ) { + while ( fmod( b, 2 ) === 0 ) { b /= 2; // right shift } // `a` and `b` are both odd. Swap values such that `b` is the larger of the two values, and then set `b` to the difference (which is even)... diff --git a/lib/node_modules/@stdlib/math/base/special/gcd/manifest.json b/lib/node_modules/@stdlib/math/base/special/gcd/manifest.json index 5923f5a8913a..87c65f0cf256 100644 --- a/lib/node_modules/@stdlib/math/base/special/gcd/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/gcd/manifest.json @@ -38,6 +38,7 @@ "dependencies": [ "@stdlib/math/base/napi/binary", "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/fmod", "@stdlib/math/base/assert/is-integer", "@stdlib/constants/float64/pinf", "@stdlib/constants/float64/ninf" @@ -55,6 +56,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/fmod", "@stdlib/math/base/assert/is-integer", "@stdlib/constants/float64/pinf", "@stdlib/constants/float64/ninf" @@ -72,6 +74,7 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/fmod", "@stdlib/math/base/assert/is-integer", "@stdlib/constants/float64/pinf", "@stdlib/constants/float64/ninf" diff --git a/lib/node_modules/@stdlib/math/base/special/gcd/src/main.c b/lib/node_modules/@stdlib/math/base/special/gcd/src/main.c index c2ad2880caf4..81bcd3351ded 100644 --- a/lib/node_modules/@stdlib/math/base/special/gcd/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/gcd/src/main.c @@ -17,12 +17,12 @@ */ #include "stdlib/math/base/special/gcd.h" +#include "stdlib/math/base/special/fmod.h" #include "stdlib/math/base/assert/is_nan.h" #include "stdlib/math/base/assert/is_integer.h" #include "stdlib/constants/float64/pinf.h" #include "stdlib//constants/float64/ninf.h" #include -#include // 2^63 - 1 static const int64_t STDLIB_CONSTANT_INT64_MAX = 9223372036854775807; @@ -56,19 +56,19 @@ static double largeIntegers( const double a, const double b ) { k = 1.0; // Reduce `a` and/or `b` to odd numbers and keep track of the greatest power of 2 dividing both `a` and `b`... - while ( fmod( ac, 2.0 ) == 0.0 && fmod( bc, 2.0 ) == 0.0 ) { + while ( stdlib_base_fmod( ac, 2.0 ) == 0.0 && stdlib_base_fmod( bc, 2.0 ) == 0.0 ) { ac /= 2.0; // right shift bc /= 2.0; // right shift k *= 2.0; // left shift } // Reduce `a` to an odd number... - while ( fmod( ac, 2.0 ) == 0.0 ) { + while ( stdlib_base_fmod( ac, 2.0 ) == 0.0 ) { ac /= 2.0; // right shift } // Henceforth, `a` is always odd... while ( bc ) { // Remove all factors of 2 in `b`, as they are not common... - while ( fmod( bc, 2.0 ) == 0.0 ) { + while ( stdlib_base_fmod( bc, 2.0 ) == 0.0 ) { bc /= 2.0; // right shift } // `a` and `b` are both odd. Swap values such that `b` is the larger of the two values, and then set `b` to the difference (which is even)... From 5be7cd3e34a156ea3a6b3b32e942be5e11980ec0 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 20 Aug 2024 21:09:33 +0530 Subject: [PATCH 08/10] Update manifest.json Signed-off-by: Gunj Joshi --- lib/node_modules/@stdlib/math/base/special/wrap/manifest.json | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json index d89e21f11198..3be35cd079eb 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json @@ -39,4 +39,3 @@ } ] } - From b0d321d2eb1d9651c45958bfcadef4d3c94e03a6 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 20 Aug 2024 21:10:30 +0530 Subject: [PATCH 09/10] Update manifest.json Signed-off-by: Gunj Joshi --- lib/node_modules/@stdlib/math/base/special/wrap/manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json index 3be35cd079eb..d89e21f11198 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/wrap/manifest.json @@ -39,3 +39,4 @@ } ] } + From c28767f8f268c2df90f97257fc84f5ce4d6e7dd1 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 21 Aug 2024 05:21:13 +0530 Subject: [PATCH 10/10] Update binary_gcd.js Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/gcd/lib/binary_gcd.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js b/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js index c8776de26d8f..ec498d96cb13 100644 --- a/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js +++ b/lib/node_modules/@stdlib/math/base/special/gcd/lib/binary_gcd.js @@ -18,10 +18,6 @@ 'use strict'; -// MODULES // - -var fmod = require( '@stdlib/math/base/special/fmod' ); - /** * Computes the greatest common divisor (gcd) using the binary GCD algorithm. * @@ -52,19 +48,19 @@ function gcd( a, b ) { return a; } // Reduce `a` and/or `b` to odd numbers and keep track of the greatest power of 2 dividing both `a` and `b`... - while ( fmod( a, 2 ) === 0 && fmod( b, 2 ) === 0 ) { + while ( a%2 === 0 && b%2 === 0 ) { a /= 2; // right shift b /= 2; // right shift k *= 2; // left shift } // Reduce `a` to an odd number... - while ( fmod( a, 2 ) === 0 ) { + while ( a%2 === 0 ) { a /= 2; // right shift } // Henceforth, `a` is always odd... while ( b ) { // Remove all factors of 2 in `b`, as they are not common... - while ( fmod( b, 2 ) === 0 ) { + while ( b%2 === 0 ) { b /= 2; // right shift } // `a` and `b` are both odd. Swap values such that `b` is the larger of the two values, and then set `b` to the difference (which is even)...