diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/README.md b/lib/node_modules/@stdlib/stats/base/dmeanpn/README.md
index e79e27a38f12..bb75b28efe52 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/README.md
@@ -51,7 +51,7 @@ The [arithmetic mean][arithmetic-mean] is defined as
var dmeanpn = require( '@stdlib/stats/base/dmeanpn' );
```
-#### dmeanpn( N, x, stride )
+#### dmeanpn( N, x, strideX )
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array `x` using a two-pass error correction algorithm.
@@ -59,9 +59,8 @@ Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-p
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-var N = x.length;
-var v = dmeanpn( N, x, 1 );
+var v = dmeanpn( x.length, x, 1 );
// returns ~0.3333
```
@@ -69,18 +68,16 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **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 [arithmetic mean][arithmetic-mean] 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 [arithmetic mean][arithmetic-mean] 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 = dmeanpn( N, x, 2 );
+var v = dmeanpn( 4, x, 2 );
// returns 1.25
```
@@ -90,18 +87,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 = dmeanpn( N, x1, 2 );
+var v = dmeanpn( 4, x1, 2 );
// returns 1.25
```
-#### dmeanpn.ndarray( N, x, stride, offset )
+#### dmeanpn.ndarray( N, x, strideX, offsetX )
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using a two-pass error correction algorithm and alternative indexing semantics.
@@ -109,26 +103,23 @@ Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-p
var Float64Array = require( '@stdlib/array/float64' );
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-var N = x.length;
-var v = dmeanpn.ndarray( N, x, 1, 0 );
+var v = dmeanpn.ndarray( x.length, x, 1, 0 );
// returns ~0.33333
```
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 [arithmetic mean][arithmetic-mean] 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 [arithmetic mean][arithmetic-mean] 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 = dmeanpn.ndarray( N, x, 2, 1 );
+var v = dmeanpn.ndarray( 4, x, 2, 1 );
// returns 1.25
```
@@ -175,6 +166,108 @@ console.log( v );
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/stats/base/dmeanpn.h"
+```
+
+#### stdlib_strided_dmeanpn( N, \*X, strideX )
+
+Calculate the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using a two-pass error correction algorithm.
+
+```c
+const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+
+double v = stdlib_strided_dmeanpn( 4, x, 2 );
+// returns 4.0
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **X**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+
+```c
+double stdlib_strided_dmeanpn( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dmeanpn_ndarray( N, \*X, strideX, offsetX )
+
+Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using a two-pass error 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_dmeanpn_ndarray( 4, x, 2, 0 );
+// returns 4.0
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **X**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+
+```c
+double stdlib_strided_dmeanpn_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/stats/base/dmeanpn.h"
+#include
+#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 arithmetic mean:
+ double v = stdlib_strided_dmeanpn( N, x, strideX );
+
+ // Print the result:
+ printf( "mean: %lf\n", v );
+}
+```
+
+
+
+
+
+
+
+
+
* * *
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.js
index bca6bea15225..e0d438abbdda 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.js
@@ -21,16 +21,25 @@
// 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/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var pkg = require( './../package.json' ).name;
var dmeanpn = require( './../lib/dmeanpn.js' );
// FUNCTIONS //
+/**
+* Returns a random value.
+*
+* @returns {number} Random number
+*/
+function rand() {
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -39,13 +48,7 @@ var dmeanpn = require( './../lib/dmeanpn.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 = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.native.js
index 113013de3f6d..dcc9fa4f5516 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/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/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
@@ -40,6 +40,15 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random value.
+*
+* @returns {number} Random number
+*/
+function rand() {
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -48,13 +57,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 = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.ndarray.js
index 4185a7e635b5..48b948b56e56 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.ndarray.js
@@ -21,16 +21,25 @@
// 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/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var pkg = require( './../package.json' ).name;
var dmeanpn = require( './../lib/ndarray.js' );
// FUNCTIONS //
+/**
+* Returns a random value.
+*
+* @returns {number} Random number
+*/
+function rand() {
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -39,13 +48,7 @@ var dmeanpn = 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 = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.ndarray.native.js
index 07b60e5fdd1e..bbda3dd11671 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/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/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
@@ -40,6 +40,15 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random value.
+*
+* @returns {number} Random number
+*/
+function rand() {
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -48,13 +57,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 = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/repl.txt
index 7eb8294fbb51..6d6d38073e2b 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/repl.txt
@@ -1,10 +1,10 @@
-{{alias}}( N, x, stride )
+{{alias}}( N, x, strideX )
Computes the arithmetic mean of a double-precision floating-point strided
array using a two-pass error 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.
@@ -19,8 +19,8 @@
x: Float64Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride Length.
Returns
-------
@@ -34,22 +34,19 @@
> {{alias}}( x.length, x, 1 )
~0.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 );
- > var stride = 2;
- > {{alias}}( N, x, stride )
+ > {{alias}}( 3, x, 2 )
~0.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 );
- > stride = 2;
- > {{alias}}( N, x1, stride )
+ > {{alias}}( 3, x1, 2 )
~-0.3333
-{{alias}}.ndarray( N, x, stride, offset )
+
+{{alias}}.ndarray( N, x, strideX, offsetX )
Computes the arithmetic mean of a double-precision floating-point strided
array using a two-pass error correction algorithm and alternative indexing
semantics.
@@ -66,10 +63,10 @@
x: Float64Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride Length.
- offset: integer
+ offsetX: integer
Starting index.
Returns
@@ -86,8 +83,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, x, 2, 1 )
+ > {{alias}}.ndarray( 3, x, 2, 1 )
~-0.3333
See Also
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/types/index.d.ts
index ebfb2cf51cb3..6522de85b0c4 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/docs/types/index.d.ts
@@ -27,7 +27,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
- * @param stride - stride length
+ * @param strideX - stride length
* @returns arithmetic mean
*
* @example
@@ -38,15 +38,15 @@ interface Routine {
* var v = dmeanpn( x.length, x, 1 );
* // returns ~0.3333
*/
- ( N: number, x: Float64Array, stride: number ): number;
+ ( N: number, x: Float64Array, strideX: number ): number;
/**
* Computes the arithmetic mean of a double-precision floating-point strided array using a two-pass error correction algorithm and alternative indexing semantics.
*
* @param N - number of indexed elements
* @param x - input array
- * @param stride - stride length
- * @param offset - starting index
+ * @param strideX - stride length
+ * @param offsetX - starting index
* @returns arithmetic mean
*
* @example
@@ -57,7 +57,7 @@ interface Routine {
* var v = dmeanpn.ndarray( x.length, x, 1, 0 );
* // returns ~0.3333
*/
- ndarray( N: number, x: Float64Array, stride: number, offset: number ): number;
+ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number ): number;
}
/**
@@ -65,7 +65,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
-* @param stride - stride length
+* @param strideX - stride length
* @returns arithmetic mean
*
* @example
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dmeanpn/examples/c/example.c
index 2719968f6ef2..17245d269d60 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/examples/c/example.c
@@ -22,16 +22,16 @@
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 };
// 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 arithmetic mean:
- double v = stdlib_strided_dmeanpn( N, x, stride );
+ double v = stdlib_strided_dmeanpn( N, x, strideX );
// Print the result:
printf( "mean: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/include/stdlib/stats/base/dmeanpn.h b/lib/node_modules/@stdlib/stats/base/dmeanpn/include/stdlib/stats/base/dmeanpn.h
index e862ff0223fc..eac55ebe6507 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/include/stdlib/stats/base/dmeanpn.h
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/include/stdlib/stats/base/dmeanpn.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_STATS_BASE_DMEANPN_H
#define STDLIB_STATS_BASE_DMEANPN_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 arithmetic mean of a double-precision floating-point strided array using a two-pass error correction algorithm.
*/
-double stdlib_strided_dmeanpn( const int64_t N, const double *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dmeanpn)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
+
+/**
+* Computes the arithmetic mean of a double-precision floating-point strided array using a two-pass error correction algorithm and alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dmeanpn_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.js
index 8e16ab5c841c..c60fc5474046 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.js
@@ -20,8 +20,8 @@
// MODULES //
-var dsumpw = require( '@stdlib/blas/ext/base/dsumpw' );
-var dapxsumpw = require( '@stdlib/blas/ext/base/dapxsumpw' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -40,35 +40,20 @@ var dapxsumpw = require( '@stdlib/blas/ext/base/dapxsumpw' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} arithmetic mean
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dmeanpn( N, x, 1 );
+* var v = dmeanpn( x.length, x, 1 );
* // returns ~0.3333
*/
-function dmeanpn( N, x, stride ) {
- var mu;
- var c;
-
- if ( N <= 0 ) {
- return NaN;
- }
- if ( N === 1 || stride === 0 ) {
- return x[ 0 ];
- }
- // Compute an estimate for the mean:
- mu = dsumpw( N, x, stride ) / N;
-
- // Compute an error term:
- c = dapxsumpw( N, -mu, x, stride ) / N;
-
- return mu + c;
+function dmeanpn( N, x, strideX ) {
+ var ox = stride2offset( N, strideX );
+ return ndarray( N, x, strideX, ox );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.native.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.native.js
index e5ab4e869d67..85d66f1597d1 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/dmeanpn.native.js
@@ -30,20 +30,19 @@ var addon = require( './../src/addon.node' );
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} arithmetic mean
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dmeanpn( N, x, 1 );
+* var v = dmeanpn( x.length, x, 1 );
* // returns ~0.3333
*/
-function dmeanpn( N, x, stride ) {
- return addon( N, x, stride );
+function dmeanpn( N, x, strideX ) {
+ return addon( N, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/index.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/index.js
index c67e359a4b48..269d0445e108 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/index.js
@@ -28,20 +28,17 @@
* var dmeanpn = require( '@stdlib/stats/base/dmeanpn' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dmeanpn( N, x, 1 );
+* var v = dmeanpn( x.length, x, 1 );
* // returns ~0.3333
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
* var dmeanpn = require( '@stdlib/stats/base/dmeanpn' );
*
* 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 = dmeanpn.ndarray( N, x, 2, 1 );
+* var v = dmeanpn.ndarray( 4, x, 2, 1 );
* // returns 1.25
*/
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.js
index e7e4450fc3bd..aa66259a0eb7 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.js
@@ -40,35 +40,33 @@ var dapxsumpw = require( '@stdlib/blas/ext/base/dapxsumpw' ).ndarray;
*
* @param {PositiveInteger} N - number of indexed elements
* @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} arithmetic mean
*
* @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 = dmeanpn( N, x, 2, 1 );
+* var v = dmeanpn( 4, x, 2, 1 );
* // returns 1.25
*/
-function dmeanpn( N, x, stride, offset ) {
+function dmeanpn( N, x, strideX, offsetX ) {
var mu;
var c;
if ( N <= 0 ) {
return NaN;
}
- if ( N === 1 || stride === 0 ) {
- return x[ offset ];
+ if ( N === 1 || strideX === 0 ) {
+ return x[ offsetX ];
}
// Compute an estimate for the mean:
- mu = dsumpw( N, x, stride, offset ) / N;
+ mu = dsumpw( N, x, strideX, offsetX ) / N;
// Compute an error term:
- c = dapxsumpw( N, -mu, x, stride, offset ) / N;
+ c = dapxsumpw( N, -mu, x, strideX, offsetX ) / N;
return mu + c;
}
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.native.js
index d3cd5fa2a869..278530017c78 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/lib/ndarray.native.js
@@ -20,8 +20,7 @@
// MODULES //
-var Float64Array = require( '@stdlib/array/float64' );
-var addon = require( './dmeanpn.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -31,27 +30,20 @@ var addon = require( './dmeanpn.native.js' );
*
* @param {PositiveInteger} N - number of indexed elements
* @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} arithmetic mean
*
* @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 = dmeanpn( N, x, 2, 1 );
+* var v = dmeanpn( 4, x, 2, 1 );
* // returns 1.25
*/
-function dmeanpn( N, 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, view, stride );
+function dmeanpn( N, x, strideX, offsetX ) {
+ return addon.ndarray( N, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/manifest.json b/lib/node_modules/@stdlib/stats/base/dmeanpn/manifest.json
index 5be1f195a914..a15915b9dc28 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/manifest.json
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/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/dmeanpn.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
"@stdlib/blas/ext/base/dsumpw",
"@stdlib/blas/ext/base/dapxsumpw",
"@stdlib/napi/export",
@@ -49,34 +51,54 @@
},
{
"task": "benchmark",
+ "wasm": false,
"src": [
- "./src/dmeanpn.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
"@stdlib/blas/ext/base/dsumpw",
"@stdlib/blas/ext/base/dapxsumpw"
]
},
{
"task": "examples",
+ "wasm": false,
"src": [
- "./src/dmeanpn.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
+ "libraries": [],
+ "libpath": [],
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/ext/base/dsumpw",
+ "@stdlib/blas/ext/base/dapxsumpw"
+ ]
+ },
+ {
+ "task": "",
+ "wasm": true,
+ "src": [
+ "./src/main.c"
+ ],
+ "include": [
+ "./include"
],
+ "libraries": [],
"libpath": [],
"dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
"@stdlib/blas/ext/base/dsumpw",
"@stdlib/blas/ext/base/dapxsumpw"
]
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/src/addon.c b/lib/node_modules/@stdlib/stats/base/dmeanpn/src/addon.c
index 3b7f19756a51..e80c639c5b55 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/src/addon.c
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/src/addon.c
@@ -40,4 +40,21 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
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, 4 );
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dmeanpn_ndarray( N, 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/dmeanpn/src/dmeanpn.c b/lib/node_modules/@stdlib/stats/base/dmeanpn/src/main.c
similarity index 61%
rename from lib/node_modules/@stdlib/stats/base/dmeanpn/src/dmeanpn.c
rename to lib/node_modules/@stdlib/stats/base/dmeanpn/src/main.c
index 5a462a86581d..815cf2ab3096 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/src/dmeanpn.c
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/src/main.c
@@ -19,7 +19,8 @@
#include "stdlib/stats/base/dmeanpn.h"
#include "stdlib/blas/ext/base/dsumpw.h"
#include "stdlib/blas/ext/base/dapxsumpw.h"
-#include
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
/**
* Computes the arithmetic mean of a double-precision floating-point strided array using a two-pass error correction algorithm.
@@ -33,12 +34,26 @@
* - 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 X input array
-* @param stride stride length
-* @return output value
+* @param N number of indexed elements
+* @param X input array
+* @param strideX stride length
+* @return output value
*/
-double stdlib_strided_dmeanpn( const int64_t N, const double *X, const int64_t stride ) {
+double API_SUFFIX(stdlib_strided_dmeanpn)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) {
+ const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dmeanpn_ndarray)( N, X, strideX, ox );
+}
+
+/**
+* Computes the arithmetic mean of a double-precision floating-point strided array using a two-pass error correction algorithm and alternative indexing semantics.
+*
+* @param N number of indexed elements
+* @param X input array
+* @param strideX stride length
+* @param offsetX starting index for X
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dmeanpn_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
double dN;
double mu;
double c;
@@ -46,17 +61,17 @@ double stdlib_strided_dmeanpn( const int64_t N, const double *X, const int64_t s
if ( N <= 0 ) {
return 0.0 / 0.0; // NaN
}
- if ( N == 1 || stride == 0 ) {
- return X[ 0 ];
+ if ( N == 1 || strideX == 0 ) {
+ return X[ offsetX ];
}
dN = (double)N;
// Compute an estimate for the mean:
- mu = stdlib_strided_dsumpw( N, X, stride );
+ mu = stdlib_strided_dsumpw_ndarray( N, X, strideX, offsetX );
mu /= dN;
// Compute an error term:
- c = stdlib_strided_dapxsumpw( N, -mu, X, stride );
+ c = stdlib_strided_dapxsumpw_ndarray( N, -mu, X, strideX, offsetX );
c /= dN;
return mu + c;
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.js
index 943c9f8061b1..d136e5ae5291 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.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 dmeanpn = require( './../lib/dmeanpn.js' );
@@ -87,7 +86,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -102,15 +100,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, 2 );
+ v = dmeanpn( 4, x, 2 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -125,8 +121,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, -2 );
+ v = dmeanpn( 4, x, -2 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
@@ -147,7 +142,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -163,9 +157,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 = dmeanpn( N, x1, 2 );
+ v = dmeanpn( 4, x1, 2 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.native.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.native.js
index 24901d904c83..f7954c9a417f 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.dmeanpn.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' );
@@ -178,7 +177,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -193,15 +191,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, 2 );
+ v = dmeanpn( 4, x, 2 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -216,8 +212,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, -2 );
+ v = dmeanpn( 4, x, -2 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
@@ -238,7 +233,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
tape( 'the function supports view offsets', opts, function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -254,9 +248,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 = dmeanpn( N, x1, 2 );
+ v = dmeanpn( 4, x1, 2 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.ndarray.js
index 06eb8b940ae1..a6dbd3eb8dc1 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/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 dmeanpn = require( './../lib/ndarray.js' );
@@ -87,7 +86,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -102,15 +100,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, 2, 0 );
+ v = dmeanpn( 4, x, 2, 0 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -125,8 +121,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, -2, 6 );
+ v = dmeanpn( 4, x, -2, 6 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
@@ -145,7 +140,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
});
tape( 'the function supports an `offset` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -159,9 +153,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) {
3.0,
4.0 // 3
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, 2, 1 );
+ v = dmeanpn( 4, x, 2, 1 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.ndarray.native.js
index b648a0c47117..ada26bc81641 100644
--- a/lib/node_modules/@stdlib/stats/base/dmeanpn/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dmeanpn/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' );
@@ -96,7 +95,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -111,15 +109,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, 2, 0 );
+ v = dmeanpn( 4, x, 2, 0 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -134,8 +130,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
2.0
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, -2, 6 );
+ v = dmeanpn( 4, x, -2, 6 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();
@@ -154,7 +149,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
});
tape( 'the function supports an `offset` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -168,9 +162,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) {
3.0,
4.0 // 3
]);
- N = floor( x.length / 2 );
- v = dmeanpn( N, x, 2, 1 );
+ v = dmeanpn( 4, x, 2, 1 );
t.strictEqual( v, 1.25, 'returns expected value' );
t.end();