From b6c8ddc0ebb3b5b4c4a5b5a295754fde27fbecb8 Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Sun, 2 Mar 2025 00:57:59 +0530
Subject: [PATCH 1/3] feat: reverted unwanted changes
---
.../@stdlib/stats/base/dsvariance/README.md | 170 ++++++++++++++----
.../base/dsvariance/benchmark/benchmark.js | 18 +-
.../dsvariance/benchmark/benchmark.native.js | 14 +-
.../dsvariance/benchmark/benchmark.ndarray.js | 18 +-
.../benchmark/benchmark.ndarray.native.js | 14 +-
.../dsvariance/benchmark/c/benchmark.length.c | 50 +++++-
.../stats/base/dsvariance/docs/repl.txt | 32 ++--
.../base/dsvariance/docs/types/index.d.ts | 12 +-
.../base/dsvariance/examples/c/example.c | 9 +-
.../stats/base/dsvariance/examples/index.js | 14 +-
.../include/stdlib/stats/base/dsvariance.h | 9 +-
.../stats/base/dsvariance/lib/dsvariance.js | 12 +-
.../base/dsvariance/lib/dsvariance.native.js | 9 +-
.../stats/base/dsvariance/lib/index.js | 7 +-
.../stats/base/dsvariance/lib/ndarray.js | 12 +-
.../base/dsvariance/lib/ndarray.native.js | 20 +--
.../stats/base/dsvariance/manifest.json | 51 ++++--
.../@stdlib/stats/base/dsvariance/src/addon.c | 27 ++-
.../stats/base/dsvariance/src/dsvariance.c | 34 ----
.../@stdlib/stats/base/dsvariance/src/main.c | 50 ++++++
.../base/dsvariance/test/test.dsvariance.js | 13 +-
.../dsvariance/test/test.dsvariance.native.js | 13 +-
.../base/dsvariance/test/test.ndarray.js | 13 +-
.../dsvariance/test/test.ndarray.native.js | 13 +-
24 files changed, 394 insertions(+), 240 deletions(-)
delete mode 100644 lib/node_modules/@stdlib/stats/base/dsvariance/src/dsvariance.c
create mode 100644 lib/node_modules/@stdlib/stats/base/dsvariance/src/main.c
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/README.md b/lib/node_modules/@stdlib/stats/base/dsvariance/README.md
index d57fb40a07e6..0020c60a92c8 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/README.md
@@ -98,17 +98,16 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
var dsvariance = require( '@stdlib/stats/base/dsvariance' );
```
-#### dsvariance( N, correction, x, stride )
+#### dsvariance( N, correction, x, strideX )
-Computes the [variance][variance] of a single-precision floating-point strided array `x` using extended accumulation and returning an extended precision result.
+Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
```javascript
var Float32Array = require( '@stdlib/array/float32' );
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
-var N = x.length;
-var v = dsvariance( N, 1, x, 1 );
+var v = dsvariance( x.length, 1, x, 1 );
// returns ~4.3333
```
@@ -117,18 +116,16 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
- **x**: input [`Float32Array`][@stdlib/array/float32].
-- **stride**: index increment for `x`.
+- **strideX**: stride length for `x`.
-The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`,
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`,
```javascript
var 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 ] );
-var N = floor( x.length / 2 );
-var v = dsvariance( N, 1, x, 2 );
+var v = dsvariance( 4, 1, x, 2 );
// returns 6.25
```
@@ -138,18 +135,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 ] );
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
-var N = floor( x0.length / 2 );
-
-var v = dsvariance( N, 1, x1, 2 );
+var v = dsvariance( 4, 1, x1, 2 );
// returns 6.25
```
-#### dsvariance.ndarray( N, correction, x, stride, offset )
+#### dsvariance.ndarray( N, correction, x, strideX, offsetX )
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
@@ -157,26 +151,23 @@ Computes the [variance][variance] of a single-precision floating-point strided a
var Float32Array = require( '@stdlib/array/float32' );
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
-var N = x.length;
-var v = dsvariance.ndarray( N, 1, x, 1, 0 );
+var v = dsvariance.ndarray( x.length, 1, x, 1, 0 );
// returns ~4.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 [variance][variance] for every other value in `x` starting from the second value
+While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [variance][variance] for every other element in `x` starting from the second element
```javascript
var 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 ] );
-var N = floor( x.length / 2 );
-var v = dsvariance.ndarray( N, 1, x, 2, 1 );
+var v = dsvariance.ndarray( 4, 1, x, 2, 1 );
// returns 6.25
```
@@ -190,7 +181,7 @@ var v = dsvariance.ndarray( N, 1, x, 2, 1 );
- If `N <= 0`, both functions return `NaN`.
- If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), both functions return `NaN`.
-- Accumulated intermediate values are stored as double-precision floating-point numbers.
+- Accumulated intermediate values are stored as double-precision floating-point numbers.
@@ -203,18 +194,12 @@ var v = dsvariance.ndarray( N, 1, 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 dsvariance = require( '@stdlib/stats/base/dsvariance' );
-var x;
-var i;
-
-x = new Float32Array( 10 );
-for ( i = 0; i < x.length; i++ ) {
- x[ i ] = round( (randu()*100.0) - 50.0 );
-}
+var x = discreteUniform( 10, -50, 50, {
+ 'dtype': 'float32'
+});
console.log( x );
var v = dsvariance( x.length, 1, x, 1 );
@@ -225,6 +210,127 @@ console.log( v );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/stats/base/dsvariance.h"
+```
+
+#### stdlib_strided_dsvariance( N, correction, \*X, strideX )
+
+Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
+
+```c
+const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }
+
+double v = stdlib_strided_dsvariance( 8, 1.0f, x, 1 );
+// returns 6.0
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **correction**: `[in] float` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
+- **X**: `[in] float*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+
+```c
+double stdlib_strided_dsvariance( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dsvariance_ndarray( N, correction, \*X, strideX, offsetX )
+
+Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
+
+```c
+const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }
+
+double v = stdlib_strided_dsvariance_ndarray( 4, 1.0, x, 2, 0 );
+// returns ~6.666667
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **correction**: `[in] float` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
+- **X**: `[in] float*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+
+```c
+double stdlib_strided_dsvariance_ndarray( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/stats/base/dsvariance.h"
+#include
+
+int main( void ) {
+ // Create a strided array:
+ const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
+
+ // Specify the number of elements:
+ const int N = 4;
+
+ // Specify the stride length:
+ const int strideX = 2;
+
+ // Compute the variance:
+ double v = stdlib_strided_dsvariance( N, 1.0f, x, strideX );
+
+ // Print the result:
+ printf( "sample variance: %lf\n", v );
+}
+```
+
+
+
+
+
+
+
+
+
+* * *
+
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.js
index dce496ed0008..a6e8995febf5 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/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 dsvariance = require( './../lib/dsvariance.js' );
+// VARIABLES //
+
+var options = {
+ 'dtype': 'float32'
+};
+
+
// FUNCTIONS //
/**
@@ -39,13 +45,7 @@ var dsvariance = require( './../lib/dsvariance.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float32Array( len );
- for ( i = 0; i < x.length; i++ ) {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
+ var x = uniform( len, -10.0, 10.0, options );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.native.js
index 5cef3584e7f3..0bab0ba0a57d 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/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 dsvariance = tryRequire( resolve( __dirname, './../lib/dsvariance.native.js'
var opts = {
'skip': ( dsvariance instanceof Error )
};
+var options = {
+ 'dtype': 'float32'
+};
// FUNCTIONS //
@@ -48,13 +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++ ) {
- 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/dsvariance/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.ndarray.js
index c37aeb298ca3..abeabb9de45f 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/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 dsvariance = require( './../lib/ndarray.js' );
+// VARIABLES //
+
+var options = {
+ 'dtype': 'float32'
+};
+
+
// FUNCTIONS //
/**
@@ -39,13 +45,7 @@ var dsvariance = 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++ ) {
- 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/dsvariance/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.ndarray.native.js
index 1832c89162bd..77ed4bd34226 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/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 dsvariance = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' )
var opts = {
'skip': ( dsvariance instanceof Error )
};
+var options = {
+ 'dtype': 'float32'
+};
// FUNCTIONS //
@@ -48,13 +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++ ) {
- 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/dsvariance/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/c/benchmark.length.c
index 88827fed01a2..a12021a74e76 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/benchmark/c/benchmark.length.c
@@ -94,7 +94,7 @@ static float rand_float( void ) {
* @param len array length
* @return elapsed time in seconds
*/
-static double benchmark( int iterations, int len ) {
+static double benchmark1( int iterations, int len ) {
double elapsed;
float x[ len ];
double v;
@@ -107,6 +107,7 @@ static double benchmark( int iterations, int len ) {
v = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
v = stdlib_strided_dsvariance( len, 1.0f, x, 1 );
if ( v != v ) {
printf( "should not return NaN\n" );
@@ -120,6 +121,40 @@ static double benchmark( int iterations, int len ) {
return elapsed;
}
+/**
+* Runs a benchmark.
+*
+* @param iterations number of iterations
+* @param len array length
+* @return elapsed time in seconds
+*/
+static double benchmark2( int iterations, int len ) {
+ double elapsed;
+ float x[ len ];
+ double v;
+ double t;
+ int i;
+
+ for ( i = 0; i < len; i++ ) {
+ x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
+ }
+ v = 0.0;
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
+ v = stdlib_strided_dsvariance_ndarray( len, 1.0f, x, 1, 0 );
+ if ( v != v ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( v != v ) {
+ printf( "should not return NaN\n" );
+ }
+ return elapsed;
+}
+
/**
* Main execution sequence.
*/
@@ -142,7 +177,18 @@ int main( void ) {
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:len=%d\n", NAME, len );
- elapsed = benchmark( iter, len );
+ elapsed = benchmark1( iter, len );
+ print_results( iter, elapsed );
+ printf( "ok %d benchmark finished\n", count );
+ }
+ }
+ for ( i = MIN; i <= MAX; i++ ) {
+ len = pow( 10, i );
+ iter = ITERATIONS / pow( 10, i-1 );
+ for ( j = 0; j < REPEATS; j++ ) {
+ count += 1;
+ printf( "# c::%s:ndarray:len=%d\n", NAME, len );
+ elapsed = benchmark2( iter, len );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dsvariance/docs/repl.txt
index 77cdfbeaf485..b5ef53bba68a 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/docs/repl.txt
@@ -1,10 +1,10 @@
-{{alias}}( N, correction, x, stride )
+{{alias}}( N, correction, x, strideX )
Computes the variance of a single-precision floating-point strided array
using extended accumulation and returning an extended precision result.
- 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.
@@ -31,8 +31,8 @@
x: Float32Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
Returns
-------
@@ -46,22 +46,19 @@
> {{alias}}( x.length, 1, x, 1 )
~4.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 ] );
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > var stride = 2;
- > {{alias}}( N, 1, x, stride )
+ > {{alias}}( 3, 1, x, 2 )
~4.3333
// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
> 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, 1, x1, stride )
+ > {{alias}}( 3, 1, x1, 2 )
~4.3333
-{{alias}}.ndarray( N, correction, x, stride, offset )
+
+{{alias}}.ndarray( N, correction, x, strideX, offsetX )
Computes the variance of a single-precision floating-point strided array
using extended accumulation and alternative indexing semantics and
returning an extended precision result.
@@ -90,10 +87,10 @@
x: Float32Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
- offset: integer
+ offsetX: integer
Starting index.
Returns
@@ -110,8 +107,7 @@
// Using offset parameter:
> var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > {{alias}}.ndarray( N, 1, x, 2, 1 )
+ > {{alias}}.ndarray( 3, 1, x, 2, 1 )
~4.3333
See Also
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dsvariance/docs/types/index.d.ts
index 5971cf553043..7477611e3929 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/docs/types/index.d.ts
@@ -28,7 +28,7 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
- * @param stride - stride length
+ * @param strideX - stride length
* @returns variance
*
* @example
@@ -39,7 +39,7 @@ interface Routine {
* var v = dsvariance( x.length, 1, x, 1 );
* // returns ~4.3333
*/
- ( N: number, correction: number, x: Float32Array, stride: number ): number;
+ ( N: number, correction: number, x: Float32Array, strideX: number ): number;
/**
* Computes the variance of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
@@ -47,8 +47,8 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
- * @param stride - stride length
- * @param offset - starting index
+ * @param strideX - stride length
+ * @param offsetX - starting index
* @returns variance
*
* @example
@@ -59,7 +59,7 @@ interface Routine {
* var v = dsvariance.ndarray( x.length, 1, x, 1, 0 );
* // returns ~4.3333
*/
- ndarray( N: number, correction: number, x: Float32Array, stride: number, offset: number ): number;
+ ndarray( N: number, correction: number, x: Float32Array, strideX: number, offsetX: number ): number;
}
/**
@@ -68,7 +68,7 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
-* @param stride - stride length
+* @param strideX - stride length
* @returns variance
*
* @example
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dsvariance/examples/c/example.c
index abcb07a6f8ad..7add77a36540 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/examples/c/example.c
@@ -17,21 +17,20 @@
*/
#include "stdlib/stats/base/dsvariance.h"
-#include
#include
int main( void ) {
// Create a strided array:
- float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
+ const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
// Specify the number of elements:
- int64_t N = 4;
+ const int N = 4;
// Specify the stride length:
- int64_t stride = 2;
+ const int strideX = 2;
// Compute the variance:
- double v = stdlib_strided_dsvariance( N, 1, x, stride );
+ double v = stdlib_strided_dsvariance( N, 1.0f, x, strideX );
// Print the result:
printf( "sample variance: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/examples/index.js b/lib/node_modules/@stdlib/stats/base/dsvariance/examples/index.js
index 97aed4af5429..7d8b08ea142a 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/examples/index.js
@@ -18,18 +18,12 @@
'use strict';
-var randu = require( '@stdlib/random/base/randu' );
-var round = require( '@stdlib/math/base/special/round' );
-var Float32Array = require( '@stdlib/array/float32' );
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var dsvariance = require( './../lib' );
-var x;
-var i;
-
-x = new Float32Array( 10 );
-for ( i = 0; i < x.length; i++ ) {
- x[ i ] = round( (randu()*100.0) - 50.0 );
-}
+var x = discreteUniform( 10, -50, 50, {
+ 'dtype': 'float32'
+});
console.log( x );
var v = dsvariance( x.length, 1, x, 1 );
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/include/stdlib/stats/base/dsvariance.h b/lib/node_modules/@stdlib/stats/base/dsvariance/include/stdlib/stats/base/dsvariance.h
index ca4dc2f7da95..d64c1923a361 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/include/stdlib/stats/base/dsvariance.h
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/include/stdlib/stats/base/dsvariance.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_STATS_BASE_DSVARIANCE_H
#define STDLIB_STATS_BASE_DSVARIANCE_H
-#include
+#include "stdlib/blas/base/shared.h"
/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
@@ -31,7 +31,12 @@ extern "C" {
/**
* Computes the variance of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
*/
-double stdlib_strided_dsvariance( const int64_t N, const float correction, const float *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dsvariance)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX );
+
+/**
+* Computes the variance of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
+*/
+double API_SUFFIX(stdlib_strided_dsvariance_ndarray)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.js b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.js
index 882679591185..8ef318fabdfa 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.js
@@ -20,7 +20,8 @@
// MODULES //
-var dsvariancepn = require( '@stdlib/stats/base/dsvariancepn' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -31,20 +32,19 @@ var dsvariancepn = require( '@stdlib/stats/base/dsvariancepn' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float32Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} variance
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
*
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dsvariance( N, 1, x, 1 );
+* var v = dsvariance( x.length, 1, x, 1 );
* // returns ~4.3333
*/
-function dsvariance( N, correction, x, stride ) {
- return dsvariancepn( N, correction, x, stride );
+function dsvariance( N, correction, x, strideX ) {
+ return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.native.js b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.native.js
index 323e4da19e38..4e6829e1f7c2 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/dsvariance.native.js
@@ -31,20 +31,19 @@ var addon = require( './../src/addon.node' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float32Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} variance
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
*
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dsvariance( N, 1, x, 1 );
+* var v = dsvariance( x.length, 1, x, 1 );
* // returns ~4.3333
*/
-function dsvariance( N, correction, x, stride ) {
- return addon( N, correction, x, stride );
+function dsvariance( N, correction, x, strideX ) {
+ return addon( N, correction, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/index.js b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/index.js
index ac11db7a802a..c276bfea3e67 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/index.js
@@ -28,20 +28,17 @@
* var dsvariance = require( '@stdlib/stats/base/dsvariance' );
*
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
-* var N = x.length;
*
-* var v = dsvariance( N, 1, x, 1 );
+* var v = dsvariance( x.length, 1, x, 1 );
* // returns ~4.3333
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
-* var floor = require( '@stdlib/math/base/special/floor' );
* var dsvariance = require( '@stdlib/stats/base/dsvariance' );
*
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
-* var N = floor( x.length / 2 );
*
-* var v = dsvariance.ndarray( N, 1, x, 2, 1 );
+* var v = dsvariance.ndarray( 4, 1, x, 2, 1 );
* // returns 6.25
*/
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.js
index 310abc7a02dc..a3756ea7d845 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.js
@@ -31,22 +31,20 @@ var dsvariancepn = require( '@stdlib/stats/base/dsvariancepn' ).ndarray;
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float32Array} x - input array
-* @param {integer} stride - stride length
-* @param {NonNegativeInteger} offset - starting index
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} variance
*
* @example
* var 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 ] );
-* var N = floor( x.length / 2 );
*
-* var v = dsvariance( N, 1, x, 2, 1 );
+* var v = dsvariance( 4, 1, x, 2, 1 );
* // returns 6.25
*/
-function dsvariance( N, correction, x, stride, offset ) {
- return dsvariancepn( N, correction, x, stride, offset );
+function dsvariance( N, correction, x, strideX, offsetX ) {
+ return dsvariancepn( N, correction, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.native.js
index 029fde100d0b..95cb5e48c292 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/lib/ndarray.native.js
@@ -20,8 +20,7 @@
// MODULES //
-var Float32Array = require( '@stdlib/array/float32' );
-var addon = require( './dsvariance.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,27 +31,20 @@ var addon = require( './dsvariance.native.js' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float32Array} x - input array
-* @param {integer} stride - stride length
-* @param {NonNegativeInteger} offset - starting index
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} variance
*
* @example
* var 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 ] );
-* var N = floor( x.length / 2 );
*
-* var v = dsvariance( N, 1, x, 2, 1 );
+* var v = dsvariance( 4, 1, x, 2, 1 );
* // returns 6.25
*/
-function dsvariance( N, correction, x, stride, offset ) {
- var view;
- if ( stride < 0 ) {
- offset += (N-1) * stride;
- }
- view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len
- return addon( N, correction, view, stride );
+function dsvariance( N, correction, x, strideX, offsetX ) {
+ return addon.ndarray( N, correction, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json b/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json
index 6dc01d847a7c..c7e43ac315cc 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json
@@ -1,5 +1,8 @@
{
- "options": {},
+ "options": {
+ "task": "build",
+ "wasm": false
+ },
"fields": [
{
"field": "src",
@@ -25,18 +28,19 @@
"confs": [
{
"task": "build",
+ "wasm": false,
"src": [
- "./src/dsvariance.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/stats/base/dsvariancepn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
@@ -47,34 +51,53 @@
},
{
"task": "benchmark",
+ "wasm": false,
"src": [
- "./src/dsvariance.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
- "@stdlib/stats/base/dsvariancepn"
+ "@stdlib/stats/base/dsvariancepn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
},
{
"task": "examples",
+ "wasm": false,
"src": [
- "./src/dsvariance.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
+ "libraries": [],
+ "libpath": [],
+ "dependencies": [
+ "@stdlib/stats/base/dsvariancepn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
+ },
+ {
+ "task": "",
+ "wasm": true,
+ "src": [
+ "./src/main.c"
+ ],
+ "include": [
+ "./include"
],
+ "libraries": [],
"libpath": [],
"dependencies": [
- "@stdlib/stats/base/dsvariancepn"
+ "@stdlib/stats/base/dsvariancepn",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
]
}
]
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/src/addon.c b/lib/node_modules/@stdlib/stats/base/dsvariance/src/addon.c
index ffd0ab29bdcd..1ccc7538f6b8 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/src/addon.c
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/src/addon.c
@@ -17,6 +17,7 @@
*/
#include "stdlib/stats/base/dsvariance.h"
+#include "stdlib/blas/base/shared.h"
#include "stdlib/napi/export.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_int64.h"
@@ -36,10 +37,28 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
STDLIB_NAPI_ARGV_FLOAT( env, correction, argv, 1 );
- STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
- STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 2 );
- STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dsvariance( N, correction, X, stride ), v );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dsvariance)( N, correction, X, strideX ), v );
return v;
}
-STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
+/**
+* Receives JavaScript callback invocation data.
+*
+* @param env environment under which the function is invoked
+* @param info callback data
+* @return Node-API value
+*/
+static napi_value addon_method( napi_env env, napi_callback_info info ) {
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 5 );
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
+ STDLIB_NAPI_ARGV_FLOAT( env, correction, argv, 1 );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dsvariance_ndarray)( N, correction, X, strideX, offsetX ), v );
+ return v;
+}
+
+STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/src/dsvariance.c b/lib/node_modules/@stdlib/stats/base/dsvariance/src/dsvariance.c
deleted file mode 100644
index 7e1165d8efae..000000000000
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/src/dsvariance.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
-* @license Apache-2.0
-*
-* Copyright (c) 2020 The Stdlib Authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "stdlib/stats/base/dsvariance.h"
-#include "stdlib/stats/base/dsvariancepn.h"
-#include
-
-/**
-* Computes the variance of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
-*
-* @param N number of indexed elements
-* @param correction degrees of freedom adjustment
-* @param X input array
-* @param stride stride length
-* @return output value
-*/
-double stdlib_strided_dsvariance( const int64_t N, const float correction, const float *X, const int64_t stride ) {
- return stdlib_strided_dsvariancepn( N, correction, X, stride );
-}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/src/main.c b/lib/node_modules/@stdlib/stats/base/dsvariance/src/main.c
new file mode 100644
index 000000000000..b7083e45dca7
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/src/main.c
@@ -0,0 +1,50 @@
+/**
+* @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.
+*/
+
+#include "stdlib/stats/base/dsvariance.h"
+#include "stdlib/stats/base/dsvariancepn.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
+
+/**
+* Computes the variance of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
+*
+* @param N number of indexed elements
+* @param correction degrees of freedom adjustment
+* @param X input array
+* @param strideX stride length
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dsvariance)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX ) {
+ const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dsvariance_ndarray)( N, correction, X, strideX, ox );
+}
+
+/**
+* Computes the variance of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
+*
+* @param N number of indexed elements
+* @param correction degrees of freedom adjustment
+* @param X input array
+* @param strideX stride length
+* @param offsetX starting index for X
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dsvariance_ndarray)( const CBLAS_INT N, const float correction, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
+ return API_SUFFIX(stdlib_strided_dsvariancepn_ndarray)( N, correction, X, strideX, offsetX );
+}
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.js b/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.js
index b0f2bc9ed87c..3ae563e2a3b8 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.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 dsvariance = require( './../lib/dsvariance.js' );
@@ -121,7 +120,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -136,15 +134,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, 2 );
+ v = dsvariance( 4, 1, x, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -159,8 +155,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, -2 );
+ v = dsvariance( 4, 1, x, -2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
@@ -181,7 +176,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float32Array([
@@ -197,9 +191,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 = dsvariance( N, 1, x1, 2 );
+ v = dsvariance( 4, 1, x1, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.native.js b/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.native.js
index 260880acaabc..186588d54210 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.dsvariance.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' );
@@ -130,7 +129,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -145,15 +143,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, 2 );
+ v = dsvariance( 4, 1, x, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -168,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, -2 );
+ v = dsvariance( 4, 1, x, -2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
@@ -190,7 +185,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
tape( 'the function supports view offsets', opts, function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float32Array([
@@ -206,9 +200,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 = dsvariance( N, 1, x1, 2 );
+ v = dsvariance( 4, 1, x1, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.ndarray.js
index b5ac8e7d7942..1a7817430a13 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/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 dsvariance = require( './../lib/ndarray.js' );
@@ -121,7 +120,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -136,15 +134,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, 2, 0 );
+ v = dsvariance( 4, 1, x, 2, 0 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -159,8 +155,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, -2, 6 );
+ v = dsvariance( 4, 1, x, -2, 6 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
@@ -179,7 +174,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
});
tape( 'the function supports an `offset` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -193,9 +187,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) {
3.0,
4.0 // 3
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, 2, 1 );
+ v = dsvariance( 4, 1, x, 2, 1 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.ndarray.native.js
index b4b67078a666..06ba8a4bc744 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/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' );
@@ -130,7 +129,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -145,15 +143,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, 2, 0 );
+ v = dsvariance( 4, 1, x, 2, 0 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -168,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
2.0
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, -2, 6 );
+ v = dsvariance( 4, 1, x, -2, 6 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
@@ -188,7 +183,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
});
tape( 'the function supports an `offset` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -202,9 +196,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) {
3.0,
4.0 // 3
]);
- N = floor( x.length / 2 );
- v = dsvariance( N, 1, x, 2, 1 );
+ v = dsvariance( 4, 1, x, 2, 1 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
From 6f36263afe3772434dcebf55f2b939e3c63978bb Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Sun, 2 Mar 2025 01:00:25 +0530
Subject: [PATCH 2/3] feat: add C ndarray interface and refactor implementation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: na
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
---
---
lib/node_modules/@stdlib/stats/base/dsvariance/README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/README.md b/lib/node_modules/@stdlib/stats/base/dsvariance/README.md
index 0020c60a92c8..102632c9f672 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/README.md
@@ -263,9 +263,9 @@ double stdlib_strided_dsvariance( const CBLAS_INT N, const float correction, con
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
```c
-const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }
+const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }
-double v = stdlib_strided_dsvariance_ndarray( 4, 1.0, x, 2, 0 );
+double v = stdlib_strided_dsvariance_ndarray( 4, 1.0f, x, 2, 0 );
// returns ~6.666667
```
From 9999a509fc5a1900a9ecaca4fe043faff17165ba Mon Sep 17 00:00:00 2001
From: JoyBoy <144602492+0PrashantYadav0@users.noreply.github.com>
Date: Fri, 14 Mar 2025 17:00:32 +0530
Subject: [PATCH 3/3] chore: minor changes
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: na
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
---
lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json b/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json
index c7e43ac315cc..6fb1a07aba20 100644
--- a/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json
+++ b/lib/node_modules/@stdlib/stats/base/dsvariance/manifest.json
@@ -84,7 +84,7 @@
]
},
{
- "task": "",
+ "task": "build",
"wasm": true,
"src": [
"./src/main.c"