Skip to content

Commit c6bf532

Browse files
committed
Auto-generated commit
1 parent b7c34ae commit c6bf532

32 files changed

+545
-386
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ indent_style = tab
8686
[*.{f,f.txt}]
8787
indent_style = space
8888
indent_size = 2
89-
insert_final_newline = false
9089

9190
# Set properties for shell files:
9291
[*.{sh,sh.txt}]

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

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

7-
## Unreleased (2024-12-30)
7+
## Unreleased (2025-02-14)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`f70e622`](https://github.com/stdlib-js/stdlib/commit/f70e6223dfc766d41092bc0039379c94f3b34681) - add C `ndarray` interface and refactor implementation for `stats/base/dsnanmeanors` [(#4397)](https://github.com/stdlib-js/stdlib/pull/4397)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`f70e622`](https://github.com/stdlib-js/stdlib/commit/f70e6223dfc766d41092bc0039379c94f3b34681) - **feat:** add C `ndarray` interface and refactor implementation for `stats/base/dsnanmeanors` [(#4397)](https://github.com/stdlib-js/stdlib/pull/4397) _(by Neeraj Pathak, Aayush Khanna)_
26+
- [`ab0e174`](https://github.com/stdlib-js/stdlib/commit/ab0e1746d6647e725fb2126e6fe78d1892970b6d) - **refactor:** update `stats/base/dsnanmeanors` native addon from C++ to C [(#4865)](https://github.com/stdlib-js/stdlib/pull/4865) _(by Prashant Kumar Yadav)_
1527
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
1628
- [`9e689ff`](https://github.com/stdlib-js/stdlib/commit/9e689ffcb7c6223afc521f1e574b42f10921cf5e) - **chore:** fix indentation in manifest.json files _(by Philipp Burckhardt)_
1729
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
@@ -27,10 +39,13 @@
2739

2840
### Contributors
2941

30-
A total of 2 people contributed to this release. Thank you to the following contributors:
42+
A total of 5 people contributed to this release. Thank you to the following contributors:
3143

44+
- Aayush Khanna
3245
- Athan Reines
46+
- Neeraj Pathak
3347
- Philipp Burckhardt
48+
- Prashant Kumar Yadav
3449

3550
</section>
3651

CONTRIBUTORS

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@ Daniel Killenberger <[email protected]>
2727
Daniel Yu <[email protected]>
2828
Debashis Maharana <[email protected]>
2929
Desh Deepak Kant <[email protected]>
30+
31+
Dhruv Arvind Singh <[email protected]>
3032
Divyansh Seth <[email protected]>
3133
Dominic Lim <[email protected]>
3234
Dominik Moritz <[email protected]>
3335
Dorrin Sotoudeh <[email protected]>
3436
EuniceSim142 <[email protected]>
3537
Frank Kovacs <[email protected]>
38+
GK Bishnoi <[email protected]>
39+
3640
Golden Kumar <[email protected]>
3741
Gunj Joshi <[email protected]>
38-
Gururaj Gurram <[email protected]>
42+
Gururaj Gurram <[email protected]>
43+
3944
4045
Harshita Kalani <[email protected]>
4146
Hridyanshu <[email protected]>
@@ -49,6 +54,7 @@ Joey Reed <[email protected]>
4954
Jordan Gallivan <[email protected]>
5055
Joris Labie <[email protected]>
5156
Justin Dennison <[email protected]>
57+
Karan Anand <[email protected]>
5258
Karthik Prakash <[email protected]>
5359
Kohantika Nath <[email protected]>
5460
Krishnendu Das <[email protected]>
@@ -60,6 +66,7 @@ Marcus Fantham <[email protected]>
6066
Matt Cochrane <[email protected]>
6167
Mihir Pandit <[email protected]>
6268
Milan Raj <[email protected]>
69+
Mohammad Bin Aftab <[email protected]>
6370
Mohammad Kaif <[email protected]>
6471
Momtchil Momtchev <[email protected]>
6572
Muhammad Haris <[email protected]>
@@ -117,10 +124,12 @@ UtkershBasnet <[email protected]>
117124
Vaibhav Patel <[email protected]>
118125
Varad Gupta <[email protected]>
119126
Vinit Pandit <[email protected]>
120-
Vivek maurya <[email protected].com>
127+
Vivek Maurya <vm8118134@gmail.com>
121128
Xiaochuan Ye <[email protected]>
122129
Yaswanth Kosuru <[email protected]>
123130
Yernar Yergaziyev <[email protected]>
131+
ekambains <[email protected]>
124132
olenkabilonizhka <[email protected]>
133+
pranav-1720 <[email protected]>
125134
126135

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: 137 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,84 +84,79 @@ To view installation and usage instructions specific to each branch build, be su
8484
var dsnanmeanors = require( '@stdlib/stats-base-dsnanmeanors' );
8585
```
8686

87-
#### dsnanmeanors( N, x, stride )
87+
#### dsnanmeanors( N, x, strideX )
8888

8989
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x`, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.
9090

9191
```javascript
9292
var Float32Array = require( '@stdlib/array-float32' );
9393

9494
var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
95-
var N = x.length;
9695

97-
var v = dsnanmeanors( N, x, 1 );
96+
var v = dsnanmeanors( x.length, x, 1 );
9897
// returns ~0.3333
9998
```
10099

101100
The function has the following parameters:
102101

103102
- **N**: number of indexed elements.
104103
- **x**: input [`Float32Array`][@stdlib/array/float32].
105-
- **stride**: index increment for `x`.
104+
- **strideX**: stride length for `x`.
105+
106+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
106107

107-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
108+
<!-- eslint-disable max-len -->
108109

109110
```javascript
110111
var Float32Array = require( '@stdlib/array-float32' );
111-
var floor = require( '@stdlib/math-base-special-floor' );
112112

113-
var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
114-
var N = floor( x.length / 2 );
113+
var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ] );
115114

116-
var v = dsnanmeanors( N, x, 2 );
115+
var v = dsnanmeanors( 5, x, 2 );
117116
// returns 1.25
118117
```
119118

120119
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
121120

122-
<!-- eslint-disable stdlib/capitalized-comments -->
121+
<!-- eslint-disable stdlib/capitalized-comments, max-len -->
123122

124123
```javascript
125124
var Float32Array = require( '@stdlib/array-float32' );
126-
var floor = require( '@stdlib/math-base-special-floor' );
127125

128-
var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
126+
var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
129127
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
130128

131-
var N = floor( x0.length / 2 );
132-
133-
var v = dsnanmeanors( N, x1, 2 );
129+
var v = dsnanmeanors( 5, x1, 2 );
134130
// returns 1.25
135131
```
136132

137-
#### dsnanmeanors.ndarray( N, x, stride, offset )
133+
#### dsnanmeanors.ndarray( N, x, strideX, offsetX )
138134

139135
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics.
140136

141137
```javascript
142138
var Float32Array = require( '@stdlib/array-float32' );
143139

144140
var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] );
145-
var N = x.length;
146141

147-
var v = dsnanmeanors.ndarray( N, x, 1, 0 );
142+
var v = dsnanmeanors.ndarray( x.length, x, 1, 0 );
148143
// returns ~0.33333
149144
```
150145

151146
The function has the following additional parameters:
152147

153-
- **offset**: starting index for `x`.
148+
- **offsetX**: starting index for `x`.
154149

155-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value
150+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other elemnent in `x` starting from the second elemnent
151+
152+
<!-- eslint-disable max-len -->
156153

157154
```javascript
158155
var Float32Array = require( '@stdlib/array-float32' );
159-
var floor = require( '@stdlib/math-base-special-floor' );
160156

161-
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
162-
var N = floor( x.length / 2 );
157+
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
163158

164-
var v = dsnanmeanors.ndarray( N, x, 2, 1 );
159+
var v = dsnanmeanors.ndarray( 5, x, 2, 1 );
165160
// returns 1.25
166161
```
167162

@@ -215,6 +210,123 @@ console.log( v );
215210

216211
<!-- /.examples -->
217212

213+
<!-- C interface documentation. -->
214+
215+
* * *
216+
217+
<section class="c">
218+
219+
## C APIs
220+
221+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
222+
223+
<section class="intro">
224+
225+
</section>
226+
227+
<!-- /.intro -->
228+
229+
<!-- C usage documentation. -->
230+
231+
<section class="usage">
232+
233+
### Usage
234+
235+
```c
236+
#include "stdlib/stats/base/dsnanmeanors.h"
237+
```
238+
239+
#### stdlib_strided_dsnanmeanors( N, \*X, strideX )
240+
241+
Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics.
242+
243+
```c
244+
const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f };
245+
246+
double v = stdlib_strided_dsnanmeanors( 6, x, 2 );
247+
// returns ~4.6667
248+
```
249+
250+
The function accepts the following arguments:
251+
252+
- **N**: `[in] CBLAS_INT` number of indexed elements.
253+
- **X**: `[in] float*` input array.
254+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
255+
256+
```c
257+
double stdlib_strided_dsnanmeanors( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
258+
```
259+
260+
#### stdlib_strided_dsnanmeanors_ndarray( N, \*X, strideX, offsetX )
261+
262+
Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics.
263+
264+
```c
265+
const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f };
266+
267+
double v = stdlib_strided_dsnanmeanors_ndarray( 6, x, 2, 0 );
268+
// returns ~4.6667
269+
```
270+
271+
The function accepts the following arguments:
272+
273+
- **N**: `[in] CBLAS_INT` number of indexed elements.
274+
- **X**: `[in] float*` input array.
275+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
276+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
277+
278+
```c
279+
double stdlib_strided_dsnanmeanors_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
280+
```
281+
282+
</section>
283+
284+
<!-- /.usage -->
285+
286+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
287+
288+
<section class="notes">
289+
290+
</section>
291+
292+
<!-- /.notes -->
293+
294+
<!-- C API usage examples. -->
295+
296+
<section class="examples">
297+
298+
### Examples
299+
300+
```c
301+
#include "stdlib/stats/base/dsnanmeanors.h"
302+
#include <stdio.h>
303+
304+
int main( void ) {
305+
// Create a strided array:
306+
const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f };
307+
308+
// Specify the number of elements:
309+
const int N = 6;
310+
311+
// Specify the stride length:
312+
const int strideX = 2;
313+
314+
// Compute the arithmetic mean:
315+
double v = stdlib_strided_dsnanmeanors( N, x, strideX );
316+
317+
// Print the result:
318+
printf( "mean: %f\n", v );
319+
}
320+
```
321+
322+
</section>
323+
324+
<!-- /.examples -->
325+
326+
</section>
327+
328+
<!-- /.c -->
329+
218330
<section class="references">
219331
220332
</section>
@@ -266,7 +378,7 @@ See [LICENSE][stdlib-license].
266378
267379
## Copyright
268380
269-
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
381+
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
270382
271383
</section>
272384

benchmark/benchmark.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,30 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-base-uniform' );
25+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array-filled-by' );
2527
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2628
var pow = require( '@stdlib/math-base-special-pow' );
27-
var Float32Array = require( '@stdlib/array-float32' );
2829
var pkg = require( './../package.json' ).name;
2930
var dsnanmeanors = require( './../lib/dsnanmeanors.js' );
3031

3132

3233
// FUNCTIONS //
3334

35+
/**
36+
* Returns a random number.
37+
*
38+
* @private
39+
* @returns {number} random number
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.8 ) < 1 ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
3448
/**
3549
* Creates a benchmark function.
3650
*
@@ -39,17 +53,7 @@ var dsnanmeanors = require( './../lib/dsnanmeanors.js' );
3953
* @returns {Function} benchmark function
4054
*/
4155
function createBenchmark( len ) {
42-
var x;
43-
var i;
44-
45-
x = new Float32Array( len );
46-
for ( i = 0; i < x.length; i++ ) {
47-
if ( randu() < 0.2 ) {
48-
x[ i ] = NaN;
49-
} else {
50-
x[ i ] = ( randu()*20.0 ) - 10.0;
51-
}
52-
}
56+
var x = filledarrayBy( len, 'float32', rand );
5357
return benchmark;
5458

5559
function benchmark( b ) {

0 commit comments

Comments
 (0)