From fb7122cf6aca63ca1e953eab029b1fd1ba6e68ab Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sat, 25 Apr 2026 12:03:41 +0530 Subject: [PATCH] refactor(stats/strided/dnanmeanpn): replace inline 0.0/0.0 with STDLIB_CONSTANT_FLOAT64_NAN from stdlib/constants/float64/nan --- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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 --- --- .../@stdlib/stats/strided/dnanmeanpn/README.md | 7 ++++--- .../dnanmeanpn/benchmark/c/benchmark.length.c | 5 +++-- .../stats/strided/dnanmeanpn/examples/c/example.c | 3 ++- .../@stdlib/stats/strided/dnanmeanpn/manifest.json | 12 ++++++++---- .../@stdlib/stats/strided/dnanmeanpn/src/main.c | 5 +++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/README.md b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/README.md index 3688ad47ab3a..2f9134751948 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/README.md +++ b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/README.md @@ -199,6 +199,7 @@ console.log( v ); ```c #include "stdlib/stats/strided/dnanmeanpn.h" +#include "stdlib/constants/float64/nan.h" ``` #### stdlib_strided_dnanmeanpn( N, \*X, strideX ) @@ -206,7 +207,7 @@ console.log( v ); Computes arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm. ```c -const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 }; +const double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN }; double v = stdlib_strided_dnanmeanpn( 6, x, 2 ); // returns ~4.6667 @@ -227,7 +228,7 @@ double stdlib_strided_dnanmeanpn( const CBLAS_INT N, const double *X, const CBLA Computes the aithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics. ```c -const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 }; +const double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN }; double v = stdlib_strided_dnanmeanpn( 6, x, 2, 0 ); // returns ~4.6667 @@ -268,7 +269,7 @@ double stdlib_strided_dnanmeanpn_ndarray( const CBLAS_INT N, const double *X, co int main( void ) { // Create a strided array: - const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 }; + const double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN }; // Specify the number of elements: const int N = 6; diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/benchmark/c/benchmark.length.c index ce81ec85d19f..29878aadc537 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/benchmark/c/benchmark.length.c @@ -17,6 +17,7 @@ */ #include "stdlib/stats/strided/dnanmeanpn.h" +#include "stdlib/constants/float64/nan.h" #include #include #include @@ -103,7 +104,7 @@ static double benchmark1( int iterations, int len ) { for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { - x[ i ] = 0.0 / 0.0; // NaN + x[ i ] = STDLIB_CONSTANT_FLOAT64_NAN; } else { x[ i ] = ( rand_double()*20000.0 ) - 10000.0; } @@ -141,7 +142,7 @@ static double benchmark2( int iterations, int len ) { for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { - x[ i ] = 0.0 / 0.0; // NaN + x[ i ] = STDLIB_CONSTANT_FLOAT64_NAN; } else { x[ i ] = ( rand_double()*20000.0 ) - 10000.0; } diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/examples/c/example.c b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/examples/c/example.c index def80770b6e9..53eb9df6f193 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/examples/c/example.c @@ -18,10 +18,11 @@ #include "stdlib/stats/strided/dnanmeanpn.h" #include +#include "stdlib/constants/float64/nan.h" int main( void ) { // Create a strided array: - const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 }; + const double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN }; // Specify the number of elements: const int N = 6; diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/manifest.json b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/manifest.json index 99aaf0c4da72..055dc092d4fb 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/manifest.json +++ b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/manifest.json @@ -44,7 +44,8 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/create-double" + "@stdlib/napi/create-double", + "@stdlib/constants/float64/nan" ] }, { @@ -60,7 +61,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/constants/float64/nan" ] }, { @@ -76,7 +78,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/constants/float64/nan" ] }, { @@ -92,7 +95,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/constants/float64/nan" ] } ] diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/src/main.c b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/src/main.c index 94dff02840b8..96af930d85d3 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/src/main.c +++ b/lib/node_modules/@stdlib/stats/strided/dnanmeanpn/src/main.c @@ -19,6 +19,7 @@ #include "stdlib/stats/strided/dnanmeanpn.h" #include "stdlib/blas/base/shared.h" #include "stdlib/strided/base/stride2offset.h" +#include "stdlib/constants/float64/nan.h" /** * Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm. @@ -61,7 +62,7 @@ double API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( const CBLAS_INT N, const d double v; if ( N <= 0 ) { - return 0.0 / 0.0; // NaN + return STDLIB_CONSTANT_FLOAT64_NAN; } if ( N == 1 || strideX == 0 ) { return X[ offsetX ]; @@ -80,7 +81,7 @@ double API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( const CBLAS_INT N, const d ix += strideX; } if ( n == 0 ) { - return 0.0 / 0.0; // NaN + return STDLIB_CONSTANT_FLOAT64_NAN; } dn = (double)n; s /= dn;