Skip to content

Commit b746010

Browse files
committed
Auto-generated commit
1 parent f6e57af commit b746010

29 files changed

+496
-280
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-06-23)
7+
## Unreleased (2025-08-13)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`03fa864`](https://github.com/stdlib-js/stdlib/commit/03fa864694becb2d5bf705033dd106c5fdc2566b) - add C ndarray interface and refactor implementation for `stats/base/snanmean` [(#7705)](https://github.com/stdlib-js/stdlib/pull/7705)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="bug-fixes">
1020

@@ -22,6 +32,7 @@
2232

2333
<details>
2434

35+
- [`03fa864`](https://github.com/stdlib-js/stdlib/commit/03fa864694becb2d5bf705033dd106c5fdc2566b) - **feat:** add C ndarray interface and refactor implementation for `stats/base/snanmean` [(#7705)](https://github.com/stdlib-js/stdlib/pull/7705) _(by Gururaj Gurram, Athan Reines, stdlib-bot)_
2536
- [`fe87ef3`](https://github.com/stdlib-js/stdlib/commit/fe87ef3f1d320867b195765cd1aec7800270e33e) - **refactor:** update paths _(by Gururaj Gurram)_
2637
- [`bcd0411`](https://github.com/stdlib-js/stdlib/commit/bcd04112308e7d7b42de2bc04599d490e429ebc8) - **refactor:** update paths _(by Gururaj Gurram)_
2738
- [`9f85b5d`](https://github.com/stdlib-js/stdlib/commit/9f85b5d90cb6fcaf052116cd06aa4a693757f0ec) - **test:** fix description _(by Philipp Burckhardt)_

CONTRIBUTORS

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ Abdelrahman Samir <60700731+abdelrahman04@users.noreply.github.com>
99
Abdul Kaium <97376242+impawstarlight@users.noreply.github.com>
1010
Abhay Punia <156515195+Hecker165@users.noreply.github.com>
1111
Abhijit Raut <abhijitmraut8010@gmail.com>
12+
Abhishek G <166795493+AbhishekG-Codes@users.noreply.github.com>
1213
Abhishek Jain <40913033+abhishekblue@users.noreply.github.com>
1314
Adarsh Palaskar <adarshpalaskar99@gmail.com>
1415
Aditya Sapra <adityaework@gmail.com>
16+
Aditya Singh <adityasinghk099@gmail.com>
1517
Ahmed Atwa <Ahmedatwa866@yahoo.com>
1618
Ahmed Kashkoush <ahmedkashkoush464@gmail.com>
1719
Ahmed Khaled <kahmd1444@gmail.com>
@@ -23,12 +25,16 @@ Aman Bhansali <bhansali.1@iitj.ac.in>
2325
AmanBhadkariya <140033975+AmanBhadkariya@users.noreply.github.com>
2426
Amisha Chhajed <136238836+amishhaa@users.noreply.github.com>
2527
Amit Jimiwal <amitjimiwal45@gmail.com>
28+
Anmol Sah <113588714+anmolsah@users.noreply.github.com>
2629
Annamalai Prabu <apfossdev@gmail.com>
2730
Anshu Kumar <132515490+anxhukumar@users.noreply.github.com>
2831
Anshu Kumar <contact.anshukumar@protonmail.com>
2932
Anudeep Sanapala <anudeep0306@gmail.com>
33+
Arihant Pal <arihant0pal@gmail.com>
3034
Aryan Bhirud <112156883+AryanBhirud@users.noreply.github.com>
35+
AryanJ18 <18aryanj2006@gmail.com>
3136
Athan Reines <kgryte@gmail.com>
37+
Atharva Patil <124063987+atharva-patil-23@users.noreply.github.com>
3238
Ayaka <73595362+USERSATOSHI@users.noreply.github.com>
3339
Bhavishy Agrawal <90029607+bhavishy2801@users.noreply.github.com>
3440
Brendan Graetz <bguiz@users.noreply.github.com>
@@ -43,6 +49,7 @@ Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
4349
Debashis Maharana <debashismaharana7854@gmail.com>
4450
Deep Trivedi <128926685+thedeeppp@users.noreply.github.com>
4551
Deepak Singh <78257493+Deepak91168@users.noreply.github.com>
52+
Deepak Singh <negid0253@gmail.com>
4653
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
4754
Dev Goel <135586571+corsairier@users.noreply.github.com>
4855
Dhanyabad behera <110620935+dhanyabad11@users.noreply.github.com>
@@ -60,6 +67,7 @@ GURU PRASAD SHARMA <168292003+GURUPRASADSHARMA@users.noreply.github.com>
6067
Gaurav <gaurav70380@gmail.com>
6168
Gautam Kaushik <162317291+Kaushikgtm@users.noreply.github.com>
6269
Gautam sharma <gautamkrishnasharma1@gmail.com>
70+
GeoDaoyu <geodaoyu@foxmail.com>
6371
Girish Garg <garggirish2020@gmail.com>
6472
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
6573
Gunj Joshi <gunjjoshi8372@gmail.com>
@@ -113,6 +121,8 @@ Momtchil Momtchev <momtchil@momtchev.com>
113121
Muhammad Haris <harriskhan047@outlook.com>
114122
Muhammad Taaha Tariq <166188821+Taaha-Tariq@users.noreply.github.com>
115123
Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com>
124+
NEEKUorAAYUSH <aayush10072004@gmail.com>
125+
Nakul Krishnakumar <nakulkrishnakumar86@gmail.com>
116126
Naresh Jagadeesan <naresh.naresh000@gmail.com>
117127
Naveen Kumar <stupiddint@gmail.com>
118128
Neeraj Pathak <neerajrpathak710@gmail.com>
@@ -127,6 +137,7 @@ Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
127137
Ori Miles <97595296+orimiles5@users.noreply.github.com>
128138
Philipp Burckhardt <pburckhardt@outlook.com>
129139
Pierre Forstmann <15964998+pierreforstmann@users.noreply.github.com>
140+
Pradyumn Prasad <pradyumnprasad.567@gmail.com>
130141
Prajjwal Bajpai <142303989+prajjwalbajpai@users.noreply.github.com>
131142
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
132143
Pranav Goswami <pranavchiku11@gmail.com>
@@ -162,14 +173,17 @@ Sai Avinash <120403424+nasarobot@users.noreply.github.com>
162173
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
163174
Sanchay Ketan Sinha <122982233+satansin123@users.noreply.github.com>
164175
Sarthak Paandey <145528240+SarthakPaandey@users.noreply.github.com>
176+
Satyajeet Chavan <chavansatyajeet2004@gmail.com>
165177
Saurabh Singh <saurabhsraghuvanshi@gmail.com>
166178
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
167179
Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com>
168180
Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
169181
Shivam Ahir <11shivam00@gmail.com>
182+
Shivansh <114570926+shiv343@users.noreply.github.com>
170183
Shraddheya Shendre <shendreshraddheya@gmail.com>
171184
Shubh Mehta <93862397+Shubh942@users.noreply.github.com>
172185
Shubham Mishra <shubh622005@gmail.com>
186+
Siddhesh waje <117733253+siddhesh434@users.noreply.github.com>
173187
Sivam Das <100067002+Sivam2313@users.noreply.github.com>
174188
Snehil Shah <snehilshah.989@gmail.com>
175189
Soumajit Chatterjee <121816890+soumajit23@users.noreply.github.com>
@@ -189,15 +203,18 @@ Utkarsh <http://utkarsh11105@gmail.com>
189203
Utkarsh Raj <rajutkarsh2505@gmail.com>
190204
UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
191205
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
206+
Vansh Choudhary <iamvanshchaudhary7@gmail.com>
192207
Vara Rahul Rajana <123227543+rajanarahul93@users.noreply.github.com>
193208
Varad Gupta <varadgupta21@gmail.com>
194209
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
195210
Vivek Maurya <vm8118134@gmail.com>
211+
Wendy Yuchen Sun <wendyyuchensun@gmail.com>
196212
Xiaochuan Ye <tap91624@gmail.com>
197213
Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
198214
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
199215
Yugal Kaushik <yugalkaushik14@gmail.com>
200216
Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
217+
deepak427 <62477872+deepak427@users.noreply.github.com>
201218
devshree-bhati <147095250+devshree-bhati@users.noreply.github.com>
202219
ditsu <170345142+ditsus@users.noreply.github.com>
203220
ekambains <bainsinbusiness@gmail.com>

README.md

Lines changed: 143 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -84,84 +84,77 @@ To view installation and usage instructions specific to each branch build, be su
8484
var snanmean = require( '@stdlib/stats-base-snanmean' );
8585
```
8686

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

89-
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x`, ignoring `NaN` values.
89+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values.
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 = snanmean( N, x, 1 );
96+
var v = snanmean( 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.
106105

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`,
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`,
108107

109108
```javascript
110109
var Float32Array = require( '@stdlib/array-float32' );
111-
var floor = require( '@stdlib/math-base-special-floor' );
112110

113111
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 );
115112

116-
var v = snanmean( N, x, 2 );
113+
var v = snanmean( 4, x, 2 );
117114
// returns 1.25
118115
```
119116

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

122-
<!-- eslint-disable stdlib/capitalized-comments -->
119+
<!-- eslint-disable stdlib/capitalized-comments, max-len -->
123120

124121
```javascript
125122
var Float32Array = require( '@stdlib/array-float32' );
126-
var floor = require( '@stdlib/math-base-special-floor' );
127123

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

131-
var N = floor( x0.length / 2 );
132-
133-
var v = snanmean( N, x1, 2 );
127+
var v = snanmean( 5, x1, 2 );
134128
// returns 1.25
135129
```
136130

137-
#### snanmean.ndarray( N, x, stride, offset )
131+
#### snanmean.ndarray( N, x, strideX, offsetX )
138132

139133
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
140134

141135
```javascript
142136
var Float32Array = require( '@stdlib/array-float32' );
143137

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

147-
var v = snanmean.ndarray( N, x, 1, 0 );
140+
var v = snanmean.ndarray( x.length, x, 1, 0 );
148141
// returns ~0.33333
149142
```
150143

151144
The function has the following additional parameters:
152145

153-
- **offset**: starting index for `x`.
146+
- **offsetX**: starting index.
147+
148+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other element in `x` starting from the second element
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+
<!-- eslint-disable max-len -->
156151

157152
```javascript
158153
var Float32Array = require( '@stdlib/array-float32' );
159-
var floor = require( '@stdlib/math-base-special-floor' );
160154

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 );
155+
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
163156

164-
var v = snanmean.ndarray( N, x, 2, 1 );
157+
var v = snanmean.ndarray( 5, x, 2, 1 );
165158
// returns 1.25
166159
```
167160

@@ -187,22 +180,19 @@ var v = snanmean.ndarray( N, x, 2, 1 );
187180
<!-- eslint no-undef: "error" -->
188181

189182
```javascript
190-
var randu = require( '@stdlib/random-base-randu' );
191-
var round = require( '@stdlib/math-base-special-round' );
192-
var Float32Array = require( '@stdlib/array-float32' );
183+
var uniform = require( '@stdlib/random-base-uniform' );
184+
var filledarrayBy = require( '@stdlib/array-filled-by' );
185+
var bernoulli = require( '@stdlib/random-base-bernoulli' );
193186
var snanmean = require( '@stdlib/stats-base-snanmean' );
194187

195-
var x;
196-
var i;
197-
198-
x = new Float32Array( 10 );
199-
for ( i = 0; i < x.length; i++ ) {
200-
if ( randu() < 0.2 ) {
201-
x[ i ] = NaN;
202-
} else {
203-
x[ i ] = round( (randu()*100.0) - 50.0 );
188+
function rand() {
189+
if ( bernoulli( 0.8 ) < 1 ) {
190+
return NaN;
204191
}
192+
return uniform( -50.0, 50.0 );
205193
}
194+
195+
var x = filledarrayBy( 10, 'float32', rand );
206196
console.log( x );
207197

208198
var v = snanmean( x.length, x, 1 );
@@ -213,6 +203,123 @@ console.log( v );
213203

214204
<!-- /.examples -->
215205

206+
<!-- C interface documentation. -->
207+
208+
* * *
209+
210+
<section class="c">
211+
212+
## C APIs
213+
214+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
215+
216+
<section class="intro">
217+
218+
</section>
219+
220+
<!-- /.intro -->
221+
222+
<!-- C usage documentation. -->
223+
224+
<section class="usage">
225+
226+
### Usage
227+
228+
```c
229+
#include "stdlib/stats/base/snanmean.h"
230+
```
231+
232+
#### stdlib_strided_snanmean( N, \*X, strideX )
233+
234+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values.
235+
236+
```c
237+
const float x[] = { 1.0f, 2.0f, 3.0f, 0.0f/0.0f };
238+
239+
float v = stdlib_strided_snanmean( 4, x, 1 );
240+
// returns 2.0f
241+
```
242+
243+
The function accepts the following arguments:
244+
245+
- **N**: `[in] CBLAS_INT` number of indexed elements.
246+
- **X**: `[in] float*` input array.
247+
- **strideX**: `[in] CBLAS_INT` stride length.
248+
249+
```c
250+
float stdlib_strided_snanmean( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
251+
```
252+
253+
#### stdlib_strided_snanmean_ndarray( N, \*X, strideX, offsetX )
254+
255+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
256+
257+
```c
258+
const float x[] = { 1.0f, 2.0f, 3.0f, 0.0f/0.0f };
259+
260+
float v = stdlib_strided_snanmean_ndarray( 4, x, 1, 0 );
261+
// returns 2.0f
262+
```
263+
264+
The function accepts the following arguments:
265+
266+
- **N**: `[in] CBLAS_INT` number of indexed elements.
267+
- **X**: `[in] float*` input array.
268+
- **strideX**: `[in] CBLAS_INT` stride length.
269+
- **offsetX**: `[in] CBLAS_INT` starting index.
270+
271+
```c
272+
float stdlib_strided_snanmean_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
273+
```
274+
275+
</section>
276+
277+
<!-- /.usage -->
278+
279+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
280+
281+
<section class="notes">
282+
283+
</section>
284+
285+
<!-- /.notes -->
286+
287+
<!-- C API usage examples. -->
288+
289+
<section class="examples">
290+
291+
### Examples
292+
293+
```c
294+
#include "stdlib/stats/base/snanmean.h"
295+
#include <stdio.h>
296+
297+
int main( void ) {
298+
// Create a strided array:
299+
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 };
300+
301+
// Specify the number of elements:
302+
const int N = 6;
303+
304+
// Specify the stride length:
305+
const int strideX = 2;
306+
307+
// Compute the arithmetic mean:
308+
float v = stdlib_strided_snanmean( N, x, strideX );
309+
310+
// Print the result:
311+
printf( "mean: %f\n", v );
312+
}
313+
```
314+
315+
</section>
316+
317+
<!-- /.examples -->
318+
319+
</section>
320+
321+
<!-- /.c -->
322+
216323
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
217324
218325
<section class="related">

0 commit comments

Comments
 (0)