From 6f08c56060a3cac54dcb86480985aab402c1bed3 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sun, 8 Jun 2025 08:30:58 +0000 Subject: [PATCH 1/3] feat: add C ndarray interface and refactor implementation for `stats/base/dvarmpn` --- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/base/dvarmpn/README.md | 160 +++++++++++++++--- .../stats/base/dvarmpn/benchmark/benchmark.js | 18 +- .../dvarmpn/benchmark/benchmark.native.js | 14 +- .../dvarmpn/benchmark/benchmark.ndarray.js | 18 +- .../benchmark/benchmark.ndarray.native.js | 14 +- .../@stdlib/stats/base/dvarmpn/docs/repl.txt | 30 ++-- .../stats/base/dvarmpn/docs/types/index.d.ts | 12 +- .../stats/base/dvarmpn/examples/c/example.c | 7 +- .../stats/base/dvarmpn/examples/index.js | 14 +- .../include/stdlib/stats/base/dvarmpn.h | 9 +- .../@stdlib/stats/base/dvarmpn/lib/dvarmpn.js | 39 +---- .../stats/base/dvarmpn/lib/dvarmpn.native.js | 6 +- .../@stdlib/stats/base/dvarmpn/lib/index.js | 4 +- .../@stdlib/stats/base/dvarmpn/lib/ndarray.js | 16 +- .../stats/base/dvarmpn/lib/ndarray.native.js | 20 +-- .../@stdlib/stats/base/dvarmpn/manifest.json | 50 ++++-- .../@stdlib/stats/base/dvarmpn/src/addon.c | 28 ++- .../@stdlib/stats/base/dvarmpn/src/dvarmpn.c | 68 -------- .../@stdlib/stats/base/dvarmpn/src/main.c | 86 ++++++++++ .../stats/base/dvarmpn/test/test.dvarmpn.js | 13 +- .../base/dvarmpn/test/test.dvarmpn.native.js | 13 +- .../stats/base/dvarmpn/test/test.ndarray.js | 13 +- .../base/dvarmpn/test/test.ndarray.native.js | 13 +- 23 files changed, 379 insertions(+), 286 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/dvarmpn/src/dvarmpn.c create mode 100644 lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/README.md b/lib/node_modules/@stdlib/stats/base/dvarmpn/README.md index 0095e5a671d0..0f381084defa 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/README.md +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/README.md @@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var dvarmpn = require( '@stdlib/stats/base/dvarmpn' ); ``` -#### dvarmpn( N, mean, correction, x, stride ) +#### dvarmpn( N, mean, correction, x, strideX ) -Computes the [variance][variance] of a double-precision floating-point strided array `x` provided a known `mean` and using Neely's correction algorithm. +Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean` and using Neely's correction algorithm. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -117,18 +117,16 @@ The function has the following parameters: - **mean**: mean. - **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]. -- **stride**: index increment for `x`. +- **strideX**: stride length 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 ] ); -var N = floor( x.length / 2 ); -var v = dvarmpn( N, 1.25, 1, x, 2 ); +var v = dvarmpn( 4, 1.25, 1, x, 2 ); // returns 6.25 ``` @@ -138,18 +136,15 @@ 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 -var N = floor( x0.length / 2 ); - -var v = dvarmpn( N, 1.25, 1, x1, 2 ); +var v = dvarmpn( 4, 1.25, 1, x1, 2 ); // returns 6.25 ``` -#### dvarmpn.ndarray( N, mean, correction, x, stride, offset ) +#### dvarmpn.ndarray( N, mean, correction, x, strideX, offsetX ) Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean` and using Neely's correction algorithm and alternative indexing semantics. @@ -164,18 +159,16 @@ var v = dvarmpn.ndarray( x.length, 1.0/3.0, 1, x, 1, 0 ); The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: 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 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 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 ```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 v = dvarmpn.ndarray( N, 1.25, 1, x, 2, 1 ); +var v = dvarmpn.ndarray( 4, 1.25, 1, x, 2, 1 ); // returns 6.25 ``` @@ -201,18 +194,12 @@ var v = dvarmpn.ndarray( N, 1.25, 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var dvarmpn = require( '@stdlib/stats/base/dvarmpn' ); -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 ); var v = dvarmpn( x.length, 0.0, 1, x, 1 ); @@ -223,8 +210,127 @@ console.log( v ); + + * * * +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dvarmpn.h" +``` + +#### stdlib_strided_dvarmpn( N, mean, correction, \*X, strideX ) + +Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean` and using Neely's correction algorithm. + +```c +const double x[] = { 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 }; + +double v = stdlib_strided_dvarmpn( 4, 1.25, 1.0, x, 2 ); +// returns 6.25 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **N**: `[in] double` mean. +- **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`. + +```c +double stdlib_strided_dvarmpn( const CBLAS_INT N, const double mean, const double correction, const double *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_dvarmpn_ndarray( N, mean, correction, \*X, strideX, offsetX ) + +Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean` and using Neely's correction algorithm and alternative indexing semantics. + +```c +const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + +double v = stdlib_strided_dvarmpn_ndarray( 4, 1.25, 1.0, x, 2, 0 ); +// returns 6.25 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **mean**: `[in] double` mean. +- **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`. + +```c +double stdlib_strided_dvarmpn_ndarray( const CBLAS_INT N, const double mean, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dvarmpn.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 }; + + // Specify the number of elements: + const int N = 4; + + // Specify the stride length: + const int strideX = 2; + + // Compute the variance: + double v = stdlib_strided_dvarmpn( N, 4.5, 1, x, strideX ); + + // Print the result: + printf( "sample variance: %lf\n", v ); +} +``` + +
+ + + +
+ + +
## References diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.js index 629b3891f9aa..60a0f372e36f 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.js @@ -21,14 +21,20 @@ // 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 dvarmpn = require( './../lib/dvarmpn.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -39,13 +45,7 @@ var dvarmpn = require( './../lib/dvarmpn.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.native.js index cf8da139dace..577d2d13ef1a 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.native.js @@ -22,10 +22,9 @@ 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 +35,9 @@ var dvarmpn = tryRequire( resolve( __dirname, './../lib/dvarmpn.native.js' ) ); var opts = { 'skip': ( dvarmpn instanceof Error ) }; +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -48,13 +50,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++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.js index 8fa3ba35a4ae..b47100dc3839 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.js @@ -21,14 +21,20 @@ // 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 dvarmpn = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -39,13 +45,7 @@ var dvarmpn = 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++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.native.js index 070c702dff6b..406ef510070e 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,9 @@ 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 +35,9 @@ var dvarmpn = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dvarmpn instanceof Error ) }; +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -48,13 +50,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++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt index 051500d27e9f..2b2e73a96b25 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, mean, correction, x, stride ) +{{alias}}( N, mean, correction, x, strideX ) Computes the variance of a double-precision floating-point strided array provided a known mean and using Neely's correction 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,20 +49,19 @@ > {{alias}}( x.length, 1.0/3.0, 1, x, 1 ) ~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 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, 1.0/3.0, 1, x, 2 ) + > {{alias}}( 3, 1.0/3.0, 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 x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, 1.0/3.0, 1, x1, 2 ) + > {{alias}}( 3, 1.0/3.0, 1, x1, 2 ) ~4.3333 -{{alias}}.ndarray( N, mean, correction, x, stride, offset ) + +{{alias}}.ndarray( N, mean, correction, x, strideX, offsetX ) Computes the variance of a double-precision floating-point strided array provided a known mean and using Neely's correction algorithm and alternative indexing semantics. @@ -94,10 +93,10 @@ x: Float64Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -114,8 +113,7 @@ // 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.0/3.0, 1, x, 2, 1 ) + > {{alias}}.ndarray( 3, 1.0/3.0, 1, x, 2, 1 ) ~4.3333 See Also diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/types/index.d.ts index f3bba910cdba..253f5b6b3daa 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/types/index.d.ts @@ -29,7 +29,7 @@ interface Routine { * @param mean - mean * @param correction - degrees of freedom adjustment * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @returns variance * * @example @@ -40,7 +40,7 @@ interface Routine { * var v = dvarmpn( x.length, 1.0/3.0, 1, x, 1 ); * // returns ~4.3333 */ - ( N: number, mean: number, correction: number, x: Float64Array, stride: number ): number; + ( N: number, mean: number, correction: number, x: Float64Array, strideX: number ): number; /** * Computes the variance of a double-precision floating-point strided array provided a known mean and using Neely's correction algorithm and alternative indexing semantics. @@ -49,8 +49,8 @@ interface Routine { * @param mean - mean * @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 @@ -61,7 +61,7 @@ interface Routine { * var v = dvarmpn.ndarray( x.length, 1.0/3.0, 1, x, 1, 0 ); * // returns ~4.3333 */ - ndarray( N: number, mean: number, correction: number, x: Float64Array, stride: number, offset: number ): number; + ndarray( N: number, mean: number, correction: number, x: Float64Array, strideX: number, offsetX: number ): number; } /** @@ -71,7 +71,7 @@ interface Routine { * @param mean - mean * @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/dvarmpn/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dvarmpn/examples/c/example.c index cf953f3bda3b..e94bbd5dbc5d 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/examples/c/example.c @@ -17,7 +17,6 @@ */ #include "stdlib/stats/base/dvarmpn.h" -#include #include int main( void ) { @@ -25,13 +24,13 @@ int main( void ) { const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; // Specify the number of elements: - int64_t N = 4; + const int N = 4; // Specify the stride length: - int64_t stride = 2; + const int strideX = 2; // Compute the variance: - double v = stdlib_strided_dvarmpn( N, 4.5, 1, x, stride ); + double v = stdlib_strided_dvarmpn( N, 4.5, 1, x, strideX ); // Print the result: printf( "sample variance: %lf\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/examples/index.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/examples/index.js index 5cd2c4729b61..d8293294330c 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/examples/index.js @@ -18,18 +18,12 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var dvarmpn = require( './../lib' ); -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 ); var v = dvarmpn( x.length, 0.0, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/include/stdlib/stats/base/dvarmpn.h b/lib/node_modules/@stdlib/stats/base/dvarmpn/include/stdlib/stats/base/dvarmpn.h index faa2f0cf310e..b7b511deea08 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/include/stdlib/stats/base/dvarmpn.h +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/include/stdlib/stats/base/dvarmpn.h @@ -19,7 +19,7 @@ #ifndef STDLIB_STATS_BASE_DVARMPN_H #define STDLIB_STATS_BASE_DVARMPN_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 provided a known mean and using Neely's correction algorithm. */ -double stdlib_strided_dvarmpn( const int64_t N, const double mean, const double correction, const double *X, const int64_t stride ); +double API_SUFFIX(stdlib_strided_dvarmpn)( const CBLAS_INT N, const double mean, const double correction, const double *X, const CBLAS_INT strideX ); + +/** +* Computes the variance of a double-precision floating-point strided array provided a known mean and using Neely's correction algorithm and alternative indexing semantics. +*/ +double API_SUFFIX(stdlib_strided_dvarmpn_ndarray)( const CBLAS_INT N, const double mean, 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/dvarmpn/lib/dvarmpn.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/dvarmpn.js index 06ffd38b877a..f050f972e6f7 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/dvarmpn.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/dvarmpn.js @@ -18,6 +18,12 @@ 'use strict'; +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + // MAIN // /** @@ -32,7 +38,7 @@ * @param {number} mean - mean * @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 @@ -43,35 +49,8 @@ * var v = dvarmpn( x.length, 1.0/3.0, 1, x, 1 ); * // returns ~4.3333 */ -function dvarmpn( N, mean, correction, x, stride ) { - var ix; - var M2; - var M; - var d; - var n; - var i; - - n = N - correction; - if ( N <= 0 || n <= 0.0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - return 0.0; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - M2 = 0.0; - M = 0.0; - for ( i = 0; i < N; i++ ) { - d = x[ ix ] - mean; - M2 += d * d; - M += d; - ix += stride; - } - return (M2/n) - ((M/N)*(M/n)); +function dvarmpn( N, mean, correction, x, strideX ) { + return ndarray( N, mean, correction, x, strideX, stride2offset( N, strideX ) ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/dvarmpn.native.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/dvarmpn.native.js index acadade5dfd6..2fb5cb1d8a34 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/dvarmpn.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/dvarmpn.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * @param {number} mean - mean * @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 @@ -43,8 +43,8 @@ var addon = require( './../src/addon.node' ); * var v = dvarmpn( x.length, 1.0/3.0, 1, x, 1 ); * // returns ~4.3333 */ -function dvarmpn( N, mean, correction, x, stride ) { - return addon( N, mean, correction, x, stride ); +function dvarmpn( N, mean, correction, x, strideX ) { + return addon( N, mean, correction, x, strideX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/index.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/index.js index a067ef4b6b76..c41fca116588 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/index.js @@ -34,13 +34,11 @@ * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dvarmpn = require( '@stdlib/stats/base/dvarmpn' ); * * 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 v = dvarmpn.ndarray( N, 1.25, 1, x, 2, 1 ); +* var v = dvarmpn.ndarray( 4, 1.25, 1, x, 2, 1 ); * // returns 6.25 */ diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.js index 9c90106996c7..b54b219d589e 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.js @@ -32,21 +32,19 @@ * @param {number} mean - mean * @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 ] ); -* var N = floor( x.length / 2 ); * -* var v = dvarmpn( N, 1.25, 1, x, 2, 1 ); +* var v = dvarmpn( 4, 1.25, 1, x, 2, 1 ); * // returns 6.25 */ -function dvarmpn( N, mean, correction, x, stride, offset ) { +function dvarmpn( N, mean, correction, x, strideX, offsetX ) { var ix; var M2; var M; @@ -58,17 +56,17 @@ function dvarmpn( N, mean, correction, x, stride, offset ) { if ( N <= 0 || n <= 0.0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { + if ( N === 1 || strideX === 0 ) { return 0.0; } - ix = offset; + ix = offsetX; M2 = 0.0; M = 0.0; for ( i = 0; i < N; i++ ) { d = x[ ix ] - mean; M2 += d * d; M += d; - ix += stride; + ix += strideX; } return (M2/n) - ((M/N)*(M/n)); } diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.native.js index b6da08fa1994..efede20c7be3 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); -var addon = require( './dvarmpn.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -33,27 +32,20 @@ var addon = require( './dvarmpn.native.js' ); * @param {number} mean - mean * @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 ] ); -* var N = floor( x.length / 2 ); * -* var v = dvarmpn( N, 1.25, 1, x, 2, 1 ); +* var v = dvarmpn( 4, 1.25, 1, x, 2, 1 ); * // returns 6.25 */ -function dvarmpn( N, mean, 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, mean, correction, view, stride ); +function dvarmpn( N, mean, correction, x, strideX, offsetX ) { + return addon.ndarray( N, mean, correction, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/manifest.json b/lib/node_modules/@stdlib/stats/base/dvarmpn/manifest.json index ad4bf3c4d7d3..86308d31795d 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/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/dvarmpn.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,31 +50,51 @@ }, { "task": "benchmark", + "wasm": false, "src": [ - "./src/dvarmpn.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] }, { "task": "examples", + "wasm": false, "src": [ - "./src/dvarmpn.c" + "./src/main.c" ], "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/dvarmpn/src/addon.c b/lib/node_modules/@stdlib/stats/base/dvarmpn/src/addon.c index f2eb4d860dd8..75976351537f 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/src/addon.c @@ -23,6 +23,7 @@ #include "stdlib/napi/argv_double.h" #include "stdlib/napi/argv_strided_float64array.h" #include "stdlib/napi/create_double.h" +#include "stdlib/blas/base/shared.h" #include /** @@ -35,12 +36,31 @@ static napi_value addon( 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_INT64( env, stride, argv, 4 ); STDLIB_NAPI_ARGV_DOUBLE( env, mean, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 2 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 3 ); - STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dvarmpn( N, mean, correction, X, stride ), v ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 3 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dvarmpn)( N, mean, correction, X, strideX ), v ); return v; } -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, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, mean, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 5 ); + STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 3 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dvarmpn_ndarray)( N, mean, correction, X, strideX, offsetX ), v ); + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/src/dvarmpn.c b/lib/node_modules/@stdlib/stats/base/dvarmpn/src/dvarmpn.c deleted file mode 100644 index 47755558d75a..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/src/dvarmpn.c +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/stats/base/dvarmpn.h" -#include - -/** -* Computes the variance of a double-precision floating-point strided array provided a known mean and using Neely's correction algorithm. -* -* ## References -* -* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958). -* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036). -* -* @param N number of indexed elements -* @param mean mean -* @param correction degrees of freedom adjustment -* @param X input array -* @param stride stride length -* @return output value -*/ -double stdlib_strided_dvarmpn( const int64_t N, const double mean, const double correction, const double *X, const int64_t stride ) { - int64_t ix; - int64_t i; - double dN; - double M2; - double M; - double n; - double d; - - dN = (double)N; - n = dN - correction; - if ( N <= 0 || n <= 0.0 ) { - return 0.0 / 0.0; // NaN - } - if ( N == 1 || stride == 0 ) { - return 0.0; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - M2 = 0.0; - M = 0.0; - for ( i = 0; i < N; i++ ) { - d = X[ ix ] - mean; - M2 += d * d; - M += d; - ix += stride; - } - return (M2/n) - ((M/dN)*(M/n)); -} diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c b/lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c new file mode 100644 index 000000000000..e22e05d90b60 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c @@ -0,0 +1,86 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dvarmpn.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/blas/base/shared.h" + +/** +* Computes the variance of a double-precision floating-point strided array provided a known mean and using Neely's correction algorithm. +* +* ## References +* +* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958). +* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036). +* +* @param N number of indexed elements +* @param mean mean +* @param correction degrees of freedom adjustment +* @param X input array +* @param strideX stride length +* @return output value +*/ +double API_SUFFIX(stdlib_strided_dvarmpn)( const CBLAS_INT N, const double mean, const double correction, const double *X, const CBLAS_INT strideX ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(stdlib_strided_dvarmpn_ndarray)( N, mean, correction, X, strideX, ox ); +} + +/** +* Computes the variance of a double-precision floating-point strided array provided a known mean and using Neely's correction algorithm and alternative indexing semantics. +* +* ## References +* +* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958). +* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036). +* +* @param N number of indexed elements +* @param mean mean +* @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_dvarmpn_ndarray)( const CBLAS_INT N, const double mean, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT ix; + CBLAS_INT i; + double dN; + double M2; + double M; + double n; + double d; + + dN = (double)N; + n = dN - correction; + if ( N <= 0 || n <= 0.0 ) { + return 0.0 / 0.0; // NaN + } + if ( N == 1 || strideX == 0 ) { + return 0.0; + } + ix = offsetX; + M2 = 0.0; + M = 0.0; + for ( i = 0; i < N; i++ ) { + d = X[ ix ] - mean; + M2 += d * d; + M += d; + ix += strideX; + } + return (M2/n) - ((M/dN)*(M/n)); +} diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.js index c39ebcc5c373..55f9f58e2b58 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.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 dvarmpn = require( './../lib/dvarmpn.js' ); @@ -121,7 +120,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -136,15 +134,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, 2 ); + v = dvarmpn( 4, 1.25, 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; @@ -159,8 +155,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, -2 ); + v = dvarmpn( 4, 1.25, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -181,7 +176,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -197,9 +191,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 = dvarmpn( N, 1.25, 1, x1, 2 ); + v = dvarmpn( 4, 1.25, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.native.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.native.js index 350ba90aa36a..0459dcc77617 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.dvarmpn.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' ); @@ -130,7 +129,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -145,15 +143,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, 2 ); + v = dvarmpn( 4, 1.25, 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; @@ -168,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, -2 ); + v = dvarmpn( 4, 1.25, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -190,7 +185,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -206,9 +200,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 = dvarmpn( N, 1.25, 1, x1, 2 ); + v = dvarmpn( 4, 1.25, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.ndarray.js index e924282277b3..680b7078df02 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/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 dvarmpn = require( './../lib/ndarray.js' ); @@ -121,7 +120,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -136,15 +134,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, 2, 0 ); + v = dvarmpn( 4, 1.25, 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; @@ -159,8 +155,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, -2, 6 ); + v = dvarmpn( 4, 1.25, 1, x, -2, 6 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -179,7 +174,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -193,9 +187,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, 2, 1 ); + v = dvarmpn( 4, 1.25, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.ndarray.native.js index dcecc2f42cd4..2d9b315be9e2 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/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' ); @@ -130,7 +129,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -145,15 +143,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, 2, 0 ); + v = dvarmpn( 4, 1.25, 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; @@ -168,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, -2, 6 ); + v = dvarmpn( 4, 1.25, 1, x, -2, 6 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -188,7 +183,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -202,9 +196,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dvarmpn( N, 1.25, 1, x, 2, 1 ); + v = dvarmpn( 4, 1.25, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); From e3f2fad54fb2ab807abdc872296b3fe0ee9ac9f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 8 Jun 2025 08:43:43 +0000 Subject: [PATCH 2/3] chore: update copyright years --- lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c b/lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c index e22e05d90b60..a4a83c431fd1 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From a7f09c251c874c1b35a9819b96513fce96fdf2a0 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 13 Jun 2025 01:55:01 -0700 Subject: [PATCH 3/3] docs: avoid duplicate declaration Signed-off-by: Athan --- lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt index 2b2e73a96b25..34b2f05704f8 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dvarmpn/docs/repl.txt @@ -112,7 +112,7 @@ ~4.3333 // Using offset parameter: - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0 ] ); + > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0 ] ); > {{alias}}.ndarray( 3, 1.0/3.0, 1, x, 2, 1 ) ~4.3333