diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/README.md b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/README.md index e257809e34d9..7a45f3b68821 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/README.md @@ -209,7 +209,7 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **n**: `[out] CBLAS_INT*` number of non-NaN elements. +- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements. ```c double stdlib_strided_dnannsumors( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n ); @@ -233,7 +233,7 @@ The function accepts the following arguments: - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **n**: `[out] CBLAS_INT*` number of non-NaN elements. +- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements. ```c double stdlib_strided_dnannsumors_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/benchmark/c/benchmark.length.c index c5c5c6c233f1..b120333bf970 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/benchmark/c/benchmark.length.c @@ -114,6 +114,7 @@ static double benchmark1( int iterations, int len ) { n = 0; t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar v = stdlib_strided_dnannsumors( len, x, 1, &n ); if ( v != v || n < 0 ) { printf( "should not return NaN\n" ); @@ -153,6 +154,7 @@ static double benchmark2( int iterations, int len ) { n = 0; t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar v = stdlib_strided_dnannsumors_ndarray( len, x, 1, 0, &n ); if ( v != v || n < 0 ) { printf( "should not return NaN\n" ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/lib/ndarray.js index af74b786a1ed..0e9968d27a3a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/lib/ndarray.js @@ -49,26 +49,24 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); function dnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) { var sum; var ix; - var io; var n; var i; sum = 0.0; - io = offsetOut; if ( N <= 0 ) { - out[ io ] = sum; - out[ io+strideOut ] = 0; + out[ offsetOut ] = sum; + out[ offsetOut+strideOut ] = 0; return out; } ix = offsetX; if ( strideX === 0 ) { if ( isnan( x[ ix ] ) ) { - out[ io ] = sum; - out[ io+strideOut ] = 0; + out[ offsetOut ] = sum; + out[ offsetOut+strideOut ] = 0; return out; } - out[ io ] = x[ ix ] * N; - out[ io+strideOut ] = N; + out[ offsetOut ] = x[ ix ] * N; + out[ offsetOut+strideOut ] = N; return out; } n = 0; @@ -79,8 +77,8 @@ function dnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) { } ix += strideX; } - out[ io ] = sum; - out[ io+strideOut ] = n; + out[ offsetOut ] = sum; + out[ offsetOut+strideOut ] = n; return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/addon.c index 5a454f42932e..b24fa014a9c2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/addon.c @@ -22,6 +22,8 @@ #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_strided_float64array.h" +#include "stdlib/strided/base/stride2offset.h" +#include #include /** @@ -39,17 +41,10 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 3 ); - int io; - if ( strideOut < 0 ) { - io = -strideOut; - } else { - io = 0; - } - - double *out = Out; + int64_t io = stdlib_strided_stride2offset( 2, strideOut ); CBLAS_INT n; - out[ io ] = API_SUFFIX(stdlib_strided_dnannsumors)( N, X, strideX, &n ); - out[ io + strideOut ] = (double)n; + Out[ io ] = API_SUFFIX(stdlib_strided_dnannsumors)( N, X, strideX, &n ); + Out[ io + strideOut ] = (double)n; return NULL; } @@ -71,11 +66,9 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 4 ); - int io = offsetOut; - double *out = Out; CBLAS_INT n; - out[ io ] = API_SUFFIX(stdlib_strided_dnannsumors_ndarray)( N, X, strideX, offsetX, &n ); - out[ io+strideOut ] = (double)n; + Out[ offsetOut ] = API_SUFFIX(stdlib_strided_dnannsumors_ndarray)( N, X, strideX, offsetX, &n ); + Out[ offsetOut+strideOut ] = (double)n; return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/main.c index a43cc7fd384f..2b6e74882e6f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dnannsumors/src/main.c @@ -27,7 +27,7 @@ * @param N number of indexed elements * @param X input array * @param strideX stride length -* @param n number of non-NaN elements +* @param n pointer for storing the number of non-NaN elements * @return output value */ double API_SUFFIX(stdlib_strided_dnannsumors)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n ) { @@ -42,13 +42,13 @@ double API_SUFFIX(stdlib_strided_dnannsumors)( const CBLAS_INT N, const double * * @param X input array * @param strideX stride length * @param offsetX starting index -* @param n number of non-NaN elements +* @param n pointer for storing the number of non-NaN elements * @return output value */ double API_SUFFIX(stdlib_strided_dnannsumors_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n ) { - double sum; CBLAS_INT ix; CBLAS_INT i; + double sum; sum = 0.0; *n = 0;