diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/README.md b/lib/node_modules/@stdlib/blas/base/zaxpy/README.md
index 12e11b4a6dd3..b5529e5e1007 100644
--- a/lib/node_modules/@stdlib/blas/base/zaxpy/README.md
+++ b/lib/node_modules/@stdlib/blas/base/zaxpy/README.md
@@ -51,9 +51,9 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **alpha**: scalar [`Complex128`][@stdlib/complex/float64/ctor] constant.
- **x**: first input [`Complex128Array`][@stdlib/array/complex128].
-- **strideX**: index increment for `x`.
+- **strideX**: stride length for `x`.
- **y**: second input [`Complex128Array`][@stdlib/array/complex128].
-- **strideY**: index increment for `y`.
+- **strideY**: stride length for `y`.
The `N` and stride parameters determine how values from `x` are scaled by `alpha` and added to `y`. For example, to scale every other value in `x` by `alpha` and add the result to every other value of `y`,
@@ -137,6 +137,7 @@ zaxpy.ndarray( 3, alpha, x, 1, 1, y, 1, 1 );
## Notes
- If `N <= 0`, both functions return `y` unchanged.
+- If `alpha === 0`, both functions return `y` unchanged.
- `zaxpy()` corresponds to the [BLAS][blas] level 1 function [`zaxpy`][zaxpy].
@@ -171,6 +172,14 @@ var alpha = new Complex128( 2.0, 2.0 );
// Scale values from `x` by `alpha` and add the result to `y`:
zaxpy( x.length, alpha, x, 1, y, 1 );
+// Print the results:
+logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y );
+
+yc = zcopy( y.length, y, 1, zeros( y.length, 'complex128' ), 1 );
+
+// Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics:
+zaxpy.ndarray( x.length, alpha, x, 1, 0, y, 1, 0 );
+
// Print the results:
logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y );
```
@@ -179,6 +188,152 @@ logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/base/caxpy.h"
+```
+
+#### c_caxpy( N, alpha, \*X, strideX, \*Y, strideY )
+
+Scales values from `X` by `alpha` and adds the result to `Y`.
+
+```c
+#include "stdlib/complex/float32/ctor.h"
+
+float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+float y[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 };
+const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 );
+
+c_caxpy( 4, alpha, (void *)x, 1, (void *)y, 1 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **alpha**: `[in] stdlib_complex128_t` scalar constant.
+- **X**: `[in] void*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **Y**: `[inout] void*` output array.
+- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
+
+```c
+void c_caxpy( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *x, const CBLAS_INT strideX, void *y, const CBLAS_INT strideY );
+```
+
+#### c_caxpy_ndarray( N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY )
+
+Scales values from `X` by `alpha` and adds the result to `Y` using alternative indexing semantics.
+
+```c
+#include "stdlib/complex/float32/ctor.h"
+
+float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+float y[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 };
+const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 );
+
+c_caxpy_ndarray( 4, alpha, (void *)x, 1, 0, (void *)y, 1, 0 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **alpha**: `[in] stdlib_complex128_t` scalar constant.
+- **X**: `[in] void*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+- **Y**: `[inout] void*` output array.
+- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
+- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
+
+```c
+void c_caxpy_ndarray( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/base/caxpy.h"
+#include "stdlib/complex/float32/ctor.h"
+#include
+
+int main( void ) {
+ // Create strided arrays:
+ double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+ double y[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
+
+ // Create a complex scalar:
+ const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 );
+
+ // Specify the number of elements:
+ const int N = 4;
+
+ // Specify stride lengths:
+ const int strideX = 1;
+ const int strideY = 1;
+
+ // Scale values from `x` by `alpha` and add the result to `y`:
+ c_zaxpy( N, alpha, (void *)x, strideX, (void *)y, strideY );
+
+ // Print the result:
+ for ( int i = 0; i < N; i++ ) {
+ printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] );
+ }
+
+ // Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics:
+ c_zaxpy_ndarray( N, alpha, (void *)x, strideX, 0, (void *)y, strideY, 0 );
+
+ // Print the result:
+ for ( int i = 0; i < N; i++ ) {
+ printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] );
+ }
+}
+```
+
+
+
+
+
+
+
+
+
@@ -191,7 +183,7 @@ for ( i = 0; i < p.length; i++ ) {
#### stdlib_base_dists_kumaraswamy_quantile( p, a, b )
-Evaluates the quantile function of a Kumaraswamy's double bounded distribution.
+Evaluates the quantile function of a [Kumaraswamy's double bounded][kumaraswamy-distribution] distribution with parameters `a` (first shape parameter) and `b` (second shape parameter).
```c
double out = stdlib_base_dists_kumaraswamy_quantile( 0.5, 1.0, 1.0 );
@@ -205,8 +197,7 @@ The function accepts the following arguments:
- **b**: `[in] double` second shape parameter.
```c
-double stdlib_base_dists_kumaraswamy_quantile( const double p, const
-double a, const double b );
+double stdlib_base_dists_kumaraswamy_quantile( const double p, const double a, const double b );
```
diff --git a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js
index af11e2caa9af..667a70687650 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/quantile/examples/index.js
@@ -20,19 +20,11 @@
var uniform = require( '@stdlib/random/array/uniform' );
var EPS = require( '@stdlib/constants/float64/eps' );
+var logEachMap = require( '@stdlib/console/log-each-map' );
var quantile = require( './../lib' );
-var a;
-var b;
-var p;
-var y;
-var i;
+var p = uniform( 10, 0.0, 1.0 );
+var a = uniform( 10, EPS, 5.0 );
+var b = uniform( 10, EPS, 5.0 );
-p = uniform( 10, 0.0, 1.0 );
-a = uniform( 10, EPS, 5.0 );
-b = uniform( 10, EPS, 5.0 );
-
-for ( i = 0; i < p.length; i++ ) {
- y = quantile( p[ i ], a[ i ], b[ i ] );
- console.log( 'p: %d, a: %d, b: %d, Q(p;a,b): %d', p[ i ].toFixed( 4 ), a[ i ].toFixed( 4 ), b[ i ].toFixed( 4 ), y.toFixed( 4 ) );
-}
+logEachMap( 'p: %0.4f, a: %0.4f, b: %0.4f, Q(p;a,b): %0.4f', p, a, b, quantile );
diff --git a/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js
index 2c3ad550ecfb..9437df79e258 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js
@@ -86,7 +86,7 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio
t.end();
});
-tape( 'the function returns the mean of a Laplace distribution', opts, function test( t ) {
+tape( 'the function returns the expected value of a Laplace distribution', opts, function test( t ) {
var expected;
var mu;
var b;
diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js
index e6fe71419d21..9c9b786e649d 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/kurtosis/test/test.native.js
@@ -92,7 +92,7 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re
t.end();
});
-tape( 'the function returns the kurtosis of a negative binomial distribution', opts, function test( t ) {
+tape( 'the function returns the excess kurtosis of a negative binomial distribution', opts, function test( t ) {
var expected;
var r;
var p;
diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js
index 24dd0753faca..dbc3fef031e7 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/variance/test/test.native.js
@@ -75,7 +75,7 @@ tape( 'if provided `r <= 0` or `p <= 0` or `p > 1`, the function returns `NaN`',
t.end();
});
-tape( 'the function evaluates the variance for a negative binomial distribution', opts, function test( t ) {
+tape( 'the function returns the variance of a negative binomial distribution', opts, function test( t ) {
var expected;
var delta;
var tol;
diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js
index b68e051730a8..1c04a206c328 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js
@@ -67,7 +67,7 @@ tape( 'if provided a shape parameter `lambda` which is nonpositive, the function
t.end();
});
-tape( 'the function returns the entropy of a Planck distribution', opts, function test( t ) {
+tape( 'the function returns the differential entropy of a Planck distribution', opts, function test( t ) {
var expected;
var lambda;
var delta;
diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md
index 36847244b0af..6c9974e44cfb 100644
--- a/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md
@@ -115,6 +115,30 @@ y = mycdf( 8.0 );
+
+
+## Examples
+
+
+
+```javascript
+var uniform = require( '@stdlib/random/array/uniform' );
+var logEachMap = require( '@stdlib/console/log-each-map' );
+var cdf = require( '@stdlib/stats/base/dists/poisson/cdf' );
+
+var opts = {
+ 'dtype': 'float64'
+};
+var lambda = uniform( 10, 0.0, 10.0, opts );
+var x = uniform( 10, 0.0, 10.0, opts );
+
+logEachMap( 'x: %0.4f, λ: %0.4f, F(x;λ): %0.4f', x, lambda, cdf );
+```
+
+
+
+
+
* * *
@@ -175,8 +199,8 @@ static double random_uniform( double min, double max ) {
}
int main( void ) {
- double x;
double lambda;
+ double x;
double y;
int i;
@@ -197,35 +221,6 @@ int main( void ) {
-* * *
-
-
-
-## Examples
-
-
-
-```javascript
-var randu = require( '@stdlib/random/base/randu' );
-var cdf = require( '@stdlib/stats/base/dists/poisson/cdf' );
-
-var lambda;
-var x;
-var y;
-var i;
-
-for ( i = 0; i < 10; i++ ) {
- x = randu() * 10.0;
- lambda = randu() * 10.0;
- y = cdf( x, lambda );
- console.log( 'x: %d, λ: %d, F(x;λ): %d', x.toFixed( 4 ), lambda.toFixed( 4 ), y.toFixed( 4 ) );
-}
-```
-
-
-
-
-
@@ -180,23 +184,23 @@ var v = nanrangeBy.ndarray( 3, x, 1, x.length-3, accessor );
```javascript
-var uniform = require( '@stdlib/random/base/uniform' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
+var randu = require( '@stdlib/random/base/randu' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
-var bernoulli = require( '@stdlib/random/base/bernoulli' );
var nanrangeBy = require( '@stdlib/stats/base/nanrange-by' );
-function rand() {
- if ( bernoulli( 0.8 ) < 0.2 ) {
+function fill() {
+ if ( randu() < 0.2 ) {
return NaN;
}
- return uniform( -50.0, 50.0 );
+ return discreteUniform( -50, 50 );
}
function accessor( v ) {
return v * 2.0;
}
-var x = filledarrayBy( 10, 'float64', rand );
+var x = filledarrayBy( 10, 'float64', fill );
console.log( x );
var v = nanrangeBy( x.length, x, 1, accessor );
@@ -236,8 +240,6 @@ console.log( v );
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
-[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
-
[@stdlib/stats/strided/dnanrange]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dnanrange
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
index 3931e4e384cf..497323944104 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.js
@@ -21,13 +21,11 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var uniform = require( '@stdlib/random/base/uniform' );
-var filledarrayBy = require( '@stdlib/array/filled-by' );
-var bernoulli = require( '@stdlib/random/base/bernoulli' );
+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 pkg = require( './../package.json' ).name;
-var nanrangeBy = require( './../lib/main.js' );
+var nanrangeBy = require( './../lib/nanrange_by.js' );
// FUNCTIONS //
@@ -43,19 +41,6 @@ function accessor( value ) {
return value * 2.0;
}
-/**
-* Returns a random number.
-*
-* @private
-* @returns {number} random number
-*/
-function rand() {
- if ( bernoulli( 0.8 ) < 1 ) {
- return NaN;
- }
- return uniform( -50.0, 50.0 );
-}
-
/**
* Create a benchmark function.
*
@@ -64,7 +49,17 @@ function rand() {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, 'generic', rand );
+ var x;
+ var i;
+
+ x = [];
+ for ( i = 0; i < len; i++ ) {
+ if ( randu() < 0.2 ) {
+ x.push( NaN );
+ } else {
+ x.push( ( randu()*20.0 ) - 10.0 );
+ }
+ }
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
index cec2b32c4fa0..8b8c84d3bdb2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/benchmark/benchmark.ndarray.js
@@ -21,9 +21,7 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var uniform = require( '@stdlib/random/base/uniform' );
-var filledarrayBy = require( '@stdlib/array/filled-by' );
-var bernoulli = require( '@stdlib/random/base/bernoulli' );
+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 pkg = require( './../package.json' ).name;
@@ -43,19 +41,6 @@ function accessor( value ) {
return value * 2.0;
}
-/**
-* Returns a random number.
-*
-* @private
-* @returns {number} random number
-*/
-function rand() {
- if ( bernoulli( 0.8 ) < 1 ) {
- return NaN;
- }
- return uniform( -50.0, 50.0 );
-}
-
/**
* Create a benchmark function.
*
@@ -64,7 +49,17 @@ function rand() {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x = filledarrayBy( len, 'generic', rand );
+ var x;
+ var i;
+
+ x = [];
+ for ( i = 0; i < len; i++ ) {
+ if ( randu() < 0.2 ) {
+ x.push( NaN );
+ } else {
+ x.push( ( randu()*20.0 ) - 10.0 );
+ }
+ }
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
index 3425fd2e6bcf..306a3a977dd2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/repl.txt
@@ -1,10 +1,10 @@
-{{alias}}( N, x, strideX, clbk[, thisArg] )
- Computes the range of a strided array via a callback function, ignoring
+{{alias}}( N, x, stride, clbk[, thisArg] )
+ Calculates the range of a strided array via a callback function, ignoring
`NaN` values.
- The `N` and stride parameters determine which elements in the strided array
- are accessed at runtime.
+ The `N` and `stride` parameters determine which elements in `x` are accessed
+ at runtime.
Indexing is relative to the first index. To introduce an offset, use typed
array views.
@@ -34,8 +34,8 @@
Input array/collection. If provided an object, the object must be array-
like (excluding strings and functions).
- strideX: integer
- Stride length.
+ stride: integer
+ Index increment for `x`.
clbk: Function
Callback function.
@@ -56,24 +56,25 @@
> {{alias}}( x.length, x, 1, accessor )
18.0
- // Using `N` and stride parameters:
+ // Using `N` and `stride` parameters:
> x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0, 1.0 ];
- > {{alias}}( 4, x, 2, accessor )
+ > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
+ > {{alias}}( N, x, 2, accessor )
14.0
// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
- > {{alias}}( 3, x1, 2, accessor )
+ > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
+ > {{alias}}( N, x1, 2, accessor )
8.0
-
-{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] )
+{{alias}}.ndarray( N, x, stride, offset, clbk[, thisArg] )
Calculates the range of a strided array via a callback function, ignoring
`NaN` values and using alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the offset parameter supports indexing semantics based on a
+ buffer, the `offset` parameter supports indexing semantics based on a
starting index.
Parameters
@@ -85,11 +86,11 @@
Input array/collection. If provided an object, the object must be array-
like (excluding strings and functions).
- strideX: integer
- Stride length.
+ stride: integer
+ Index increment for `x`.
- offsetX: integer
- Starting index.
+ offset: integer
+ Starting index of `x`.
clbk: Function
Callback function.
@@ -112,7 +113,8 @@
// Using an index offset:
> x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
- > {{alias}}.ndarray( 3, x, 2, 1, accessor )
+ > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
+ > {{alias}}.ndarray( N, x, 2, 1, accessor )
8.0
See Also
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
index caa6d2312b59..502636524eb1 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/index.d.ts
@@ -20,12 +20,7 @@
///
-import { Collection, AccessorArrayLike } from '@stdlib/types/array';
-
-/**
-* Input array.
-*/
-type InputArray = Collection | AccessorArrayLike;
+import { Collection } from '@stdlib/types/array';
/**
* Returns an accessed value.
@@ -88,7 +83,7 @@ type Callback = Nullary | Unary | Binary | Ternary |
*/
interface Routine {
/**
- * Computes the range of a strided array via a callback function, ignoring `NaN` values.
+ * Calculates the range of a strided array via a callback function, ignoring `NaN` values.
*
* ## Notes
*
@@ -107,7 +102,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
- * @param strideX - stride length
+ * @param stride - stride length
* @param clbk - callback
* @param thisArg - execution context
* @returns range
@@ -122,10 +117,10 @@ interface Routine {
* var v = nanrangeBy( x.length, x, 1, accessor );
* // returns 18.0
*/
- ( N: number, x: InputArray, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
+ ( N: number, x: Collection, stride: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
/**
- * Computes the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics.
+ * Calculates the range of a strided array via a callback function, ignoring `NaN` values and using alternative indexing semantics.
*
* ## Notes
*
@@ -144,8 +139,8 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
- * @param strideX - stride length
- * @param offsetX - starting index
+ * @param stride - stride length
+ * @param offset - starting index
* @param clbk - callback
* @param thisArg - execution context
* @returns range
@@ -160,11 +155,11 @@ interface Routine {
* var v = nanrangeBy.ndarray( x.length, x, 1, 0, accessor );
* // returns 18.0
*/
- ndarray( N: number, x: InputArray, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
+ ndarray( N: number, x: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
}
/**
-* Computes the range of a strided array via a callback function, ignoring `NaN` values.
+* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
*
* ## Notes
*
@@ -183,7 +178,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
-* @param strideX - stride length
+* @param stride - stride length
* @param clbk - callback
* @param thisArg - execution context
* @returns range
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
index 309fa8677c85..076af8773ea2 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/docs/types/test.ts
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-import AccessorArray = require( '@stdlib/array/base/accessor' );
import nanrangeBy = require( './index' );
const accessor = (): number => {
@@ -31,10 +30,7 @@ const accessor = (): number => {
const x = new Float64Array( 10 );
nanrangeBy( x.length, x, 1, accessor ); // $ExpectType number
- nanrangeBy( x.length, new AccessorArray( x ), 1, accessor ); // $ExpectType number
-
nanrangeBy( x.length, x, 1, accessor, {} ); // $ExpectType number
- nanrangeBy( x.length, new AccessorArray( x ), 1, accessor, {} ); // $ExpectType number
}
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -74,7 +70,7 @@ const accessor = (): number => {
nanrangeBy( x.length, x, undefined, accessor ); // $ExpectError
nanrangeBy( x.length, x, [], accessor ); // $ExpectError
nanrangeBy( x.length, x, {}, accessor ); // $ExpectError
- nanrangeBy( x.length, x, ( x: number ): number => x, accessor ); // $ExpectError
+ nanrangeBy( x.length, x, ( x: number, accessor ): number => x, accessor ); // $ExpectError
}
// The compiler throws an error if the function is provided a fourth argument which is not a function...
@@ -106,10 +102,7 @@ const accessor = (): number => {
const x = new Float64Array( 10 );
nanrangeBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number
- nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor ); // $ExpectType number
-
nanrangeBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number
- nanrangeBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor, {} ); // $ExpectType number
}
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
index 6f2b6c34b546..8aaaf469c7a4 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/examples/index.js
@@ -18,23 +18,23 @@
'use strict';
-var uniform = require( '@stdlib/random/base/uniform' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
+var randu = require( '@stdlib/random/base/randu' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
-var bernoulli = require( '@stdlib/random/base/bernoulli' );
var nanrangeBy = require( './../lib' );
-function rand() {
- if ( bernoulli( 0.8 ) < 0.2 ) {
+function fill() {
+ if ( randu() < 0.2 ) {
return NaN;
}
- return uniform( -50.0, 50.0 );
+ return discreteUniform( -50, 50 );
}
function accessor( v ) {
return v * 2.0;
}
-var x = filledarrayBy( 10, 'float64', rand );
+var x = filledarrayBy( 10, 'float64', fill );
console.log( x );
var v = nanrangeBy( x.length, x, 1, accessor );
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js
index 3ae440117e2e..dfc81b840c2f 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/index.js
@@ -19,7 +19,7 @@
'use strict';
/**
-* Compute the range of a strided array via a callback function and ignoring `NaN` values.
+* Calculate the range of a strided array via a callback function and ignoring `NaN` values.
*
* @module @stdlib/stats/base/nanrange-by
*
@@ -50,14 +50,7 @@
// MODULES //
-var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
var main = require( './main.js' );
-var ndarray = require( './ndarray.js' );
-
-
-// MAIN //
-
-setReadOnly( main, 'ndarray', ndarray );
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
index e25596b0f392..806353376607 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/main.js
@@ -20,35 +20,14 @@
// MODULES //
-var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
+var nanrangeBy = require( './nanrange_by.js' );
var ndarray = require( './ndarray.js' );
// MAIN //
-/**
-* Computes the range of a strided array via a callback function, ignoring `NaN` values.
-*
-* @param {PositiveInteger} N - number of indexed elements
-* @param {Collection} x - input array
-* @param {integer} strideX - index increment
-* @param {Callback} clbk - callback
-* @param {*} [thisArg] - execution context
-* @returns {number} range
-*
-* @example
-* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
-*
-* function accessor( v ) {
-* return v * 2.0;
-* }
-*
-* var v = nanrangeBy( x.length, x, 1, accessor );
-* // returns 18.0
-*/
-function nanrangeBy( N, x, strideX, clbk, thisArg ) {
- return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );
-}
+setReadOnly( nanrangeBy, 'ndarray', ndarray );
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
new file mode 100644
index 000000000000..b7b9dd146f9f
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/nanrange_by.js
@@ -0,0 +1,100 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2020 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+
+
+// MAIN //
+
+/**
+* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
+*
+* @param {PositiveInteger} N - number of indexed elements
+* @param {Collection} x - input array/collection
+* @param {integer} stride - index increment
+* @param {Callback} clbk - callback
+* @param {*} [thisArg] - execution context
+* @returns {number} range
+*
+* @example
+* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
+*
+* function accessor( v ) {
+* return v * 2.0;
+* }
+*
+* var v = nanrangeBy( x.length, x, 1, accessor );
+* // returns 18.0
+*/
+function nanrangeBy( N, x, stride, clbk, thisArg ) {
+ var max;
+ var min;
+ var ix;
+ var v;
+ var i;
+
+ if ( N <= 0 ) {
+ return NaN;
+ }
+ if ( N === 1 || stride === 0 ) {
+ v = clbk.call( thisArg, x[ 0 ], 0, 0, x );
+ if ( v === void 0 || isnan( v ) ) {
+ return NaN;
+ }
+ return 0.0;
+ }
+ if ( stride < 0 ) {
+ ix = (1-N) * stride;
+ } else {
+ ix = 0;
+ }
+ for ( i = 0; i < N; i++ ) {
+ min = clbk.call( thisArg, x[ ix ], i, ix, x );
+ if ( min === min && min !== void 0 ) {
+ break;
+ }
+ ix += stride;
+ }
+ if ( i === N ) {
+ return NaN;
+ }
+ max = min;
+ i += 1;
+ for ( i; i < N; i++ ) {
+ ix += stride;
+ v = clbk.call( thisArg, x[ ix ], i, ix, x );
+ if ( v === void 0 || isnan( v ) ) {
+ continue;
+ }
+ if ( v < min ) {
+ min = v;
+ } else if ( v > max ) {
+ max = v;
+ }
+ }
+ return max - min;
+}
+
+
+// EXPORTS //
+
+module.exports = nanrangeBy;
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
index 1d517958bcd8..8d7bcbae67df 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/lib/ndarray.js
@@ -21,19 +21,17 @@
// MODULES //
var isnan = require( '@stdlib/math/base/assert/is-nan' );
-var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
-var accessors = require( './accessors.js' );
// MAIN //
/**
-* Computes the range of a strided array via a callback function, ignoring `NaN` values.
+* Calculates the range of a strided array via a callback function, ignoring `NaN` values.
*
* @param {PositiveInteger} N - number of indexed elements
-* @param {Collection} x - input array
-* @param {integer} strideX - stride length
-* @param {NonNegativeInteger} offsetX - starting index
+* @param {Collection} x - input array/collection
+* @param {integer} stride - index increment
+* @param {NonNegativeInteger} offset - starting index
* @param {Callback} clbk - callback
* @param {*} [thisArg] - execution context
* @returns {number} range
@@ -48,35 +46,30 @@ var accessors = require( './accessors.js' );
* var v = nanrangeBy( x.length, x, 1, 0, accessor );
* // returns 18.0
*/
-function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
+function nanrangeBy( N, x, stride, offset, clbk, thisArg ) {
var max;
var min;
var ix;
- var o;
var v;
var i;
if ( N <= 0 ) {
return NaN;
}
- o = arraylike2object( x );
- if ( o.accessorProtocol ) {
- return accessors( N, o, strideX, offsetX, clbk, thisArg );
- }
- if ( N === 1 || strideX === 0 ) {
- v = clbk.call( thisArg, x[ offsetX ], 0, offsetX, x );
+ if ( N === 1 || stride === 0 ) {
+ v = clbk.call( thisArg, x[ 0 ], 0, 0, x );
if ( v === void 0 || isnan( v ) ) {
return NaN;
}
return 0.0;
}
- ix = offsetX;
+ ix = offset;
for ( i = 0; i < N; i++ ) {
min = clbk.call( thisArg, x[ ix ], i, ix, x );
if ( min === min && min !== void 0 ) {
break;
}
- ix += strideX;
+ ix += stride;
}
if ( i === N ) {
return NaN;
@@ -84,7 +77,7 @@ function nanrangeBy( N, x, strideX, offsetX, clbk, thisArg ) {
max = min;
i += 1;
for ( i; i < N; i++ ) {
- ix += strideX;
+ ix += stride;
v = clbk.call( thisArg, x[ ix ], i, ix, x );
if ( v === void 0 || isnan( v ) ) {
continue;
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js
new file mode 100644
index 000000000000..ce1e4d8fe3ed
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.nanrange_by.js
@@ -0,0 +1,233 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2020 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
+var Float64Array = require( '@stdlib/array/float64' );
+var nanrangeBy = require( './../lib/nanrange_by.js' );
+
+
+// FUNCTIONS //
+
+function accessor( v ) {
+ if ( v === void 0 ) {
+ return;
+ }
+ return v * 2.0;
+}
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof nanrangeBy, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function has an arity of 5', function test( t ) {
+ t.strictEqual( nanrangeBy.length, 5, 'has expected arity' );
+ t.end();
+});
+
+tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ];
+ v = nanrangeBy( x.length, x, 1, accessor );
+ t.strictEqual( v, 18.0, 'returns expected value' );
+
+ x = [ -4.0, NaN, -5.0 ];
+ v = nanrangeBy( x.length, x, 1, accessor );
+ t.strictEqual( v, 2.0, 'returns expected value' );
+
+ x = [ -0.0, 0.0, NaN, -0.0 ];
+ v = nanrangeBy( x.length, x, 1, accessor );
+ t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );
+
+ x = [ NaN ];
+ v = nanrangeBy( x.length, x, 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = [ NaN, NaN ];
+ v = nanrangeBy( x.length, x, 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = new Array( 5 ); // sparse array
+ v = nanrangeBy( x.length, x, 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ x = new Array( 5 ); // sparse array
+ x[ 2 ] = 1.0;
+ v = nanrangeBy( x.length, x, 1, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( 0, x, 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ v = nanrangeBy( -1, x, 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( 1, x, 1, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ x = new Array( 1 ); // sparse array
+ v = nanrangeBy( 1, x, 1, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports a `stride` parameter', function test( t ) {
+ var N;
+ var x;
+ var v;
+
+ x = [
+ 1.0, // 0
+ 2.0,
+ 2.0, // 1
+ -7.0,
+ -2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 2.0,
+ NaN, // 4
+ NaN
+ ];
+
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, x, 2, accessor );
+
+ t.strictEqual( v, 12.0, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function supports a negative `stride` parameter', function test( t ) {
+ var N;
+ var x;
+ var v;
+
+ x = [
+ NaN, // 4
+ NaN,
+ 1.0, // 3
+ 2.0,
+ 2.0, // 2
+ -7.0,
+ -2.0, // 1
+ 3.0,
+ 4.0, // 0
+ 2.0
+ ];
+
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, x, -2, accessor );
+
+ t.strictEqual( v, 12.0, 'returns expected value' );
+ t.end();
+});
+
+tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = nanrangeBy( x.length, x, 0, accessor );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ x = new Array( 1 ); // sparse array
+ v = nanrangeBy( 1, x, 0, accessor );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports view offsets', function test( t ) {
+ var x0;
+ var x1;
+ var N;
+ var v;
+
+ x0 = new Float64Array([
+ 2.0,
+ 1.0, // 0
+ 2.0,
+ -2.0, // 1
+ -2.0,
+ 2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 6.0,
+ NaN, // 4
+ NaN
+ ]);
+
+ x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
+ N = floor(x1.length / 2);
+
+ v = nanrangeBy( N, x1, 2, accessor );
+ t.strictEqual( v, 12.0, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a callback execution context', function test( t ) {
+ var ctx;
+ var x;
+
+ x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ];
+ ctx = {
+ 'count': 0
+ };
+ nanrangeBy( x.length, x, 1, accessor, ctx );
+
+ t.strictEqual( ctx.count, x.length, 'returns expected value' );
+ t.end();
+
+ function accessor( v ) {
+ this.count += 1; // eslint-disable-line no-invalid-this
+ return v * 2.0;
+ }
+});
diff --git a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
index e56dff487a70..33f6c629025d 100644
--- a/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/nanrange-by/test/test.ndarray.js
@@ -21,7 +21,7 @@
// MODULES //
var tape = require( 'tape' );
-var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+var floor = require( '@stdlib/math/base/special/floor' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
var nanrangeBy = require( './../lib/ndarray.js' );
@@ -74,11 +74,11 @@ tape( 'the function calculates the range of a strided array via a callback funct
v = nanrangeBy( x.length, x, 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
+ x = new Array( 5 ); // sparse array
v = nanrangeBy( x.length, x, 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
- x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
+ x = new Array( 5 ); // sparse array
x[ 2 ] = 1.0;
v = nanrangeBy( x.length, x, 1, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
@@ -86,42 +86,6 @@ tape( 'the function calculates the range of a strided array via a callback funct
t.end();
});
-tape( 'the function calculates the range of a strided array via a callback function, ignoring NaN values (accessors)', function test( t ) {
- var x;
- var v;
-
- x = [ 1.0, -2.0, -4.0, NaN, 5.0, 0.0, NaN, 3.0 ];
- v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( v, 18.0, 'returns expected value' );
-
- x = [ -4.0, NaN, -5.0 ];
- v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( v, 2.0, 'returns expected value' );
-
- x = [ -0.0, 0.0, NaN, -0.0 ];
- v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );
-
- x = [ NaN ];
- v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( isnan( v ), true, 'returns expected value' );
-
- x = [ NaN, NaN ];
- v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( isnan( v ), true, 'returns expected value' );
-
- x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
- v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( isnan( v ), true, 'returns expected value' );
-
- x = new Array( 5 ); // eslint-disable-line stdlib/no-new-array
- x[ 2 ] = 1.0;
- v = nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( v, 0.0, 'returns expected value' );
-
- t.end();
-});
-
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN`', function test( t ) {
var x;
var v;
@@ -137,21 +101,6 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
t.end();
});
-tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
- var x;
- var v;
-
- x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
-
- v = nanrangeBy( 0, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( isnan( v ), true, 'returns expected value' );
-
- v = nanrangeBy( -1, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( isnan( v ), true, 'returns expected value' );
-
- t.end();
-});
-
tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) {
var x;
var v;
@@ -161,30 +110,15 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun
v = nanrangeBy( 1, x, 1, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
+ x = new Array( 1 ); // sparse array
v = nanrangeBy( 1, x, 1, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});
-tape( 'if provided an `N` parameter equal to `1`, the function returns `0` (accessors)', function test( t ) {
- var x;
- var v;
-
- x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
-
- v = nanrangeBy( 1, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( v, 0.0, 'returns expected value' );
-
- x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
- v = nanrangeBy( 1, toAccessorArray( x ), 1, 0, accessor );
- t.strictEqual( isnan( v ), true, 'returns expected value' );
-
- t.end();
-});
-
tape( 'the function supports a `stride` parameter', function test( t ) {
+ var N;
var x;
var v;
@@ -201,36 +135,15 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
];
- v = nanrangeBy( 5, x, 2, 0, accessor );
-
- t.strictEqual( v, 12.0, 'returns expected value' );
- t.end();
-});
-
-tape( 'the function supports a `stride` parameter (accessors)', function test( t ) {
- var x;
- var v;
-
- x = [
- 1.0, // 0
- 2.0,
- 2.0, // 1
- -7.0,
- -2.0, // 2
- 3.0,
- 4.0, // 3
- 2.0,
- NaN, // 4
- NaN
- ];
-
- v = nanrangeBy( 5, toAccessorArray( x ), 2, 0, accessor );
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, x, 2, 0, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
+ var N;
var x;
var v;
@@ -247,30 +160,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
];
- v = nanrangeBy( 5, x, -2, 8, accessor );
-
- t.strictEqual( v, 12.0, 'returns expected value' );
- t.end();
-});
-
-tape( 'the function supports a negative `stride` parameter (accessors)', function test( t ) {
- var x;
- var v;
-
- x = [
- NaN, // 4
- NaN,
- 1.0, // 3
- 2.0,
- 2.0, // 2
- -7.0,
- -2.0, // 1
- 3.0,
- 4.0, // 0
- 2.0
- ];
-
- v = nanrangeBy( 5, toAccessorArray( x ), -2, 8, accessor );
+ N = floor( x.length / 2 );
+ v = nanrangeBy( N, x, -2, 8, accessor );
t.strictEqual( v, 12.0, 'returns expected value' );
t.end();
@@ -285,29 +176,13 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
v = nanrangeBy( x.length, x, 0, 0, accessor );
t.strictEqual( v, 0.0, 'returns expected value' );
- x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
+ x = new Array( 1 ); // sparse array
v = nanrangeBy( 1, x, 0, 0, accessor );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});
-tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessors)', function test( t ) {
- var x;
- var v;
-
- x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
-
- v = nanrangeBy( x.length, toAccessorArray( x ), 0, 0, accessor );
- t.strictEqual( v, 0.0, 'returns expected value' );
-
- x = new Array( 1 ); // eslint-disable-line stdlib/no-new-array
- v = nanrangeBy( 1, toAccessorArray( x ), 0, 0, accessor );
- t.strictEqual( isnan( v ), true, 'returns expected value' );
-
- t.end();
-});
-
tape( 'the function supports an offset parameter', function test( t ) {
var x;
var v;
@@ -329,27 +204,6 @@ tape( 'the function supports an offset parameter', function test( t ) {
t.end();
});
-tape( 'the function supports an offset parameter (accessors)', function test( t ) {
- var x;
- var v;
-
- x = [
- 1.0,
- -2.0, // 0
- 3.0,
- 4.0, // 1
- 5.0,
- -6.0, // 2
- NaN,
- NaN // 3
- ];
-
- v = nanrangeBy( 4, toAccessorArray( x ), 2, 1, accessor );
- t.strictEqual( v, 20.0, 'returns expected value' );
-
- t.end();
-});
-
tape( 'the function supports providing a callback execution context', function test( t ) {
var ctx;
var x;
@@ -368,22 +222,3 @@ tape( 'the function supports providing a callback execution context', function t
return v * 2.0;
}
});
-
-tape( 'the function supports providing a callback execution context (accessors)', function test( t ) {
- var ctx;
- var x;
-
- x = [ 1.0, 2.0, 3.0, NaN, 4.0, 5.0 ];
- ctx = {
- 'count': 0
- };
- nanrangeBy( x.length, toAccessorArray( x ), 1, 0, accessor, ctx );
-
- t.strictEqual( ctx.count, x.length, 'returns expected value' );
- t.end();
-
- function accessor( v ) {
- this.count += 1; // eslint-disable-line no-invalid-this
- return v * 2.0;
- }
-});
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/drange/README.md
new file mode 100644
index 000000000000..b113d5e594d7
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/README.md
@@ -0,0 +1,116 @@
+
+
+# drange
+
+> Compute the [range][range] of a one-dimensional double-precision floating-point ndarray.
+
+
+
+The [**range**][range] is defined as the difference between the maximum and minimum values.
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var drange = require( '@stdlib/stats/base/ndarray/drange' );
+```
+
+#### drange( arrays )
+
+Computes the [range][range] of a one-dimensional double-precision floating-point ndarray.
+
+```javascript
+var Float64Array = require( '@stdlib/array/float64' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+
+var xbuf = new Float64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
+var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
+
+var v = drange( [ x ] );
+// returns 3.0
+```
+
+The function has the following parameters:
+
+- **arrays**: array-like object containing a one-dimensional input ndarray.
+
+
+
+
+
+
+
+## Notes
+
+- If provided an empty one-dimensional ndarray, the function returns `NaN`.
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var drange = require( '@stdlib/stats/base/ndarray/drange' );
+
+var xbuf = discreteUniform( 10, -50, 50, {
+ 'dtype': 'float64'
+});
+var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
+console.log( ndarray2array( x ) );
+
+var v = drange( [ x ] );
+console.log( v );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[range]: https://en.wikipedia.org/wiki/Range_%28statistics%29
+
+
+
+
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/ndarray/drange/benchmark/benchmark.js
new file mode 100644
index 000000000000..88b2461a05e3
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/benchmark/benchmark.js
@@ -0,0 +1,102 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+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 ndarray = require( '@stdlib/ndarray/base/ctor' );
+var pkg = require( './../package.json' ).name;
+var drange = require( './../lib' );
+
+
+// VARIABLES //
+
+var options = {
+ 'dtype': 'float64'
+};
+
+
+// FUNCTIONS //
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( len ) {
+ var xbuf;
+ var x;
+
+ xbuf = uniform( len, -10.0, 10.0, options );
+ x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
+
+ return benchmark;
+
+ function benchmark( b ) {
+ var v;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = drange( [ x ] );
+ if ( isnan( v ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( v ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ min = 1; // 10^min
+ max = 6; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( len );
+ bench( pkg+':len='+len, f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/repl.txt
new file mode 100644
index 000000000000..f6d7e68428bc
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/repl.txt
@@ -0,0 +1,32 @@
+
+{{alias}}( arrays )
+ Computes the range of a one-dimensional double-precision floating-point
+ ndarray.
+
+ If provided an empty ndarray, the function returns `NaN`.
+
+ Parameters
+ ----------
+ arrays: ArrayLikeObject
+ Array-like object containing a one-dimensional input ndarray.
+
+ Returns
+ -------
+ out: number
+ Range.
+
+ Examples
+ --------
+ > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] );
+ > var dt = 'float64';
+ > var sh = [ xbuf.length ];
+ > var sx = [ 1 ];
+ > var ox = 0;
+ > var ord = 'row-major';
+ > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord );
+ > {{alias}}( [ x ] )
+ 4.0
+
+ See Also
+ --------
+
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/index.d.ts
new file mode 100644
index 000000000000..5f15df5f50af
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/index.d.ts
@@ -0,0 +1,46 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+///
+
+import { float64ndarray } from '@stdlib/types/ndarray';
+
+/**
+* Computes the range of a one-dimensional double-precision floating-point ndarray.
+*
+* @param arrays - array-like object containing an input ndarray
+* @returns range
+*
+* @example
+* var Float64Array = require( '@stdlib/array/float64' );
+* var ndarray = require( '@stdlib/ndarray/base/ctor' );
+*
+* var xbuf = new Float64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
+* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
+*
+* var v = drange( [ x ] );
+* // returns 3.0
+*/
+declare function drange( arrays: [ float64ndarray ] ): number;
+
+
+// EXPORTS //
+
+export = drange;
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/test.ts
new file mode 100644
index 000000000000..db79162f0f5c
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/docs/types/test.ts
@@ -0,0 +1,57 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/* eslint-disable space-in-parens */
+
+import zeros = require( '@stdlib/ndarray/zeros' );
+import drange = require( './index' );
+
+
+// TESTS //
+
+// The function returns a number...
+{
+ const x = zeros( [ 10 ], {
+ 'dtype': 'float64'
+ });
+
+ drange( [ x ] ); // $ExpectType number
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays...
+{
+ drange( '10' ); // $ExpectError
+ drange( 10 ); // $ExpectError
+ drange( true ); // $ExpectError
+ drange( false ); // $ExpectError
+ drange( null ); // $ExpectError
+ drange( undefined ); // $ExpectError
+ drange( [] ); // $ExpectError
+ drange( {} ); // $ExpectError
+ drange( ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = zeros( [ 10 ], {
+ 'dtype': 'float64'
+ });
+
+ drange(); // $ExpectError
+ drange( [ x ], {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/examples/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/drange/examples/index.js
new file mode 100644
index 000000000000..4e0c668da739
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/examples/index.js
@@ -0,0 +1,33 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var drange = require( './../lib' );
+
+var xbuf = discreteUniform( 10, -50, 50, {
+ 'dtype': 'float64'
+});
+var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
+console.log( ndarray2array( x ) );
+
+var v = drange( [ x ] );
+console.log( v );
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/index.js
new file mode 100644
index 000000000000..0d877e359044
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/index.js
@@ -0,0 +1,45 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Compute the range of a one-dimensional double-precision floating-point ndarray.
+*
+* @module @stdlib/stats/base/ndarray/drange
+*
+* @example
+* var Float64Array = require( '@stdlib/array/float64' );
+* var ndarray = require( '@stdlib/ndarray/base/ctor' );
+* var drange = require( '@stdlib/stats/base/ndarray/drange' );
+*
+* var xbuf = new Float64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
+* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
+*
+* var v = drange( [ x ] );
+* // returns 3.0
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/main.js b/lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/main.js
new file mode 100644
index 000000000000..1993542ffbb7
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/ndarray/drange/lib/main.js
@@ -0,0 +1,56 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' );
+var getStride = require( '@stdlib/ndarray/base/stride' );
+var getOffset = require( '@stdlib/ndarray/base/offset' );
+var getData = require( '@stdlib/ndarray/base/data-buffer' );
+var strided = require( '@stdlib/stats/strided/drange' ).ndarray;
+
+
+// MAIN //
+
+/**
+* Computes the range of a one-dimensional double-precision floating-point ndarray.
+*
+* @param {ArrayLikeObject