Skip to content

Commit fc55f39

Browse files
committed
Auto-generated commit
1 parent b6cbd6e commit fc55f39

30 files changed

+425
-258
lines changed

CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-12-27)
7+
## Unreleased (2025-01-08)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`4fae05a`](https://github.com/stdlib-js/stdlib/commit/4fae05a8a8d1851c1619b58d1b262fd903cec395) - add C ndarray interface and refactor implementation for `stats/base/dstdevtk` [(#4621)](https://github.com/stdlib-js/stdlib/pull/4621)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

15-
- [`f03f6b7`](https://github.com/stdlib-js/stdlib/commit/f03f6b79ceb1324b6e17099163167ea56fb9695d) - **refactor:** update `stats/base/dstdevtk` native addon from C++ to C [(#4273)](https://github.com/stdlib-js/stdlib/pull/4273) _(by Vivek maurya)_
25+
- [`4fae05a`](https://github.com/stdlib-js/stdlib/commit/4fae05a8a8d1851c1619b58d1b262fd903cec395) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dstdevtk` [(#4621)](https://github.com/stdlib-js/stdlib/pull/4621) _(by Aayush Khanna, Athan Reines)_
26+
- [`f03f6b7`](https://github.com/stdlib-js/stdlib/commit/f03f6b79ceb1324b6e17099163167ea56fb9695d) - **refactor:** update `stats/base/dstdevtk` native addon from C++ to C [(#4273)](https://github.com/stdlib-js/stdlib/pull/4273) _(by Vivek Maurya)_
1627
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
1728
- [`9e689ff`](https://github.com/stdlib-js/stdlib/commit/9e689ffcb7c6223afc521f1e574b42f10921cf5e) - **chore:** fix indentation in manifest.json files _(by Philipp Burckhardt)_
1829
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
@@ -28,11 +39,12 @@
2839

2940
### Contributors
3041

31-
A total of 3 people contributed to this release. Thank you to the following contributors:
42+
A total of 4 people contributed to this release. Thank you to the following contributors:
3243

44+
- Aayush Khanna
3345
- Athan Reines
3446
- Philipp Burckhardt
35-
- Vivek maurya
47+
- Vivek Maurya
3648

3749
</section>
3850

CONTRIBUTORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Daniel Killenberger <daniel.killenberger@gmail.com>
2727
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
2828
Debashis Maharana <debashismaharana7854@gmail.com>
2929
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
30+
Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
3031
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
3132
Dominic Lim <46486515+domlimm@users.noreply.github.com>
3233
Dominik Moritz <domoritz@gmail.com>
@@ -117,7 +118,7 @@ UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
117118
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
118119
Varad Gupta <varadgupta21@gmail.com>
119120
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
120-
Vivek maurya <155618190+vivekmaurya001@users.noreply.github.com>
121+
Vivek Maurya <vm8118134@gmail.com>
121122
Xiaochuan Ye <tap91624@gmail.com>
122123
Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
123124
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copyright (c) 2016-2024 The Stdlib Authors.
1+
Copyright (c) 2016-2025 The Stdlib Authors.

README.md

Lines changed: 136 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,16 @@ To view installation and usage instructions specific to each branch build, be su
131131
var dstdevtk = require( '@stdlib/stats-base-dstdevtk' );
132132
```
133133

134-
#### dstdevtk( N, correction, x, stride )
134+
#### dstdevtk( N, correction, x, strideX )
135135

136136
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array `x` using a one-pass textbook algorithm.
137137

138138
```javascript
139139
var Float64Array = require( '@stdlib/array-float64' );
140140

141141
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
142-
var N = x.length;
143142

144-
var v = dstdevtk( N, 1, x, 1 );
143+
var v = dstdevtk( x.length, 1.0, x, 1 );
145144
// returns ~2.0817
146145
```
147146

@@ -150,18 +149,16 @@ The function has the following parameters:
150149
- **N**: number of indexed elements.
151150
- **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 [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] 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 corrected sample [standard deviation][standard-deviation], 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).
152151
- **x**: input [`Float64Array`][@stdlib/array/float64].
153-
- **stride**: index increment for `x`.
152+
- **strideX**: stride length for `x`.
154153

155-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
154+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
156155

157156
```javascript
158157
var Float64Array = require( '@stdlib/array-float64' );
159-
var floor = require( '@stdlib/math-base-special-floor' );
160158

161159
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
162-
var N = floor( x.length / 2 );
163160

164-
var v = dstdevtk( N, 1, x, 2 );
161+
var v = dstdevtk( 4, 1.0, x, 2 );
165162
// returns 2.5
166163
```
167164

@@ -171,45 +168,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
171168

172169
```javascript
173170
var Float64Array = require( '@stdlib/array-float64' );
174-
var floor = require( '@stdlib/math-base-special-floor' );
175171

176172
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
177173
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
178174

179-
var N = floor( x0.length / 2 );
180-
181-
var v = dstdevtk( N, 1, x1, 2 );
175+
var v = dstdevtk( 4, 1.0, x1, 2 );
182176
// returns 2.5
183177
```
184178

185-
#### dstdevtk.ndarray( N, correction, x, stride, offset )
179+
#### dstdevtk.ndarray( N, correction, x, strideX, offsetX )
186180

187181
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using a one-pass textbook algorithm and alternative indexing semantics.
188182

189183
```javascript
190184
var Float64Array = require( '@stdlib/array-float64' );
191185

192186
var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
193-
var N = x.length;
194187

195-
var v = dstdevtk.ndarray( N, 1, x, 1, 0 );
188+
var v = dstdevtk.ndarray( x.length, 1.0, x, 1, 0 );
196189
// returns ~2.0817
197190
```
198191

199192
The function has the following additional parameters:
200193

201-
- **offset**: starting index for `x`.
194+
- **offsetX**: starting index for `x`.
202195

203-
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 [standard deviation][standard-deviation] for every other value in `x` starting from the second value
196+
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 [standard deviation][standard-deviation] for every other element in `x` starting from the second element
204197

205198
```javascript
206199
var Float64Array = require( '@stdlib/array-float64' );
207-
var floor = require( '@stdlib/math-base-special-floor' );
208200

209201
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
210-
var N = floor( x.length / 2 );
211202

212-
var v = dstdevtk.ndarray( N, 1, x, 2, 1 );
203+
var v = dstdevtk.ndarray( 4, 1.0, x, 2, 1 );
213204
// returns 2.5
214205
```
215206

@@ -236,28 +227,141 @@ var v = dstdevtk.ndarray( N, 1, x, 2, 1 );
236227
<!-- eslint no-undef: "error" -->
237228

238229
```javascript
239-
var randu = require( '@stdlib/random-base-randu' );
240-
var round = require( '@stdlib/math-base-special-round' );
241-
var Float64Array = require( '@stdlib/array-float64' );
230+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
242231
var dstdevtk = require( '@stdlib/stats-base-dstdevtk' );
243232

244-
var x;
245-
var i;
246-
247-
x = new Float64Array( 10 );
248-
for ( i = 0; i < x.length; i++ ) {
249-
x[ i ] = round( (randu()*100.0) - 50.0 );
250-
}
233+
var x = discreteUniform( 10, -50, 50, {
234+
'dtype': 'float64'
235+
});
251236
console.log( x );
252237

253-
var v = dstdevtk( x.length, 1, x, 1 );
238+
var v = dstdevtk( x.length, 1.0, x, 1 );
254239
console.log( v );
255240
```
256241

257242
</section>
258243

259244
<!-- /.examples -->
260245

246+
<!-- C interface documentation. -->
247+
248+
* * *
249+
250+
<section class="c">
251+
252+
## C APIs
253+
254+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
255+
256+
<section class="intro">
257+
258+
</section>
259+
260+
<!-- /.intro -->
261+
262+
<!-- C usage documentation. -->
263+
264+
<section class="usage">
265+
266+
### Usage
267+
268+
```c
269+
#include "stdlib/stats/base/dstdevtk.h"
270+
```
271+
272+
#### stdlib_strided_dstdevtk( N, correction, \*X, strideX )
273+
274+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using a one-pass textbook algorithm.
275+
276+
```c
277+
const double x[] = { 1.0, -2.0, 2.0 };
278+
279+
double v = stdlib_strided_dstdevtk( 3, 1.0, x, 1 );
280+
// returns ~2.0817
281+
```
282+
283+
The function accepts the following arguments:
284+
285+
- **N**: `[in] CBLAS_INT` number of indexed elements.
286+
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] 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 corrected sample [standard deviation][standard-deviation], 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).
287+
- **X**: `[in] double*` input array.
288+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
289+
290+
```c
291+
double stdlib_strided_dstdevtk( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX );
292+
```
293+
294+
#### stdlib_strided_dstdevtk_ndarray( N, correction, \*X, strideX, offsetX )
295+
296+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array using a one-pass textbook algorithm and alternative indexing semantics.
297+
298+
```c
299+
const double x[] = { 1.0, -2.0, 2.0 };
300+
301+
double v = stdlib_strided_dstdevtk_ndarray( 3, 1.0, x, 1, 0 );
302+
// returns ~2.0817
303+
```
304+
305+
The function accepts the following arguments:
306+
307+
- **N**: `[in] CBLAS_INT` number of indexed elements.
308+
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] 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 corrected sample [standard deviation][standard-deviation], 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).
309+
- **X**: `[in] double*` input array.
310+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
311+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
312+
313+
```c
314+
double stdlib_strided_dstdevtk_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
315+
```
316+
317+
</section>
318+
319+
<!-- /.usage -->
320+
321+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
322+
323+
<section class="notes">
324+
325+
</section>
326+
327+
<!-- /.notes -->
328+
329+
<!-- C API usage examples. -->
330+
331+
<section class="examples">
332+
333+
### Examples
334+
335+
```c
336+
#include "stdlib/stats/base/dstdevtk.h"
337+
#include <stdio.h>
338+
339+
int main( void ) {
340+
// Create a strided array:
341+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
342+
343+
// Specify the number of elements:
344+
const int N = 4;
345+
346+
// Specify the stride length:
347+
const int strideX = 2;
348+
349+
// Compute the variance:
350+
double v = stdlib_strided_dstdevtk( N, 1.0, x, strideX );
351+
352+
// Print the result:
353+
printf( "sample standard deviation: %lf\n", v );
354+
}
355+
```
356+
357+
</section>
358+
359+
<!-- /.examples -->
360+
361+
</section>
362+
363+
<!-- /.c -->
364+
261365
* * *
262366
263367
<section class="references">
@@ -314,7 +418,7 @@ See [LICENSE][stdlib-license].
314418
315419
## Copyright
316420
317-
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
421+
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
318422
319423
</section>
320424

benchmark/benchmark.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-array-uniform' );
2525
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2626
var pow = require( '@stdlib/math-base-special-pow' );
27-
var Float64Array = require( '@stdlib/array-float64' );
2827
var pkg = require( './../package.json' ).name;
2928
var dstdevtk = require( './../lib/dstdevtk.js' );
3029

3130

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'float64'
35+
};
36+
37+
3238
// FUNCTIONS //
3339

3440
/**
@@ -39,13 +45,7 @@ var dstdevtk = require( './../lib/dstdevtk.js' );
3945
* @returns {Function} benchmark function
4046
*/
4147
function createBenchmark( len ) {
42-
var x;
43-
var i;
44-
45-
x = new Float64Array( len );
46-
for ( i = 0; i < x.length; i++ ) {
47-
x[ i ] = ( randu()*20.0 ) - 10.0;
48-
}
48+
var x = uniform( len, -10.0, 10.0, options );
4949
return benchmark;
5050

5151
function benchmark( b ) {

benchmark/benchmark.native.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
25-
var randu = require( '@stdlib/random-base-randu' );
25+
var uniform = require( '@stdlib/random-array-uniform' );
2626
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2727
var pow = require( '@stdlib/math-base-special-pow' );
28-
var Float64Array = require( '@stdlib/array-float64' );
2928
var tryRequire = require( '@stdlib/utils-try-require' );
3029
var pkg = require( './../package.json' ).name;
3130

@@ -36,6 +35,9 @@ var dstdevtk = tryRequire( resolve( __dirname, './../lib/dstdevtk.native.js' ) )
3635
var opts = {
3736
'skip': ( dstdevtk instanceof Error )
3837
};
38+
var options = {
39+
'dtype': 'float64'
40+
};
3941

4042

4143
// FUNCTIONS //
@@ -48,13 +50,7 @@ var opts = {
4850
* @returns {Function} benchmark function
4951
*/
5052
function createBenchmark( len ) {
51-
var x;
52-
var i;
53-
54-
x = new Float64Array( len );
55-
for ( i = 0; i < x.length; i++ ) {
56-
x[ i ] = ( randu()*20.0 ) - 10.0;
57-
}
53+
var x = uniform( len, -10.0, 10.0, options );
5854
return benchmark;
5955

6056
function benchmark( b ) {

0 commit comments

Comments
 (0)