diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/README.md
index 48d27c59b488..dd74fe349b79 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/README.md
@@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
var dnanvarianceyc = require( '@stdlib/stats/base/dnanvarianceyc' );
```
-#### dnanvarianceyc( N, correction, x, stride )
+#### dnanvarianceyc( N, correction, x, strideX )
-Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
+Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -116,41 +116,38 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
- **x**: input [`Float64Array`][@stdlib/array/float64].
-- **stride**: index increment for `x`.
+- **strideX**: 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, NaN ] );
-var N = floor( x.length / 2 );
+var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ] );
-var v = dnanvarianceyc( N, 1, x, 2 );
+var v = dnanvarianceyc( 5, 1, x, 2 );
// returns 6.25
```
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
-
+
```javascript
var Float64Array = require( '@stdlib/array/float64' );
-var floor = require( '@stdlib/math/base/special/floor' );
-var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
+var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
-var N = floor( x0.length / 2 );
-
-var v = dnanvarianceyc( N, 1, x1, 2 );
+var v = dnanvarianceyc( 5, 1, x1, 2 );
// returns 6.25
```
-#### dnanvarianceyc.ndarray( N, correction, x, stride, offset )
+#### dnanvarianceyc.ndarray( N, correction, x, strideX, offsetX )
-Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
+Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -163,18 +160,18 @@ var v = dnanvarianceyc.ndarray( x.length, 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 element in `x` starting from the second element
-While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [variance][variance] for every other value in `x` starting from the second value
+
```javascript
var Float64Array = require( '@stdlib/array/float64' );
-var floor = require( '@stdlib/math/base/special/floor' );
-var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
-var N = floor( x.length / 2 );
+var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-var v = dnanvarianceyc.ndarray( N, 1, x, 2, 1 );
+var v = dnanvarianceyc.ndarray( 5, 1, x, 2, 1 );
// returns 6.25
```
@@ -200,18 +197,19 @@ var v = dnanvarianceyc.ndarray( N, 1, x, 2, 1 );
```javascript
-var randu = require( '@stdlib/random/base/randu' );
-var round = require( '@stdlib/math/base/special/round' );
-var Float64Array = require( '@stdlib/array/float64' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var dnanvarianceyc = require( '@stdlib/stats/base/dnanvarianceyc' );
-var x;
-var i;
-
-x = new Float64Array( 10 );
-for ( i = 0; i < x.length; i++ ) {
- x[ i ] = round( (randu()*100.0) - 50.0 );
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -50.0, 50.0 );
}
+
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var v = dnanvarianceyc( x.length, 1, x, 1 );
@@ -222,6 +220,125 @@ console.log( v );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/stats/base/dnanvarianceyc.h"
+```
+
+#### stdlib_strided_dnanvarianceyc( N, correction, \*X, strideX )
+
+Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
+
+```c
+const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
+
+double v = stdlib_strided_dnanvarianceyc( 4, 1.0, x, 1 );
+// returns ~4.3333
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
+- **X**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+
+```c
+double stdlib_strided_dnanvarianceyc( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dnanvarianceyc_ndarray( N, correction, \*X, strideX, offsetX )
+
+Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
+
+```c
+const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
+
+double v = stdlib_strided_dnanvarianceyc_ndarray( 4, 1.0, x, 1, 0 );
+// returns ~4.3333
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
+- **X**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+
+```c
+double stdlib_strided_dnanvarianceyc_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/stats/base/dnanvarianceyc.h"
+#include
+
+int main( void ) {
+ // Create a strided array:
+ const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
+
+ // Specify the number of elements:
+ const int N = 6;
+
+ // Specify the stride length:
+ const int strideX = 2;
+
+ // Compute the variance:
+ double v = stdlib_strided_dnanvarianceyc( N, 1, x, strideX );
+
+ // Print the result:
+ printf( "sample variance: %lf\n", v );
+}
+```
+
+
+
+
+
+
+
+
+
* * *
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.js
index 8c993a19d96b..41294439ba31 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.js
@@ -21,16 +21,30 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dnanvarianceyc = require( './../lib/dnanvarianceyc.js' );
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -39,17 +53,7 @@ var dnanvarianceyc = require( './../lib/dnanvarianceyc.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.native.js
index dd0aac5d412e..5a88ac9ac5e9 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.native.js
@@ -22,10 +22,11 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
@@ -40,6 +41,19 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -48,17 +62,7 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.js
index bf4f2f8250e5..623dfdd254aa 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.js
@@ -21,16 +21,30 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dnanvarianceyc = require( './../lib/ndarray.js' );
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -39,17 +53,7 @@ var dnanvarianceyc = require( './../lib/ndarray.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.native.js
index bae54967cd09..cfff51b0f7f1 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/benchmark.ndarray.native.js
@@ -22,10 +22,11 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
@@ -40,6 +41,19 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -48,17 +62,7 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/c/benchmark.length.c
index 4ddce57bc641..2d5fb2f00d0e 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/benchmark/c/benchmark.length.c
@@ -94,7 +94,7 @@ static double rand_double( void ) {
* @param len array length
* @return elapsed time in seconds
*/
-static double benchmark( int iterations, int len ) {
+static double benchmark1( int iterations, int len ) {
double elapsed;
double x[ len ];
double v;
@@ -102,11 +102,16 @@ static double benchmark( int iterations, int len ) {
int i;
for ( i = 0; i < len; i++ ) {
- x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ if ( rand_double() < 0.2 ) {
+ x[ i ] = 0.0 / 0.0; // NaN
+ } else {
+ x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ }
}
v = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
v = stdlib_strided_dnanvarianceyc( len, 1.0, x, 1 );
if ( v != v ) {
printf( "should not return NaN\n" );
@@ -120,6 +125,44 @@ static double benchmark( int iterations, int len ) {
return elapsed;
}
+/**
+* Runs a benchmark.
+*
+* @param iterations number of iterations
+* @param len array length
+* @return elapsed time in seconds
+*/
+static double benchmark2( int iterations, int len ) {
+ double elapsed;
+ double x[ len ];
+ double v;
+ double t;
+ int i;
+
+ for ( i = 0; i < len; i++ ) {
+ if ( rand_double() < 0.2 ) {
+ x[ i ] = 0.0 / 0.0; // NaN
+ } else {
+ x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ }
+ }
+ v = 0.0;
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
+ v = stdlib_strided_dnanvarianceyc_ndarray( len, 1.0, x, 1, 0 );
+ if ( v != v ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( v != v ) {
+ printf( "should not return NaN\n" );
+ }
+ return elapsed;
+}
+
/**
* Main execution sequence.
*/
@@ -142,7 +185,18 @@ int main( void ) {
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:len=%d\n", NAME, len );
- elapsed = benchmark( iter, len );
+ elapsed = benchmark1( iter, len );
+ print_results( iter, elapsed );
+ printf( "ok %d benchmark finished\n", count );
+ }
+ }
+ for ( i = MIN; i <= MAX; i++ ) {
+ len = pow( 10, i );
+ iter = ITERATIONS / pow( 10, i-1 );
+ for ( j = 0; j < REPEATS; j++ ) {
+ count += 1;
+ printf( "# c::%s:ndarray:len=%d\n", NAME, len );
+ elapsed = benchmark2( iter, len );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/repl.txt
index 437e36657f69..cbc67caed09b 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/repl.txt
@@ -1,11 +1,11 @@
-{{alias}}( N, correction, x, stride )
+{{alias}}( N, correction, x, strideX )
Computes the variance of a double-precision floating-point strided array
ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and
Cramer.
- 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.
@@ -35,8 +35,8 @@
x: Float64Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
Returns
-------
@@ -46,26 +46,23 @@
Examples
--------
// Standard Usage:
- > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, NaN, 2.0 ] );
+ > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] );
> {{alias}}( x.length, 1, x, 1 )
~4.3333
- // Using `N` and `stride` parameters:
- > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] );
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > var stride = 2;
- > {{alias}}( N, 1, x, stride )
+ // Using `N` and stride parameters:
+ > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] );
+ > {{alias}}( 4, 1, x, 2 )
~4.3333
// Using view offsets:
- > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
+ > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
- > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
- > stride = 2;
- > {{alias}}( N, 1, x1, stride )
+ > {{alias}}( 4, 1, x1, 2 )
~4.3333
-{{alias}}.ndarray( N, correction, x, stride, offset )
+
+{{alias}}.ndarray( N, correction, x, strideX, offsetX )
Computes the variance of a double-precision floating-point strided array
ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and
Cramer and alternative indexing semantics.
@@ -95,10 +92,10 @@
x: Float64Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
- offset: integer
+ offsetX: integer
Starting index.
Returns
@@ -114,9 +111,8 @@
~4.3333
// Using offset parameter:
- > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > {{alias}}.ndarray( N, 1, x, 2, 1 )
+ > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] );
+ > {{alias}}.ndarray( 4, 1, x, 2, 1 )
~4.3333
See Also
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/types/index.d.ts
index 0e9e71e34524..ac2e5e8daf35 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/docs/types/index.d.ts
@@ -28,7 +28,7 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
- * @param stride - stride length
+ * @param strideX - stride length
* @returns variance
*
* @example
@@ -39,7 +39,7 @@ interface Routine {
* var v = dnanvarianceyc( x.length, 1, x, 1 );
* // returns ~4.3333
*/
- ( N: number, correction: number, x: Float64Array, stride: number ): number;
+ ( N: number, correction: number, x: Float64Array, strideX: number ): number;
/**
* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
@@ -47,8 +47,8 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
- * @param stride - stride length
- * @param offset - starting index
+ * @param strideX - stride length
+ * @param offsetX - starting index
* @returns variance
*
* @example
@@ -59,7 +59,7 @@ interface Routine {
* var v = dnanvarianceyc.ndarray( x.length, 1, x, 1, 0 );
* // returns ~4.3333
*/
- ndarray( N: number, correction: number, x: Float64Array, stride: number, offset: number ): number;
+ ndarray( N: number, correction: number, x: Float64Array, strideX: number, offsetX: number ): number;
}
/**
@@ -68,7 +68,7 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
-* @param stride - stride length
+* @param strideX - stride length
* @returns variance
*
* @example
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/c/example.c
index 6be481987f30..5a3154ae7a9c 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/c/example.c
@@ -17,21 +17,20 @@
*/
#include "stdlib/stats/base/dnanvarianceyc.h"
-#include
#include
int main( void ) {
// Create a strided array:
- double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
+ const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
// Specify the number of elements:
- int64_t N = 6;
+ const int N = 6;
// Specify the stride length:
- int64_t stride = 2;
+ const int strideX = 2;
// Compute the variance:
- double v = stdlib_strided_dnanvarianceyc( N, 1, x, stride );
+ double v = stdlib_strided_dnanvarianceyc( N, 1.0, x, strideX );
// Print the result:
printf( "sample variance: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/index.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/index.js
index 3c45f489f245..4c3558df7c29 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/examples/index.js
@@ -18,22 +18,19 @@
'use strict';
-var randu = require( '@stdlib/random/base/randu' );
-var round = require( '@stdlib/math/base/special/round' );
-var Float64Array = require( '@stdlib/array/float64' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var dnanvarianceyc = require( './../lib' );
-var x;
-var i;
-
-x = new Float64Array( 10 );
-for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = round( (randu()*100.0) - 50.0 );
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
}
+ return uniform( -50.0, 50.0 );
}
+
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var v = dnanvarianceyc( x.length, 1, x, 1 );
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/include/stdlib/stats/base/dnanvarianceyc.h b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/include/stdlib/stats/base/dnanvarianceyc.h
index 8e80313f2364..b6e0bc82c8a9 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/include/stdlib/stats/base/dnanvarianceyc.h
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/include/stdlib/stats/base/dnanvarianceyc.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_STATS_BASE_DNANVARIANCEYC_H
#define STDLIB_STATS_BASE_DNANVARIANCEYC_H
-#include
+#include "stdlib/blas/base/shared.h"
/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
@@ -31,7 +31,12 @@ extern "C" {
/**
* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
*/
-double stdlib_strided_dnanvarianceyc( const int64_t N, const double correction, const double *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dnanvarianceyc)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX );
+
+/**
+* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dnanvarianceyc_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.js
index 0cd744d5eaef..4c926fc23702 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.js
@@ -18,6 +18,12 @@
'use strict';
+// MODULES //
+
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
+
+
// MAIN //
/**
@@ -34,74 +40,19 @@
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
-* var N = x.length;
*
-* var v = dnanvarianceyc( N, 1, x, 1 );
+* var v = dnanvarianceyc( x.length, 1, x, 1 );
* // returns ~4.3333
*/
-function dnanvarianceyc( N, correction, x, stride ) {
- var sum;
- var ix;
- var nc;
- var S;
- var v;
- var d;
- var n;
- var i;
-
- if ( N <= 0 ) {
- return NaN;
- }
- if ( N === 1 || stride === 0 ) {
- v = x[ 0 ];
- if ( v === v && N-correction > 0.0 ) {
- return 0.0;
- }
- return NaN;
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- // Find the first non-NaN element...
- for ( i = 0; i < N; i++ ) {
- v = x[ ix ];
- if ( v === v ) {
- break;
- }
- ix += stride;
- }
- if ( i === N ) {
- return NaN;
- }
- ix += stride;
- sum = v;
- S = 0.0;
- i += 1;
- n = 1;
- for ( i; i < N; i++ ) {
- v = x[ ix ];
- if ( v === v ) {
- n += 1;
- sum += v;
- d = (n*v) - sum;
- S += (1.0/(n*(n-1))) * d * d;
- }
- ix += stride;
- }
- nc = n - correction;
- if ( nc <= 0.0 ) {
- return NaN;
- }
- return S / nc;
+function dnanvarianceyc( N, correction, x, strideX ) {
+ return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.native.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.native.js
index 6044fd3fb80a..a300476dc267 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/dnanvarianceyc.native.js
@@ -31,20 +31,19 @@ var addon = require( './../src/addon.node' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
-* var N = x.length;
*
-* var v = dnanvarianceyc( N, 1, x, 1 );
+* var v = dnanvarianceyc( x.length, 1, x, 1 );
* // returns ~4.3333
*/
-function dnanvarianceyc( N, correction, x, stride ) {
- return addon( N, correction, x, stride );
+function dnanvarianceyc( N, correction, x, strideX ) {
+ return addon( N, correction, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/index.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/index.js
index ecdbdd240075..1a8daefaba96 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/index.js
@@ -28,20 +28,17 @@
* var dnanvarianceyc = require( '@stdlib/stats/base/dnanvarianceyc' );
*
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
-* var N = x.length;
*
-* var v = dnanvarianceyc( N, 1, x, 1 );
+* var v = dnanvarianceyc( x.length, 1, x, 1 );
* // returns ~4.3333
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
* var dnanvarianceyc = require( '@stdlib/stats/base/dnanvarianceyc' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-* var N = floor( x.length / 2 );
*
-* var v = dnanvarianceyc.ndarray( N, 1, x, 2, 1 );
+* var v = dnanvarianceyc.ndarray( 5, 1, x, 2, 1 );
* // returns 6.25
*/
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.js
index a2c9d4029c09..61f515aeb9a9 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.js
@@ -34,21 +34,19 @@
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
-* @param {NonNegativeInteger} offset - starting index
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-* var N = floor( x.length / 2 );
*
-* var v = dnanvarianceyc( N, 1, x, 2, 1 );
+* var v = dnanvarianceyc( 5, 1, x, 2, 1 );
* // returns 6.25
*/
-function dnanvarianceyc( N, correction, x, stride, offset ) {
+function dnanvarianceyc( N, correction, x, strideX, offsetX ) {
var sum;
var ix;
var nc;
@@ -61,14 +59,14 @@ function dnanvarianceyc( N, correction, x, stride, offset ) {
if ( N <= 0 ) {
return NaN;
}
- if ( N === 1 || stride === 0 ) {
- v = x[ offset ];
+ if ( N === 1 || strideX === 0 ) {
+ v = x[ offsetX ];
if ( v === v && N-correction > 0.0 ) {
return 0.0;
}
return NaN;
}
- ix = offset;
+ ix = offsetX;
// Find the first non-NaN element...
for ( i = 0; i < N; i++ ) {
@@ -76,12 +74,12 @@ function dnanvarianceyc( N, correction, x, stride, offset ) {
if ( v === v ) {
break;
}
- ix += stride;
+ ix += strideX;
}
if ( i === N ) {
return NaN;
}
- ix += stride;
+ ix += strideX;
sum = v;
S = 0.0;
i += 1;
@@ -94,7 +92,7 @@ function dnanvarianceyc( N, correction, x, stride, offset ) {
d = (n*v) - sum;
S += (1.0/(n*(n-1))) * d * d;
}
- ix += stride;
+ ix += strideX;
}
nc = n - correction;
if ( nc <= 0.0 ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.native.js
index 9c4d7f1957cd..10960e8f7ab3 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/lib/ndarray.native.js
@@ -20,8 +20,7 @@
// MODULES //
-var Float64Array = require( '@stdlib/array/float64' );
-var addon = require( './dnanvarianceyc.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,27 +31,20 @@ var addon = require( './dnanvarianceyc.native.js' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
-* @param {NonNegativeInteger} offset - starting index
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-* var N = floor( x.length / 2 );
*
-* var v = dnanvarianceyc( N, 1, x, 2, 1 );
+* var v = dnanvarianceyc( 5, 1, x, 2, 1 );
* // returns 6.25
*/
-function dnanvarianceyc( N, correction, x, stride, offset ) {
- var view;
- if ( stride < 0 ) {
- offset += (N-1) * stride;
- }
- view = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len
- return addon( N, correction, view, stride );
+function dnanvarianceyc( N, correction, x, strideX, offsetX ) {
+ return addon.ndarray( N, correction, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/manifest.json b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/manifest.json
index c10d9247c0c6..86308d31795d 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/manifest.json
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/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/dnanvarianceyc.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/dnanvarianceyc.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/dnanvarianceyc.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/dnanvarianceyc/src/addon.c b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/addon.c
index 43d9acaa0d7c..06280745653b 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/addon.c
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/addon.c
@@ -17,6 +17,7 @@
*/
#include "stdlib/stats/base/dnanvarianceyc.h"
+#include "stdlib/blas/base/shared.h"
#include "stdlib/napi/export.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_int64.h"
@@ -36,10 +37,28 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 );
- STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
- STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 2 );
- STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dnanvarianceyc( N, correction, X, stride ), v );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dnanvarianceyc)( N, 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, 5 );
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
+ STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dnanvarianceyc_ndarray)( N, 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/dnanvarianceyc/src/dnanvarianceyc.c b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/main.c
similarity index 63%
rename from lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/dnanvarianceyc.c
rename to lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/main.c
index ab921aeb225b..f33b4652eb94 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/dnanvarianceyc.c
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/src/main.c
@@ -17,7 +17,8 @@
*/
#include "stdlib/stats/base/dnanvarianceyc.h"
-#include
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
/**
* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
@@ -33,46 +34,58 @@
* @param N number of indexed elements
* @param correction degrees of freedom adjustment
* @param X input array
-* @param stride stride length
+* @param strideX stride length
* @return output value
*/
-double stdlib_strided_dnanvarianceyc( const int64_t N, const double correction, const double *X, const int64_t stride ) {
+double API_SUFFIX(stdlib_strided_dnanvarianceyc)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ) {
+ const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dnanvarianceyc_ndarray)( N, correction, X, strideX, ox );
+}
+
+/**
+* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
+*
+* @param N number of indexed elements
+* @param correction degrees of freedom adjustment
+* @param X input array
+* @param strideX stride length
+* @param offsetX starting index for X
+* @return variance
+*/
+double API_SUFFIX(stdlib_strided_dnanvarianceyc_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
+ CBLAS_INT ix;
+ CBLAS_INT i;
double sum;
- int64_t ix;
double nc;
double n;
- double S;
double v;
+ double S;
double d;
- double i;
if ( N <= 0 ) {
return 0.0 / 0.0; // NaN
}
- if ( N == 1 || stride == 0 ) {
- v = X[ 0 ];
+ if ( N == 1 || strideX == 0 ) {
+ v = X[ offsetX ];
if ( v == v && (double)N-correction > 0.0 ) {
return 0.0;
}
return 0.0 / 0.0; // NaN
}
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
+ ix = offsetX;
+
// Find the first non-NaN element...
for ( i = 0; i < N; i++ ) {
v = X[ ix ];
if ( v == v ) {
break;
}
- ix += stride;
+ ix += strideX;
}
if ( i == N ) {
return 0.0 / 0.0; // NaN
}
- ix += stride;
+ ix += strideX;
sum = v;
S = 0.0;
n = 1.0;
@@ -85,7 +98,7 @@ double stdlib_strided_dnanvarianceyc( const int64_t N, const double correction,
d = (n*v) - sum;
S += (1.0/(n*(n-1.0))) * d * d;
}
- ix += stride;
+ ix += strideX;
}
nc = n - correction;
if ( nc <= 0.0 ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.js
index a17af1f71520..a97dbff967e3 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.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 dnanvarianceyc = require( './../lib/dnanvarianceyc.js' );
@@ -213,7 +212,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -230,15 +228,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, 2 );
+ v = dnanvarianceyc( 5, 1, x, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
var i;
@@ -255,9 +251,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, -2 );
+ v = dnanvarianceyc( 5, 1, x, -2 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -295,7 +290,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -313,9 +307,8 @@ tape( 'the function supports view offsets', function test( t ) {
]);
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
- N = floor(x1.length / 2);
- v = dnanvarianceyc( N, 1, x1, 2 );
+ v = dnanvarianceyc( 5, 1, x1, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.native.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.native.js
index 0577493dbfeb..0b2e9c81f2c3 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.dnanvarianceyc.native.js
@@ -22,7 +22,6 @@
var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Float64Array = require( '@stdlib/array/float64' );
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -222,7 +221,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -239,15 +237,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, 2 );
+ v = dnanvarianceyc( 5, 1, x, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
var i;
@@ -264,9 +260,8 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, -2 );
+ v = dnanvarianceyc( 5, 1, x, -2 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -304,7 +299,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
tape( 'the function supports view offsets', opts, function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -322,9 +316,8 @@ tape( 'the function supports view offsets', opts, function test( t ) {
]);
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
- N = floor(x1.length / 2);
- v = dnanvarianceyc( N, 1, x1, 2 );
+ v = dnanvarianceyc( 5, 1, x1, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.ndarray.js
index 9174c0e758c0..c912497d312d 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/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 dnanvarianceyc = require( './../lib/ndarray.js' );
@@ -213,7 +212,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -230,15 +228,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, 2, 0 );
+ v = dnanvarianceyc( 5, 1, x, 2, 0 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
var i;
@@ -255,9 +251,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, -2, 8 );
+ v = dnanvarianceyc( 5, 1, x, -2, 8 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -293,7 +288,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
});
tape( 'the function supports an `offset` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -309,9 +303,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) {
NaN,
NaN // 4
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, 2, 1 );
+ v = dnanvarianceyc( 5, 1, x, 2, 1 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.ndarray.native.js
index cacf70a73e56..b94898cc6a67 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvarianceyc/test/test.ndarray.native.js
@@ -22,7 +22,6 @@
var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Float64Array = require( '@stdlib/array/float64' );
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -222,7 +221,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -239,15 +237,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, 2, 0 );
+ v = dnanvarianceyc( 5, 1, x, 2, 0 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
var i;
@@ -264,9 +260,8 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, -2, 8 );
+ v = dnanvarianceyc( 5, 1, x, -2, 8 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -302,7 +297,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
});
tape( 'the function supports an `offset` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -318,9 +312,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) {
NaN,
NaN // 4
]);
- N = floor( x.length / 2 );
- v = dnanvarianceyc( N, 1, x, 2, 1 );
+ v = dnanvarianceyc( 5, 1, x, 2, 1 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();