From 4871b02e7ff60e33ecf51772a9ea550b4c830c6e Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Wed, 19 Feb 2025 17:12:20 +0530 Subject: [PATCH 1/5] feat: add C ndarray interface and refactor implementation --- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../stats/base/dnanvariancewd/README.md | 172 +++++++++++++++--- .../dnanvariancewd/benchmark/benchmark.js | 30 +-- .../benchmark/benchmark.native.js | 30 +-- .../benchmark/benchmark.ndarray.js | 30 +-- .../benchmark/benchmark.ndarray.native.js | 30 +-- .../benchmark/c/benchmark.length.c | 60 +++++- .../stats/base/dnanvariancewd/docs/repl.txt | 38 ++-- .../base/dnanvariancewd/docs/types/index.d.ts | 12 +- .../base/dnanvariancewd/examples/c/example.c | 9 +- .../base/dnanvariancewd/examples/index.js | 21 +-- .../stdlib/stats/base/dnanvariancewd.h | 9 +- .../base/dnanvariancewd/lib/dnanvariancewd.js | 57 +----- .../lib/dnanvariancewd.native.js | 9 +- .../stats/base/dnanvariancewd/lib/index.js | 7 +- .../stats/base/dnanvariancewd/lib/ndarray.js | 18 +- .../base/dnanvariancewd/lib/ndarray.native.js | 20 +- .../stats/base/dnanvariancewd/manifest.json | 18 +- .../stats/base/dnanvariancewd/src/addon.c | 26 ++- .../src/{dnanvariancewd.c => main.c} | 37 ++-- .../test/test.dnanvariancewd.js | 13 +- .../test/test.dnanvariancewd.native.js | 13 +- .../base/dnanvariancewd/test/test.ndarray.js | 13 +- .../test/test.ndarray.native.js | 13 +- 23 files changed, 414 insertions(+), 271 deletions(-) rename lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/{dnanvariancewd.c => main.c} (64%) diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md index 71a7c2eb6f25..e5f9034a04e5 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md @@ -98,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var dnanvariancewd = require( '@stdlib/stats/base/dnanvariancewd' ); ``` -#### dnanvariancewd( N, correction, x, stride ) +#### dnanvariancewd( N, correction, x, strideX ) Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values and using Welford's algorithm. @@ -116,39 +116,38 @@ The function has the following parameters: - **N**: number of indexed elements. - **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). - **x**: input [`Float64Array`][@stdlib/array/float64]. -- **stride**: index increment for `x`. +- **strideX**: index increment for `X`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `X`, + + ```javascript var Float64Array = require( '@stdlib/array/float64' ); var floor = require( '@stdlib/math/base/special/floor' ); -var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] ); -var N = floor( x.length / 2 ); +var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ] ); -var v = dnanvariancewd( N, 1, x, 2 ); +var v = dnanvariancewd( 5, 1, x, 2 ); // returns 6.25 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. - + ```javascript var Float64Array = require( '@stdlib/array/float64' ); var floor = require( '@stdlib/math/base/special/floor' ); -var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); +var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = dnanvariancewd( N, 1, x1, 2 ); +var v = dnanvariancewd( 5, 1, x1, 2 ); // returns 6.25 ``` -#### dnanvariancewd.ndarray( N, correction, x, stride, offset ) +#### dnanvariancewd.ndarray( N, correction, x, strideX, offsetX ) Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics. @@ -163,18 +162,19 @@ var v = dnanvariancewd.ndarray( x.length, 1, x, 1, 0 ); The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offset**: starting index for `X`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [variance][variance] for every other element in `X` starting from the second element -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [variance][variance] for every other value in `x` starting from the second value + ```javascript var Float64Array = require( '@stdlib/array/float64' ); var floor = require( '@stdlib/math/base/special/floor' ); -var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); +var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); -var v = dnanvariancewd.ndarray( N, 1, x, 2, 1 ); +var v = dnanvariancewd.ndarray( 5, 1, x, 2, 1 ); // returns 6.25 ``` @@ -200,18 +200,19 @@ var v = dnanvariancewd.ndarray( N, 1, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var dnanvariancewd = require( '@stdlib/stats/base/dnanvariancewd' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -50.0, 50.0 ); } + +var x = filledarrayBy( 10, 'float64', rand ); console.log( x ); var v = dnanvariancewd( x.length, 1, x, 1 ); @@ -222,6 +223,125 @@ console.log( v ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dnanvariancewd.h" +``` + +#### stdlib_strided_dnanvariancewd( N, correction, \*X, strideX ) + +Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm. + +```c +const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 }; + +double v = stdlib_strided_dnanvariancewd( 4, 1.0, x, 1 ); +// returns ~4.3333 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). +- **X**: `[in] double*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. + +```c +double stdlib_strided_dnanvariancewd( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_dnanvariancewd_ndarray( N, correction, \*X, strideX, offsetX ) + +Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics. + +```c +const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 }; + +double v = stdlib_strided_dnanvariancewd_ndarray( 4, 1.0, x, 1, 0 ); +// returns ~4.3333 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). +- **X**: `[in] double*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. + +```c +double stdlib_strided_dnanvariancewd_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dnanvariancewd.h" +#include + +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 }; + + // Specify the number of elements: + const int N = 6; + + // Specify the stride length: + const int strideX = 2; + + // Compute the variance: + double v = stdlib_strided_dnanvariancewd( N, 1.0, x, strideX ); + + // Print the result: + printf( "sample variance: %lf\n", v ); +} +``` + +
+ + + +
+ + + * * *
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js index 71a39db6630e..749d7ab63f84 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js @@ -21,16 +21,30 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dnanvariancewd = require( './../lib/dnanvariancewd.js' ); // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -39,17 +53,7 @@ var dnanvariancewd = require( './../lib/dnanvariancewd.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js index 70df64750a0b..1c19905fb51d 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,6 +41,19 @@ var opts = { // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -48,17 +62,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js index 54149e899e82..b40d77686013 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js @@ -21,16 +21,30 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dnanvariancewd = require( './../lib/ndarray.js' ); // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -39,17 +53,7 @@ var dnanvariancewd = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js index 501e7a0d6025..87bb1b607d1a 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,6 +41,19 @@ var opts = { // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -48,17 +62,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/c/benchmark.length.c index 00dbaa5d51f2..39a5537da80d 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/c/benchmark.length.c @@ -94,7 +94,7 @@ static double rand_double( void ) { * @param len array length * @return elapsed time in seconds */ -static double benchmark( int iterations, int len ) { +static double benchmark1( int iterations, int len ) { double elapsed; double x[ len ]; double v; @@ -102,11 +102,16 @@ static double benchmark( int iterations, int len ) { int i; for ( i = 0; i < len; i++ ) { - x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + if ( rand_double() < 0.2 ) { + x[ i ] = 0.0 / 0.0; // NaN + } else { + x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + } } v = 0.0; t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar v = stdlib_strided_dnanvariancewd( len, 1.0, x, 1 ); if ( v != v ) { printf( "should not return NaN\n" ); @@ -120,6 +125,44 @@ static double benchmark( int iterations, int len ) { return elapsed; } +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + double x[ len ]; + double v; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + if ( rand_double() < 0.2 ) { + x[ i ] = 0.0 / 0.0; // NaN + } else { + x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + } + } + v = 0.0; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + v = stdlib_strided_dnanvariancewd_ndarray( len, 1.0, x, 1, 0 ); + if ( v != v ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( v != v ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + /** * Main execution sequence. */ @@ -142,7 +185,18 @@ int main( void ) { for ( j = 0; j < REPEATS; j++ ) { count += 1; printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark( iter, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/repl.txt index b981b44b8c4b..684fdc923f50 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, correction, x, stride ) +{{alias}}( N, correction, x, strideX ) Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -34,8 +34,8 @@ x: Float64Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -49,22 +49,19 @@ > {{alias}}( x.length, 1, x, 1 ) ~4.3333 - // Using `N` and `stride` parameters: - > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, 1, x, stride ) + // Using `N` and stride parameters: + > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] ); + > {{alias}}( 4, 1, x, 2 ) ~4.3333 // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, 1, x1, stride ) + > {{alias}}( 4, 1, x1, 2 ) ~4.3333 -{{alias}}.ndarray( N, correction, x, stride, offset ) + +{{alias}}.ndarray( N, correction, x, strideX, offsetX ) Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics. @@ -94,10 +91,10 @@ x: Float64Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -113,9 +110,8 @@ ~4.3333 // Using offset parameter: - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, 1, x, 2, 1 ) + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); + > {{alias}}.ndarray( 4, 1, x, 2, 1 ) ~4.3333 See Also diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/types/index.d.ts index de3b8304ca6e..d4faefc9565a 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/docs/types/index.d.ts @@ -28,7 +28,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @returns variance * * @example @@ -39,7 +39,7 @@ interface Routine { * var v = dnanvariancewd( x.length, 1, x, 1 ); * // returns ~4.3333 */ - ( N: number, correction: number, x: Float64Array, stride: number ): number; + ( N: number, correction: number, x: Float64Array, strideX: number ): number; /** * Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics. @@ -47,8 +47,8 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @returns variance * * @example @@ -59,7 +59,7 @@ interface Routine { * var v = dnanvariancewd.ndarray( x.length, 1, x, 1, 0 ); * // returns ~4.3333 */ - ndarray( N: number, correction: number, x: Float64Array, stride: number, offset: number ): number; + ndarray( N: number, correction: number, x: Float64Array, strideX: number, offsetX: number ): number; } /** @@ -68,7 +68,7 @@ interface Routine { * @param N - number of indexed elements * @param correction - degrees of freedom adjustment * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @returns variance * * @example diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/c/example.c index 0ba86eea2877..cc34b1f1aba2 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/stats/base/dnanvariancewd.h" -#include #include int main( void ) { // Create a strided array: - 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, 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 }; // Specify the number of elements: - int64_t N = 6; + const int N = 6; // Specify the stride length: - int64_t stride = 2; + const int strideX = 2; // Compute the variance: - double v = stdlib_strided_dnanvariancewd( N, 1, x, stride ); + double v = stdlib_strided_dnanvariancewd( N, 1.0, x, strideX ); // Print the result: printf( "sample variance: %lf\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/index.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/index.js index a36486a899f0..05698bbbe604 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/examples/index.js @@ -18,22 +18,19 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var dnanvariancewd = require( './../lib' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( (randu()*100.0) - 50.0 ); +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; } + return uniform( -50.0, 50.0 ); } + +var x = filledarrayBy( 10, 'float64', rand ); console.log( x ); var v = dnanvariancewd( x.length, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/include/stdlib/stats/base/dnanvariancewd.h b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/include/stdlib/stats/base/dnanvariancewd.h index 62f4055af1cd..360d6bfc90ab 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/include/stdlib/stats/base/dnanvariancewd.h +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/include/stdlib/stats/base/dnanvariancewd.h @@ -19,7 +19,7 @@ #ifndef STDLIB_STATS_BASE_DNANVARIANCEWD_H #define STDLIB_STATS_BASE_DNANVARIANCEWD_H -#include +#include "stdlib/blas/base/shared.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -31,7 +31,12 @@ extern "C" { /** * Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm. */ -double stdlib_strided_dnanvariancewd( const int64_t N, const double correction, const double *X, const int64_t stride ); +double API_SUFFIX(stdlib_strided_dnanvariancewd)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ); + +/** +* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics. +*/ +double API_SUFFIX(stdlib_strided_dnanvariancewd_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.js index b2ed3c872dc7..75bdf4f3f9ad 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.js @@ -18,6 +18,12 @@ 'use strict'; +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + // MAIN // /** @@ -31,61 +37,18 @@ * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float64Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} variance * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; -* -* var v = dnanvariancewd( N, 1, x, 1 ); +* var v = dnanvariancewd( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function dnanvariancewd( N, correction, x, stride ) { - var delta; - var mu; - var M2; - var ix; - var nc; - var v; - var n; - var i; - - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - v = x[ 0 ]; - if ( v === v && N-correction > 0.0 ) { - return 0.0; - } - return NaN; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - M2 = 0.0; - mu = 0.0; - n = 0; - for ( i = 0; i < N; i++ ) { - v = x[ ix ]; - if ( v === v ) { - delta = v - mu; - n += 1; - mu += delta / n; - M2 += delta * ( v - mu ); - } - ix += stride; - } - nc = n - correction; - if ( nc <= 0.0 ) { - return NaN; - } - return M2 / nc; +function dnanvariancewd( N, correction, x, strideX ) { + return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.native.js index 5059fa377c9f..96caf34672ba 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/dnanvariancewd.native.js @@ -31,20 +31,19 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float64Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} variance * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = dnanvariancewd( N, 1, x, 1 ); +* var v = dnanvariancewd( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function dnanvariancewd( N, correction, x, stride ) { - return addon( N, correction, x, stride ); +function dnanvariancewd( N, correction, x, strideX ) { + return addon( N, correction, x, strideX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/index.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/index.js index 257fca515919..9f3930df0f24 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/index.js @@ -28,20 +28,17 @@ * var dnanvariancewd = require( '@stdlib/stats/base/dnanvariancewd' ); * * var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = dnanvariancewd( N, 1, x, 1 ); +* var v = dnanvariancewd( x.length, 1, x, 1 ); * // returns ~4.3333 * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dnanvariancewd = require( '@stdlib/stats/base/dnanvariancewd' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = dnanvariancewd.ndarray( N, 1, x, 2, 1 ); +* var v = dnanvariancewd.ndarray( 5, 1, x, 2, 1 ); * // returns 6.25 */ diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.js index 94063a2b6242..8d242d57c60a 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.js @@ -31,21 +31,19 @@ * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float64Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} variance * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = dnanvariancewd( N, 1, x, 2, 1 ); +* var v = dnanvariancewd( 5, 1, x, 2, 1 ); * // returns 6.25 */ -function dnanvariancewd( N, correction, x, stride, offset ) { +function dnanvariancewd( N, correction, x, strideX, offsetX ) { var delta; var mu; var M2; @@ -58,14 +56,14 @@ function dnanvariancewd( N, correction, x, stride, offset ) { if ( N <= 0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { - v = x[ offset ]; + if ( N === 1 || strideX === 0 ) { + v = x[ offsetX ]; if ( v === v && N-correction > 0.0 ) { return 0.0; } return NaN; } - ix = offset; + ix = offsetX; M2 = 0.0; mu = 0.0; n = 0; @@ -77,7 +75,7 @@ function dnanvariancewd( N, correction, x, stride, offset ) { mu += delta / n; M2 += delta * ( v - mu ); } - ix += stride; + ix += strideX; } nc = n - correction; if ( nc <= 0.0 ) { diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.native.js index 653396c6c2f8..568250c1be3c 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); -var addon = require( './dnanvariancewd.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -32,27 +31,20 @@ var addon = require( './dnanvariancewd.native.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {number} correction - degrees of freedom adjustment * @param {Float64Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} variance * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = dnanvariancewd( N, 1, x, 2, 1 ); +* var v = dnanvariancewd( 5, 1, x, 2, 1 ); * // returns 6.25 */ -function dnanvariancewd( N, correction, x, stride, offset ) { - var view; - if ( stride < 0 ) { - offset += (N-1) * stride; - } - view = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len - return addon( N, correction, view, stride ); +function dnanvariancewd( N, correction, x, strideX, offsetX ) { + return addon.ndarray( N, correction, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json index 28218b0c69df..ba5efb659aa8 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,17 +28,18 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ - "./src/dnanvariancewd.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -48,8 +50,9 @@ }, { "task": "benchmark", + "wasm": false, "src": [ - "./src/dnanvariancewd.c" + "./src/main.c" ], "include": [ "./include" @@ -62,8 +65,9 @@ }, { "task": "examples", + "wasm": false, "src": [ - "./src/dnanvariancewd.c" + "./src/main.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c index 02d59ac6ee8b..dd0bfbc685a5 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c @@ -17,6 +17,8 @@ */ #include "stdlib/stats/base/dnanvariancewd.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_double.h" @@ -37,9 +39,27 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 ); STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 2 ); - STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dnanvariancewd( N, correction, X, stride ), v ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dnanvariancewd)( N, correction, X, strideX ), v ); + return v; +} + +/** +* 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_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 5 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dnanvariancewd_ndarray)( N, correction, X, strideX, offsetX ), v ); return v; } -STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/dnanvariancewd.c b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/main.c similarity index 64% rename from lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/dnanvariancewd.c rename to lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/main.c index d91f74bbae78..8b31866119c9 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/dnanvariancewd.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/main.c @@ -30,14 +30,29 @@ * @param N number of indexed elements * @param correction degrees of freedom adjustment * @param X input array -* @param stride stride length +* @param strideX stride length * @return output value */ -double stdlib_strided_dnanvariancewd( const int64_t N, const double correction, const double *X, const int64_t stride ) { +double API_SUFFIX(stdlib_strided_dnanvariancewd)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(stdlib_strided_dnanvariancewd_ndarray)( N, correction, X, strideX, ox ); +} + +/** +* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics. +* +* @param N number of indexed elements +* @param correction degrees of freedom adjustment +* @param X input array +* @param strideX stride length +* @param offsetX starting index for X +* @return output value +*/ +double API_SUFFIX(stdlib_strided_dnanvariancewd_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { double delta; - int64_t ix; - int64_t n; - int64_t i; + CBLAS_INT ix; + CBLAS_INT n; + CBLAS_INT i; double M2; double nc; double mu; @@ -46,18 +61,14 @@ double stdlib_strided_dnanvariancewd( const int64_t N, const double correction, if ( N <= 0 ) { return 0.0 / 0.0; // NaN } - if ( N == 1 || stride == 0 ) { - v = X[ 0 ]; + if ( N == 1 || strideX == 0 ) { + v = X[ offsetX ]; if ( v == v && (double)N-correction > 0.0 ) { return 0.0; } return 0.0 / 0.0; // NaN } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } + ix = offsetX; M2 = 0.0; mu = 0.0; n = 0; @@ -69,7 +80,7 @@ double stdlib_strided_dnanvariancewd( const int64_t N, const double correction, mu += delta / (double)n; M2 += delta * ( v - mu ); } - ix += stride; + ix += strideX; } nc = (double)n - correction; if ( nc <= 0.0 ) { diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.js index 1057ce454558..5ce721fd95cb 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var dnanvariancewd = require( './../lib/dnanvariancewd.js' ); @@ -213,7 +212,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -230,15 +228,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, 2 ); + v = dnanvariancewd( 5, 1, x, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -255,9 +251,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 4.0, // 0 2.0 ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, -2 ); + v = dnanvariancewd( 5, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); x = new Float64Array( 1e3 ); @@ -295,7 +290,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -313,9 +307,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dnanvariancewd( N, 1, x1, 2 ); + v = dnanvariancewd( 5, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.native.js index 418ed6461b51..1e7b2256e307 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.dnanvariancewd.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -222,7 +221,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -239,15 +237,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, 2 ); + v = dnanvariancewd( 5, 1, x, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -264,9 +260,8 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 4.0, // 0 2.0 ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, -2 ); + v = dnanvariancewd( 5, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); x = new Float64Array( 1e3 ); @@ -304,7 +299,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -322,9 +316,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dnanvariancewd( N, 1, x1, 2 ); + v = dnanvariancewd( 5, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.js index 9973229b63d0..a5d153d4a6d0 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var dnanvariancewd = require( './../lib/ndarray.js' ); @@ -213,7 +212,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -230,15 +228,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, 2, 0 ); + v = dnanvariancewd( 5, 1, x, 2, 0 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -255,9 +251,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 4.0, // 0 2.0 ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, -2, 8 ); + v = dnanvariancewd( 5, 1, x, -2, 8 ); t.strictEqual( v, 6.25, 'returns expected value' ); x = new Float64Array( 1e3 ); @@ -293,7 +288,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -309,9 +303,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, 2, 1 ); + v = dnanvariancewd( 5, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.native.js index 6d554ec97233..8b48196852ad 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -222,7 +221,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -239,15 +237,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, 2, 0 ); + v = dnanvariancewd( 5, 1, x, 2, 0 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -264,9 +260,8 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 4.0, // 0 2.0 ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, -2, 8 ); + v = dnanvariancewd( 5, 1, x, -2, 8 ); t.strictEqual( v, 6.25, 'returns expected value' ); x = new Float64Array( 1e3 ); @@ -302,7 +297,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -318,9 +312,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = dnanvariancewd( N, 1, x, 2, 1 ); + v = dnanvariancewd( 5, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); From 83d2596c60147342e6cd6e6519d5c19de294667f Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Wed, 19 Feb 2025 17:23:06 +0530 Subject: [PATCH 2/5] chore: updated mainfest file and c implementation --- 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: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../stats/base/dnanvariancewd/manifest.json | 32 +++++++++++++++---- .../stats/base/dnanvariancewd/src/addon.c | 2 +- .../stats/base/dnanvariancewd/src/main.c | 2 ++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json index ba5efb659aa8..86308d31795d 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/manifest.json @@ -57,11 +57,12 @@ "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] }, { "task": "examples", @@ -72,11 +73,28 @@ "include": [ "./include" ], - "libraries": [ - "-lm" + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] } ] } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c index dd0bfbc685a5..4445a16028fd 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c @@ -37,7 +37,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); - STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dnanvariancewd)( N, correction, X, strideX ), v ); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/main.c b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/main.c index 8b31866119c9..26f4b134028d 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/main.c @@ -17,6 +17,8 @@ */ #include "stdlib/stats/base/dnanvariancewd.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" #include /** From 09b3b04aaf475317a8dd4f83fb03c111a50a4d8b Mon Sep 17 00:00:00 2001 From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com> Date: Sat, 22 Feb 2025 14:17:07 +0530 Subject: [PATCH 3/5] chore: update according to code review --- 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: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/stats/base/dnanvariancewd/README.md | 6 +++--- .../stats/base/dnanvariancewd/benchmark/benchmark.js | 2 +- .../stats/base/dnanvariancewd/benchmark/benchmark.native.js | 2 +- .../base/dnanvariancewd/benchmark/benchmark.ndarray.js | 2 +- .../dnanvariancewd/benchmark/benchmark.ndarray.native.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md index e5f9034a04e5..cb695dbd8beb 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md @@ -116,9 +116,9 @@ The function has the following parameters: - **N**: number of indexed elements. - **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). - **x**: input [`Float64Array`][@stdlib/array/float64]. -- **strideX**: index increment for `X`. +- **strideX**: index increment for `x`. -The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `X`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`, @@ -162,7 +162,7 @@ var v = dnanvariancewd.ndarray( x.length, 1, x, 1, 0 ); The function has the following additional parameters: -- **offset**: starting index for `X`. +- **offset**: starting index for `x`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [variance][variance] for every other element in `X` starting from the second element diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js index 749d7ab63f84..d09013b346b6 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.js @@ -33,7 +33,7 @@ var dnanvariancewd = require( './../lib/dnanvariancewd.js' ); // FUNCTIONS // /** -* Returns a random value or `NaN`. +* Returns a random number. * * @private * @returns {number} random number or `NaN` diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js index 1c19905fb51d..cebcebe989a1 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.native.js @@ -42,7 +42,7 @@ var opts = { // FUNCTIONS // /** -* Returns a random value or `NaN`. +* Returns a random number. * * @private * @returns {number} random number or `NaN` diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js index b40d77686013..185e63417f3e 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.js @@ -33,7 +33,7 @@ var dnanvariancewd = require( './../lib/ndarray.js' ); // FUNCTIONS // /** -* Returns a random value or `NaN`. +* Returns a random number. * * @private * @returns {number} random number or `NaN` diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js index 87bb1b607d1a..65cd3bd665a5 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/benchmark/benchmark.ndarray.native.js @@ -42,7 +42,7 @@ var opts = { // FUNCTIONS // /** -* Returns a random value or `NaN`. +* Returns a random number. * * @private * @returns {number} random number or `NaN` From 2e34d3b4c33c7d57c904ee4d5689475bbf9118db Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 22 Feb 2025 03:56:20 -0800 Subject: [PATCH 4/5] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md index cb695dbd8beb..346bd375eb0b 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/README.md @@ -124,7 +124,6 @@ The `N` and stride parameters determine which elements in the strided array are ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ] ); @@ -138,7 +137,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element @@ -170,7 +168,6 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); From e64a66a873b6d58dbe04eb5f930ae01526ccd1e8 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 22 Feb 2025 04:00:54 -0800 Subject: [PATCH 5/5] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c index 4445a16028fd..08f628c0970e 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariancewd/src/addon.c @@ -18,7 +18,6 @@ #include "stdlib/stats/base/dnanvariancewd.h" #include "stdlib/blas/base/shared.h" -#include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_double.h"