From a3c5511f27af9df3cc191657770b953238451712 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Thu, 19 Jun 2025 10:49:58 +0000 Subject: [PATCH 1/3] feat: add C ndarray interface and refactor implementation for `stats/base/dmeanvar` --- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/dmeanvar/README.md | 168 +++++++++++++++--- .../base/dmeanvar/benchmark/benchmark.js | 15 +- .../dmeanvar/benchmark/benchmark.native.js | 11 +- .../dmeanvar/benchmark/benchmark.ndarray.js | 15 +- .../benchmark/benchmark.ndarray.native.js | 11 +- .../@stdlib/stats/base/dmeanvar/docs/repl.txt | 24 ++- .../stats/base/dmeanvar/examples/c/example.c | 11 +- .../stats/base/dmeanvar/examples/index.js | 16 +- .../include/stdlib/stats/base/dmeanvar.h | 9 +- .../stats/base/dmeanvar/lib/dmeanvar.js | 8 +- .../@stdlib/stats/base/dmeanvar/lib/index.js | 5 +- .../stats/base/dmeanvar/lib/ndarray.js | 5 +- .../stats/base/dmeanvar/lib/ndarray.native.js | 20 +-- .../@stdlib/stats/base/dmeanvar/manifest.json | 44 +++-- .../@stdlib/stats/base/dmeanvar/src/addon.c | 23 ++- .../@stdlib/stats/base/dmeanvar/src/main.c | 27 ++- .../stats/base/dmeanvar/test/test.dmeanvar.js | 13 +- .../dmeanvar/test/test.dmeanvar.native.js | 13 +- .../stats/base/dmeanvar/test/test.ndarray.js | 13 +- .../base/dmeanvar/test/test.ndarray.native.js | 13 +- 20 files changed, 299 insertions(+), 165 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md b/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md index 057f8e88fde0..4852ffa47ed4 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md @@ -102,7 +102,7 @@ var dmeanvar = require( '@stdlib/stats/base/dmeanvar' ); #### dmeanvar( N, correction, x, strideX, out, strideOut ) -Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array `x`. +Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -122,21 +122,19 @@ 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. 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**: stride length for `x`. - **out**: output [`Float64Array`][@stdlib/array/float64] for storing results. -- **strideOut**: index increment for `out`. +- **strideOut**: stride length for `out`. -The `N` and `stride` parameters determine which elements 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 ] ); var out = new Float64Array( 2 ); -var N = floor( x.length / 2 ); -var v = dmeanvar( N, 1, x, 2, out, 1 ); +var v = dmeanvar( 4, 1, x, 2, out, 1 ); // returns [ 1.25, 6.25 ] ``` @@ -146,7 +144,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 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element @@ -154,9 +151,7 @@ var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd var out0 = new Float64Array( 4 ); var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at 3rd element -var N = floor( x0.length / 2 ); - -var v = dmeanvar( N, 1, x1, 2, out1, 1 ); +var v = dmeanvar( 4, 1, x1, 2, out1, 1 ); // returns [ 1.25, 6.25 ] ``` @@ -179,17 +174,15 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetOut**: starting index for `out`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameters support indexing semantics based on a starting index. For example, to calculate the [mean][arithmetic-mean] and [variance][variance] for every other value in `x` starting from the second value +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on a starting index. For example, to calculate the [mean][arithmetic-mean] and [variance][variance] for every other element in `x` starting from the second element ```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 out = new Float64Array( 4 ); -var N = floor( x.length / 2 ); -var v = dmeanvar.ndarray( N, 1, x, 2, 1, out, 2, 1 ); +var v = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 2, 1 ); // returns [ 0.0, 1.25, 0.0, 6.25 ] ``` @@ -215,22 +208,16 @@ var v = dmeanvar.ndarray( N, 1, x, 2, 1, out, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var dmeanvar = require( '@stdlib/stats/base/dmeanvar' ); -var out; -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); -out = new Float64Array( 2 ); +var out = new Float64Array( 2 ); dmeanvar( x.length, 1, x, 1, out, 1 ); console.log( out ); ``` @@ -239,6 +226,135 @@ console.log( out ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dmeanvar.h" +``` + +#### stdlib_strided_dmeanvar( N, correction, \*X, strideX, \*Out, strideOut ) + +Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array. + +```c +const double x[] = { 1.0, -2.0, 2.0 }; +double out[] = { 0.0, 0.0 }; + +stdlib_strided_dmeanvar( 3, 1.0, x, 1, out, 1 ); +``` + +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. 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`. +- **Out**: `[in] double*` output array. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. + +```c +void stdlib_strided_dmeanvar( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT strideOut ); +``` + +#### stdlib_strided_dmeanvar_ndarray( N, correction, \*X, strideX, offsetX, \*Out, strideOut, offsetOut ) + +Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using alternative indexing semantics. + +```c +const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; +double out[] = { 0.0, 0.0 }; + +stdlib_strided_dmeanvar_ndarray( 4, 1.0, x, 2, 0, x, 1, 0 ); +``` + +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. 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`. +- **Out**: `[in] double*` output array. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. + +```c +void stdlib_strided_dmeanvar_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dmeanvar.h" +#include + +int main( void ) { + // Create a strided array: + const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Create an output array: + double out[] = { 0.0, 0.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify the stride lengths: + const int strideX = 2; + const int strideOut = 1; + + // Compute the mean and variance: + stdlib_strided_dmeanvar( N, 1.0, x, strideX, out, strideOut ); + + // Print the result: + printf( "sample mean: %lf\n", out[ 0 ] ); + printf( "sample variance: %lf\n", out[ 1 ] ); +} +``` + +
+ + + +
+ + +
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.js index 122cfc83c13e..4cbce6bfbee5 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.js @@ -21,14 +21,21 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/array/uniform' ); var pkg = require( './../package.json' ).name; var dmeanvar = require( './../lib/dmeanvar.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -41,12 +48,8 @@ var dmeanvar = require( './../lib/dmeanvar.js' ); function createBenchmark( len ) { var out; var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10.0, 10.0, options ); out = new Float64Array( 2 ); return benchmark; diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.native.js index 530caeea14d5..ee991d5f0b0a 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/array/uniform' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,9 @@ var dmeanvar = tryRequire( resolve( __dirname, './../lib/dmeanvar.native.js' ) ) var opts = { 'skip': ( dmeanvar instanceof Error ) }; +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -50,12 +53,8 @@ var opts = { function createBenchmark( len ) { var out; var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10.0, 10.0, options ); out = new Float64Array( 2 ); return benchmark; diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.js index f207d8af00ba..2b803d805a2d 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.js @@ -21,14 +21,21 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/array/uniform' ); var pkg = require( './../package.json' ).name; var dmeanvar = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -41,12 +48,8 @@ var dmeanvar = require( './../lib/ndarray.js' ); function createBenchmark( len ) { var out; var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10.0, 10.0, options ); out = new Float64Array( 2 ); return benchmark; diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.native.js index d05a19372cf8..397fe31cc5e8 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/array/uniform' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,9 @@ var dmeanvar = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dmeanvar instanceof Error ) }; +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -50,12 +53,8 @@ var opts = { function createBenchmark( len ) { var out; var x; - var i; - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + x = uniform( len, -10.0, 10.0, options ); out = new Float64Array( 2 ); return benchmark; diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dmeanvar/docs/repl.txt index 6021ade0bc3a..feba53a8a683 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/docs/repl.txt @@ -3,8 +3,8 @@ Computes the mean and variance of a double-precision floating-point strided array. - The `N` and `stride` parameters determine which elements 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. @@ -32,13 +32,13 @@ Input array. strideX: integer - Index increment for `x`. + Stride length for `x`. out: Float64Array Output array. strideOut: integer - Index increment for `out`. + Stride length for `out`. Returns ------- @@ -53,21 +53,20 @@ > {{alias}}( x.length, 1, x, 1, out, 1 ) [ ~0.3333, ~4.3333 ] - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > out = new {{alias:@stdlib/array/float64}}( 2 ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, 1, x, 2, out, 1 ) + > {{alias}}( 3, 1, x, 2, out, 1 ) [ ~0.3333, ~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 x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); > out = new {{alias:@stdlib/array/float64}}( 2 ); - > {{alias}}( N, 1, x1, 2, out, 1 ) + > {{alias}}( 3, 1, x1, 2, out, 1 ) [ ~0.3333, ~4.3333 ] + {{alias}}.ndarray( N, c, x, strideX, offsetX, out, strideOut, offsetOut ) Computes the mean and variance of a double-precision floating-point strided array using alternative indexing semantics. @@ -97,7 +96,7 @@ Input array. strideX: integer - Index increment for `x`. + Stride length for `x`. offsetX: integer Starting index for `x`. @@ -106,7 +105,7 @@ Output array. strideOut: integer - Index increment for `out`. + Stride length for `out`. offsetOut: integer Starting index for `out`. @@ -126,9 +125,8 @@ // 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 ); > out = new {{alias:@stdlib/array/float64}}( 2 ); - > {{alias}}.ndarray( N, 1, x, 2, 1, out, 1, 0 ) + > {{alias}}.ndarray( 3, 1, x, 2, 1, out, 1, 0 ) [ ~0.3333, ~4.3333 ] See Also diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/c/example.c index 0f50ca631ec2..d000a57c3516 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/c/example.c @@ -17,25 +17,24 @@ */ #include "stdlib/stats/base/dmeanvar.h" -#include #include int main( void ) { // Create a strided array: - double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; // Create an output array: double out[] = { 0.0, 0.0 }; // Specify the number of elements: - int64_t N = 4; + const int N = 4; // Specify the stride lengths: - int64_t strideX = 2; - int64_t strideOut = 1; + const int strideX = 2; + const int strideOut = 1; // Compute the mean and variance: - stdlib_strided_dmeanvar( N, 1, x, strideX, out, strideOut ); + stdlib_strided_dmeanvar( N, 1.0, x, strideX, out, strideOut ); // Print the result: printf( "sample mean: %lf\n", out[ 0 ] ); diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/index.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/index.js index 390a3ca3f76f..964785eb4239 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/examples/index.js @@ -18,21 +18,15 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var dmeanvar = require( './../lib' ); -var out; -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); -out = new Float64Array( 2 ); +var out = new Float64Array( 2 ); dmeanvar( x.length, 1, x, 1, out, 1 ); console.log( out ); diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/include/stdlib/stats/base/dmeanvar.h b/lib/node_modules/@stdlib/stats/base/dmeanvar/include/stdlib/stats/base/dmeanvar.h index fab2564e0bab..7df7340b231c 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/include/stdlib/stats/base/dmeanvar.h +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/include/stdlib/stats/base/dmeanvar.h @@ -19,7 +19,7 @@ #ifndef STDLIB_STATS_BASE_DMEANVAR_H #define STDLIB_STATS_BASE_DMEANVAR_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 mean and variance of a double-precision floating-point strided array. */ -void stdlib_strided_dmeanvar( const int64_t N, const double correction, const double *X, const int64_t strideX, double *Out, const int64_t strideOut ); +void API_SUFFIX(stdlib_strided_dmeanvar)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT strideOut ); + +/** +* Computes the mean and variance of a double-precision floating-point strided array using alternative indexing semantics. +*/ +void API_SUFFIX(stdlib_strided_dmeanvar_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/dmeanvar.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/dmeanvar.js index c08e217804bc..4b9f28150e6d 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/dmeanvar.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/dmeanvar.js @@ -20,7 +20,8 @@ // MODULES // -var dmeanvarpn = require( '@stdlib/stats/base/dmeanvarpn' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -46,7 +47,10 @@ var dmeanvarpn = require( '@stdlib/stats/base/dmeanvarpn' ); * // returns [ ~0.3333, ~4.3333 ] */ function dmeanvar( N, correction, x, strideX, out, strideOut ) { - return dmeanvarpn( N, correction, x, strideX, out, strideOut ); + var ox = stride2offset( N, strideX ); + var oo = ( strideOut >= 0 ) ? 0 : -strideOut; + ndarray( N, correction, x, strideX, ox, out, strideOut, oo ); + return out; } diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/index.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/index.js index 5706cbec8c59..606e4b52fcb7 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/index.js @@ -35,15 +35,12 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dmeanvar = require( '@stdlib/stats/base/dmeanvar' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var out = new Float64Array( 2 ); * -* var N = floor( x.length / 2 ); -* -* var v = dmeanvar.ndarray( N, 1, x, 2, 1, out, 1, 0 ); +* var v = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 1, 0 ); * // returns [ 1.25, 6.25 ] */ diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.js index 3060fe30177e..6280dead6a6c 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.js @@ -40,14 +40,11 @@ var dmeanvarpn = require( '@stdlib/stats/base/dmeanvarpn' ).ndarray; * * @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 ] ); * var out = new Float64Array( 2 ); * -* var N = floor( x.length / 2 ); -* -* var v = dmeanvar( N, 1, x, 2, 1, out, 1, 0 ); +* var v = dmeanvar( 4, 1, x, 2, 1, out, 1, 0 ); * // returns [ 1.25, 6.25 ] */ function dmeanvar( N, correction, x, strideX, offsetX, out, strideOut, offsetOut ) { // eslint-disable-line max-len diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.native.js index 3e96555fce7d..22eede8ecf7e 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); -var addon = require( './dmeanvar.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -41,28 +40,15 @@ var addon = require( './dmeanvar.native.js' ); * * @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 ] ); * var out = new Float64Array( 2 ); * -* var N = floor( x.length / 2 ); -* -* var v = dmeanvar( N, 1, x, 2, 1, out, 1, 0 ); +* var v = dmeanvar( 4, 1, x, 2, 1, out, 1, 0 ); * // returns [ 1.25, 6.25 ] */ function dmeanvar( N, correction, x, strideX, offsetX, out, strideOut, offsetOut ) { // eslint-disable-line max-len - var viewOut; - var viewX; - if ( strideX < 0 ) { - offsetX += (N-1) * strideX; - } - if ( strideOut < 0 ) { - offsetOut += strideOut; - } - viewX = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len - viewOut = new Float64Array( out.buffer, out.byteOffset+(out.BYTES_PER_ELEMENT*offsetOut), out.length-offsetOut ); // eslint-disable-line max-len - addon( N, correction, viewX, strideX, viewOut, strideOut ); + addon.ndarray( N, correction, x, strideX, offsetX, out, strideOut, offsetOut ); // eslint-disable-line max-len return out; } diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/manifest.json b/lib/node_modules/@stdlib/stats/base/dmeanvar/manifest.json index 5126f265eed3..2f85e24f01b0 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,55 +28,74 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/stats/base/dmeanvarpn", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-double", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/blas/base/shared", - "@stdlib/stats/base/dmeanvarpn" + "@stdlib/napi/argv-strided-float64array" ] }, { "task": "benchmark", + "wasm": false, "src": [ "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/stats/base/dmeanvarpn" ] }, { "task": "examples", + "wasm": false, "src": [ "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/stats/base/dmeanvarpn" + ] + }, + { + "task": "", + "wasm": true, + "src": [ + "./src/main.c" ], + "include": [ + "./include" + ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/stats/base/dmeanvarpn" ] } diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/src/addon.c b/lib/node_modules/@stdlib/stats/base/dmeanvar/src/addon.c index 2c2a876e35da..f218f8039f22 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/src/addon.c @@ -44,4 +44,25 @@ static napi_value addon( napi_env env, napi_callback_info info ) { return NULL; } -STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) +/** +* 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, 8 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 7 ); + STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 5 ); + API_SUFFIX(stdlib_strided_dmeanvar_ndarray)( N, correction, X, strideX, offsetX, Out, strideOut, offsetOut ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/src/main.c b/lib/node_modules/@stdlib/stats/base/dmeanvar/src/main.c index 1fef2a93fa31..bb54a008d9ce 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/src/main.c @@ -18,7 +18,8 @@ #include "stdlib/stats/base/dmeanvar.h" #include "stdlib/stats/base/dmeanvarpn.h" -#include +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/blas/base/shared.h" /** * Computes the mean and variance of a double-precision floating-point strided array. @@ -30,6 +31,26 @@ * @param Out output array * @param strideOut Out stride length */ -void stdlib_strided_dmeanvar( const int64_t N, const double correction, const double *X, const int64_t strideX, double *Out, const int64_t strideOut ) { - stdlib_strided_dmeanvarpn( N, correction, X, strideX, Out, strideOut ); +void API_SUFFIX(stdlib_strided_dmeanvar)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT strideOut ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + const CBLAS_INT oo = ( strideOut >= 0 ) ? 0 : -strideOut; + API_SUFFIX(stdlib_strided_dmeanvar_ndarray)( N, correction, X, strideX, ox, Out, strideOut, oo ); + return; +} + +/** +* Computes the mean and variance of a double-precision floating-point strided array using alternative indexing semantics. +* +* @param N number of indexed elements +* @param correction degrees of freedom adjustment +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Out output array +* @param strideOut Out stride length +* @param offsetOut starting index for Out +*/ +void API_SUFFIX(stdlib_strided_dmeanvar_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { + API_SUFFIX(stdlib_strided_dmeanvarpn_ndarray)( N, correction, X, strideX, offsetX, Out, strideOut, offsetOut ); + return; } diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.js index fb2a7b486a29..ff42b06a84a1 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.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 dmeanvar = require( './../lib/dmeanvar.js' ); @@ -188,7 +187,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or tape( 'the function supports `stride` parameters', function test( t ) { var expected; var out; - var N; var x; var v; @@ -204,8 +202,7 @@ tape( 'the function supports `stride` parameters', function test( t ) { ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, 2, out, 2 ); + v = dmeanvar( 4, 1, x, 2, out, 2 ); expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -216,7 +213,6 @@ tape( 'the function supports `stride` parameters', function test( t ) { tape( 'the function supports negative `stride` parameters', function test( t ) { var expected; var out; - var N; var x; var v; @@ -232,8 +228,7 @@ tape( 'the function supports negative `stride` parameters', function test( t ) { ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, -2, out, -2 ); + v = dmeanvar( 4, 1, x, -2, out, -2 ); expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -265,7 +260,6 @@ tape( 'the function supports view offsets', function test( t ) { var out1; var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -283,9 +277,8 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at the 3rd element - N = floor(x1.length / 2); - v = dmeanvar( N, 1, x1, 2, out1, 1 ); + v = dmeanvar( 4, 1, x1, 2, out1, 1 ); expected0 = new Float64Array( [ 0.0, 0.0, 1.25, 6.25 ] ); expected1 = new Float64Array( [ 1.25, 6.25 ] ); diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.native.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.native.js index 71f6750488ce..ca6edc0911e6 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.native.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.dmeanvar.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' ); @@ -197,7 +196,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or tape( 'the function supports `stride` parameters', opts, function test( t ) { var expected; var out; - var N; var x; var v; @@ -213,8 +211,7 @@ tape( 'the function supports `stride` parameters', opts, function test( t ) { ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, 2, out, 2 ); + v = dmeanvar( 4, 1, x, 2, out, 2 ); expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -225,7 +222,6 @@ tape( 'the function supports `stride` parameters', opts, function test( t ) { tape( 'the function supports negative `stride` parameters', opts, function test( t ) { var expected; var out; - var N; var x; var v; @@ -241,8 +237,7 @@ tape( 'the function supports negative `stride` parameters', opts, function test( ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, -2, out, -2 ); + v = dmeanvar( 4, 1, x, -2, out, -2 ); expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -274,7 +269,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { var out1; var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -292,9 +286,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 out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at the 3rd element - N = floor(x1.length / 2); - v = dmeanvar( N, 1, x1, 2, out1, 1 ); + v = dmeanvar( 4, 1, x1, 2, out1, 1 ); expected0 = new Float64Array( [ 0.0, 0.0, 1.25, 6.25 ] ); expected1 = new Float64Array( [ 1.25, 6.25 ] ); diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.ndarray.js index 3da1cb4a6531..fa73c580bcad 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/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 dmeanvar = require( './../lib/ndarray.js' ); @@ -188,7 +187,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or tape( 'the function supports `stride` parameters', function test( t ) { var expected; var out; - var N; var x; var v; @@ -204,8 +202,7 @@ tape( 'the function supports `stride` parameters', function test( t ) { ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, 2, 0, out, 2, 0 ); + v = dmeanvar( 4, 1, x, 2, 0, out, 2, 0 ); expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -216,7 +213,6 @@ tape( 'the function supports `stride` parameters', function test( t ) { tape( 'the function supports negative `stride` parameters', function test( t ) { var expected; var out; - var N; var x; var v; @@ -232,8 +228,7 @@ tape( 'the function supports negative `stride` parameters', function test( t ) { ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, -2, 6, out, -2, 2 ); + v = dmeanvar( 4, 1, x, -2, 6, out, -2, 2 ); expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -261,7 +256,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns an ar tape( 'the function supports `offset` parameters', function test( t ) { var expected; var out; - var N; var x; var v; @@ -276,9 +270,8 @@ tape( 'the function supports `offset` parameters', function test( t ) { 4.0 // 3 ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, 2, 1, out, 2, 1 ); + v = dmeanvar( 4, 1, x, 2, 1, out, 2, 1 ); expected = new Float64Array( [ 0.0, 1.25, 0.0, 6.25 ] ); t.deepEqual( v, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.ndarray.native.js index c96aef7dfb0f..3bf7bf990b24 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/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' ); @@ -197,7 +196,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or tape( 'the function supports `stride` parameters', opts, function test( t ) { var expected; var out; - var N; var x; var v; @@ -213,8 +211,7 @@ tape( 'the function supports `stride` parameters', opts, function test( t ) { ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, 2, 0, out, 2, 0 ); + v = dmeanvar( 4, 1, x, 2, 0, out, 2, 0 ); expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -225,7 +222,6 @@ tape( 'the function supports `stride` parameters', opts, function test( t ) { tape( 'the function supports negative `stride` parameters', opts, function test( t ) { var expected; var out; - var N; var x; var v; @@ -241,8 +237,7 @@ tape( 'the function supports negative `stride` parameters', opts, function test( ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, -2, 6, out, -2, 2 ); + v = dmeanvar( 4, 1, x, -2, 6, out, -2, 2 ); expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); t.deepEqual( v, expected, 'returns expected value' ); @@ -270,7 +265,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns an ar tape( 'the function supports `offset` parameters', opts, function test( t ) { var expected; var out; - var N; var x; var v; @@ -285,9 +279,8 @@ tape( 'the function supports `offset` parameters', opts, function test( t ) { 4.0 // 3 ]); out = new Float64Array( 4 ); - N = floor( x.length / 2 ); - v = dmeanvar( N, 1, x, 2, 1, out, 2, 1 ); + v = dmeanvar( 4, 1, x, 2, 1, out, 2, 1 ); expected = new Float64Array( [ 0.0, 1.25, 0.0, 6.25 ] ); t.deepEqual( v, expected, 'returns expected value' ); From 7c20b968f490b1524e725a55475d9a7c474cdce3 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 20 Jun 2025 18:05:40 -0700 Subject: [PATCH 2/3] docs: update copy Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/dmeanvar/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md b/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md index 4852ffa47ed4..967aef0cf61e 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md @@ -174,7 +174,7 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetOut**: starting index for `out`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on a starting index. For example, to calculate the [mean][arithmetic-mean] and [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 parameters support indexing semantics based on starting indices. For example, to calculate the [mean][arithmetic-mean] and [variance][variance] for every other element in `x` starting from the second element ```javascript var Float64Array = require( '@stdlib/array/float64' ); From ad87e65f0a9237adb0f1f57e8ea76fd4a96addf7 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 20 Jun 2025 18:15:54 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/dmeanvar/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md b/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md index 967aef0cf61e..dc0854ae5f98 100644 --- a/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md +++ b/lib/node_modules/@stdlib/stats/base/dmeanvar/README.md @@ -269,7 +269,7 @@ The function accepts the following arguments: - **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. 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`. -- **Out**: `[in] double*` output array. +- **Out**: `[out] double*` output array. - **strideOut**: `[in] CBLAS_INT` stride length for `Out`. ```c @@ -294,7 +294,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`. -- **Out**: `[in] double*` output array. +- **Out**: `[out] double*` output array. - **strideOut**: `[in] CBLAS_INT` stride length for `Out`. - **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.