diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/README.md b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/README.md index 09a7a63f133c..082218f7d2d8 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/README.md +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/README.md @@ -51,7 +51,7 @@ The [arithmetic mean][arithmetic-mean] is defined as var sdsnanmeanors = require( '@stdlib/stats/base/sdsnanmeanors' ); ``` -#### sdsnanmeanors( N, x, stride ) +#### sdsnanmeanors( N, x, strideX ) Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x`, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. @@ -69,18 +69,16 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Float32Array`][@stdlib/array/float32]. -- **stride**: index increment for `x`. +- **strideX**: index increment for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [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 Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] ); -var N = floor( x.length / 2 ); -var v = sdsnanmeanors( N, x, 2 ); +var v = sdsnanmeanors( 4, x, 2 ); // returns 1.25 ``` @@ -90,18 +88,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = sdsnanmeanors( N, x1, 2 ); +var v = sdsnanmeanors( 4, x1, 2 ); // returns 1.25 ``` -#### sdsnanmeanors.ndarray( N, x, stride, offset ) +#### sdsnanmeanors.ndarray( N, x, strideX, offsetX ) Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics. @@ -109,26 +104,23 @@ Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-p var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -var N = x.length; -var v = sdsnanmeanors.ndarray( N, x, 1, 0 ); +var v = sdsnanmeanors.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 Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -var N = floor( x.length / 2 ); -var v = sdsnanmeanors.ndarray( N, x, 2, 1 ); +var v = sdsnanmeanors.ndarray( 4, x, 2, 1 ); // returns 1.25 ``` @@ -155,22 +147,12 @@ var v = sdsnanmeanors.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var sdsnanmeanors = require( '@stdlib/stats/base/sdsnanmeanors' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( (randu()*100.0) - 50.0 ); - } -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float32' +}); console.log( x ); var v = sdsnanmeanors( x.length, x, 1 ); @@ -198,7 +180,7 @@ Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-p ```c const float x[] = { 1.0, -2.0, 0.0/0.0, 2.0 }; -double v = stdlib_strided_sdsnanmeanors( 4, x, 1 ); +double v = stdlib_strided_sdsnanmeanors( x.length, x, 1 ); // returns ~0.3333 ``` @@ -219,7 +201,7 @@ Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-p ```c const float x[] = { 1.0, -2.0, 0.0/0.0, 2.0 }; -double v = stdlib_strided_sdsnanmeanors_ndarray( 4, x, 1, 0 ); +double v = stdlib_strided_sdsnanmeanors_ndarray( x.length, x, 1, 0 ); // returns ~0.3333 ``` diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.js index 8b36975df7f8..eee9088aa95c 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.js @@ -21,14 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sdsnanmeanors = require( './../lib/sdsnanmeanors.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + // FUNCTIONS // /** @@ -39,17 +45,7 @@ var sdsnanmeanors = require( './../lib/sdsnanmeanors.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( 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 = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.native.js index 4d2212ef436a..795f73f9fadd 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/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 uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +35,9 @@ var sdsnanmeanors = tryRequire( resolve( __dirname, './../lib/sdsnanmeanors.nati var opts = { 'skip': ( sdsnanmeanors instanceof Error ) }; +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -48,17 +50,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( 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 = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.ndarray.js index 758f552378fd..7970d4e65df5 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.ndarray.js @@ -21,14 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sdsnanmeanors = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + // FUNCTIONS // /** @@ -39,17 +45,7 @@ var sdsnanmeanors = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( 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 = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.ndarray.native.js index e9d3a65aa30b..f7322d595995 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/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 uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +35,9 @@ var sdsnanmeanors = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' var opts = { 'skip': ( sdsnanmeanors instanceof Error ) }; +var options = { + 'dtype': 'float32' +}; // FUNCTIONS // @@ -48,17 +50,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( 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 = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/docs/repl.txt index 8c212be775ff..37bb4734e670 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/docs/repl.txt @@ -1,11 +1,11 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. - 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. @@ -22,8 +22,8 @@ x: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride Length. Returns ------- @@ -37,22 +37,19 @@ > {{alias}}( x.length, x, 1 ) ~0.3333 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN ] ); - > 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/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] ); > var x1 = new {{alias:@stdlib/array/float32}}( 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 single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics. @@ -69,10 +66,10 @@ x: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride Length. - offset: integer + offsetX: integer Starting index. Returns @@ -89,8 +86,7 @@ // Using offset parameter: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] ); - > 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/sdsnanmeanors/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/docs/types/index.d.ts index 94a947f481d9..7807332406aa 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/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 = sdsnanmeanors( x.length, x, 1 ); * // returns ~0.3333 */ - ( N: number, x: Float32Array, stride: number ): number; + ( N: number, x: Float32Array, strideX: number ): number; /** * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation 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 = sdsnanmeanors.ndarray( x.length, x, 1, 0 ); * // returns ~0.3333 */ - ndarray( N: number, x: Float32Array, stride: number, offset: number ): number; + ndarray( N: number, x: Float32Array, 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/sdsnanmeanors/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/examples/c/example.c index 610fd055e7d2..1bcb31d6be1d 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/stats/base/sdsnanmeanors.h" -#include #include int main( void ) { // Create a strided array: - float 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 float 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 arithmetic mean: - float v = stdlib_strided_sdsnanmeanors( N, x, stride ); + float v = stdlib_strided_sdsnanmeanors( N, x, strideX ); // Print the result: printf( "mean: %f\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/examples/index.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/examples/index.js index dfd679fa98e3..a20a077abed9 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/examples/index.js @@ -18,22 +18,12 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var sdsnanmeanors = require( './../lib' ); -var x; -var i; - -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( (randu()*100.0) - 50.0 ); - } -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float32' +}); console.log( x ); var v = sdsnanmeanors( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/include/stdlib/stats/base/sdsnanmeanors.h b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/include/stdlib/stats/base/sdsnanmeanors.h index 7e589d48c9ca..d5498561a29d 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/include/stdlib/stats/base/sdsnanmeanors.h +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/include/stdlib/stats/base/sdsnanmeanors.h @@ -31,12 +31,12 @@ extern "C" { /** * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. */ -float API_SUFFIX( stdlib_strided_sdsnanmeanors )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); +double API_SUFFIX( stdlib_strided_sdsnanmeanors )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); /** -* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. +* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics. */ -float API_SUFFIX( stdlib_strided_sdsnanmeanors_ndarray )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +double API_SUFFIX( stdlib_strided_sdsnanmeanors_ndarray )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/index.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/index.js index 07991c112927..1f8a4d616c44 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/index.js @@ -28,20 +28,17 @@ * var sdsnanmeanors = require( '@stdlib/stats/base/sdsnanmeanors' ); * * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = sdsnanmeanors( N, x, 1 ); +* var v = sdsnanmeanors( x.length, x, 1 ); * // returns ~0.3333 * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var sdsnanmeanors = require( '@stdlib/stats/base/sdsnanmeanors' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = sdsnanmeanors.ndarray( N, x, 2, 1 ); +* var v = sdsnanmeanors.ndarray( 4, x, 2, 1 ); * // returns 1.25 */ diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.js index 6a69f321246b..85d789dc0a60 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.js @@ -26,7 +26,7 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); // MAIN // /** -* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. +* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics. * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array @@ -36,12 +36,10 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = sdsnanmeanors( N, x, 2, 1 ); +* var v = sdsnanmeanors( 4, x, 2, 1 ); * // returns 1.25 */ function sdsnanmeanors( N, x, strideX, offsetX ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.native.js index ebbd22391453..71aea189a8fc 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/ndarray.native.js @@ -26,22 +26,20 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. +* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics. * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array * @param {integer} strideX - stride length -* @param {NonNegativeInteger} offsetX - starting index +* @param {NonNegativeInteger} offsetX - starting index for x * @returns {number} arithmetic mean * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = sdsnanmeanors( N, x, 2, 1 ); +* var v = sdsnanmeanors( 4, x, 2, 1 ); * //returns 1.25 */ function sdsnanmeanors( N, x, strideX, offsetX ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.js index 471caa790281..8b4faf89871d 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.js @@ -38,9 +38,8 @@ var ndarray = require( './ndarray.js' ); * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = sdsnanmeanors( N, x, 1 ); +* var v = sdsnanmeanors( x.length, x, 1 ); * // returns ~0.3333 */ function sdsnanmeanors( N, x, strideX ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.native.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.native.js index 3658b091e215..dadf1cb37967 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.native.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/lib/sdsnanmeanors.native.js @@ -37,9 +37,8 @@ var addon = require( './../src/addon.node' ); * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = sdsnanmeanors( N, x, 1 ); +* var v = sdsnanmeanors( x.length, x, 1 ); * //returns ~0.3333 */ function sdsnanmeanors( N, x, strideX ) { diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/addon.c b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/addon.c index b51e25ea23f5..3b802fbf59fd 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/addon.c @@ -37,7 +37,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, ( double )API_SUFFIX( stdlib_strided_sdsnanmeanors )( N, X, strideX ), v ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX( stdlib_strided_sdsnanmeanors )( N, X, strideX ), v ); return v; } @@ -54,7 +54,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, ( double )API_SUFFIX( stdlib_strided_sdsnanmeanors_ndarray )( N, X, strideX, offsetX ), v ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX( stdlib_strided_sdsnanmeanors_ndarray )( N, X, strideX, offsetX ), v ); return v; } diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/main.c b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/main.c index 5db0b8592df3..f0e8d8fcdd73 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/src/main.c @@ -27,22 +27,22 @@ * @param N number of indexed elements * @param X input array * @param strideX stride length -* @return output value +* @return output value */ -float API_SUFFIX( stdlib_strided_sdsnanmeanors )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) { +double API_SUFFIX( stdlib_strided_sdsnanmeanors )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) { const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); return API_SUFFIX( stdlib_strided_sdsnanmeanors_ndarray )( N, X, strideX, ox ); } /** -* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation. +* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics. * * @param N number of indexed elements * @param X input array * @param strideX stride length -* @param offsetX starting index -* @return output value +* @param offsetX starting index for X +* @return output value */ -float API_SUFFIX( stdlib_strided_sdsnanmeanors_ndarray )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { +double API_SUFFIX( stdlib_strided_sdsnanmeanors_ndarray )( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { double sum; CBLAS_INT ix; CBLAS_INT i; diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.ndarray.js index 6dd301d335a4..b66c2e7ead9b 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/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 Float32Array = require( '@stdlib/array/float32' ); var sdsnanmeanors = require( './../lib/ndarray.js' ); @@ -90,7 +89,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; @@ -106,15 +104,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, 2, 0 ); + v = sdsnanmeanors( 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; @@ -130,8 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) NaN // 0 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, -2, 6 ); + v = sdsnanmeanors( 4, x, -2, 6 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -150,7 +145,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; @@ -166,9 +160,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, 2, 1 ); + v = sdsnanmeanors( 4, x, 2, 1 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.ndarray.native.js index 11c4168584b0..ebc1a2d598ee 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/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 Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -99,7 +98,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; @@ -115,15 +113,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, 2, 0 ); + v = sdsnanmeanors( 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; @@ -139,8 +135,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test NaN // 0 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, -2, 6 ); + v = sdsnanmeanors( 4, x, -2, 6 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -159,7 +154,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; @@ -175,9 +169,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, 2, 1 ); + v = sdsnanmeanors( 4, x, 2, 1 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.js index 5c3250725ead..4aa6c85faaac 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.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 Float32Array = require( '@stdlib/array/float32' ); var sdsnanmeanors = require( './../lib/sdsnanmeanors.js' ); @@ -62,7 +61,7 @@ tape( 'the function calculates the arithmetic mean of a strided array, ignoring t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { +tape( 'if provided an `4` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) { var x; var v; @@ -77,7 +76,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if provided an `N` parameter equal to `1`, the function returns the first element', function test( t ) { +tape( 'if provided an `4` parameter equal to `1`, the function returns the first element', function test( t ) { var x; var v; @@ -90,7 +89,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; @@ -106,15 +104,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, 2 ); + v = sdsnanmeanors( 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; @@ -130,8 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) NaN // 0 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, -2 ); + v = sdsnanmeanors( 4, x, -2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -152,7 +147,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 Float32Array([ @@ -169,9 +163,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = sdsnanmeanors( N, x1, 2 ); + v = sdsnanmeanors( 4, x1, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.native.js b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.native.js index a329de71f4ce..60ccabbf74e3 100644 --- a/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.native.js +++ b/lib/node_modules/@stdlib/stats/base/sdsnanmeanors/test/test.sdsnanmeanors.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 Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -153,7 +152,7 @@ tape( 'the function calculates the arithmetic mean of a strided array, ignoring t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', opts, function test( t ) { +tape( 'if provided an `4` parameter less than or equal to `0`, the function returns `NaN`', opts, function test( t ) { var x; var v; @@ -168,7 +167,7 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu t.end(); }); -tape( 'if provided an `N` parameter equal to `1`, the function returns the first element', opts, function test( t ) { +tape( 'if provided an `4` parameter equal to `1`, the function returns the first element', opts, function test( t ) { var x; var v; @@ -181,7 +180,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; @@ -197,15 +195,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, 2 ); + v = sdsnanmeanors( 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; @@ -221,8 +217,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test NaN // 0 ]); - N = floor( x.length / 2 ); - v = sdsnanmeanors( N, x, -2 ); + v = sdsnanmeanors( 4, x, -2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -243,7 +238,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 Float32Array([ @@ -260,9 +254,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = sdsnanmeanors( N, x1, 2 ); + v = sdsnanmeanors( 4, x1, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end();