Skip to content

Commit 7ebc247

Browse files
committed
Auto-generated commit
1 parent 2ec6ad4 commit 7ebc247

29 files changed

Lines changed: 444 additions & 277 deletions

CHANGELOG.md

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

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

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`7e5c88b`](https://github.com/stdlib-js/stdlib/commit/7e5c88b980808074354a672c930472eb56130b7d) - **feat:** add C ndarray interface and refactor implementation for `stats/base/smeankbn` [(#7494)](https://github.com/stdlib-js/stdlib/pull/7494) _(by Gururaj Gurram, stdlib-bot)_
26+
- [`06df3ac`](https://github.com/stdlib-js/stdlib/commit/06df3ac73aa59460f29237f4d0930e0a99679047) - **refactor:** update paths _(by Gururaj Gurram)_
1527
- [`bcd0411`](https://github.com/stdlib-js/stdlib/commit/bcd04112308e7d7b42de2bc04599d490e429ebc8) - **refactor:** update paths _(by Gururaj Gurram)_
1628
- [`9f85b5d`](https://github.com/stdlib-js/stdlib/commit/9f85b5d90cb6fcaf052116cd06aa4a693757f0ec) - **test:** fix description _(by Philipp Burckhardt)_
1729
- [`5cc731b`](https://github.com/stdlib-js/stdlib/commit/5cc731bdea5ca228c30734e9bccfaa9215ab231e) - **refactor:** update paths _(by Aayush Khanna)_

CONTRIBUTORS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ Ali Salesi <ali_sal1381@yahoo.com>
2121
AlyAbdelmoneim <148393799+AlyAbdelmoneim@users.noreply.github.com>
2222
Aman Bhansali <bhansali.1@iitj.ac.in>
2323
AmanBhadkariya <140033975+AmanBhadkariya@users.noreply.github.com>
24+
Amisha Chhajed <136238836+amishhaa@users.noreply.github.com>
2425
Amit Jimiwal <amitjimiwal45@gmail.com>
2526
Annamalai Prabu <apfossdev@gmail.com>
2627
Anshu Kumar <132515490+anxhukumar@users.noreply.github.com>
2728
Anshu Kumar <contact.anshukumar@protonmail.com>
2829
Anudeep Sanapala <anudeep0306@gmail.com>
30+
Aryan Bhirud <112156883+AryanBhirud@users.noreply.github.com>
2931
Athan Reines <kgryte@gmail.com>
3032
Ayaka <73595362+USERSATOSHI@users.noreply.github.com>
3133
Bhavishy Agrawal <90029607+bhavishy2801@users.noreply.github.com>
@@ -35,6 +37,7 @@ Bryan Elee <rxbryn@gmail.com>
3537
Chinmay Joshi <86140365+JawHawk@users.noreply.github.com>
3638
Christopher Dambamuromo <chridam@gmail.com>
3739
Dan Rose <danoftheroses@gmail.com>
40+
Daniel Hernandez Gomez <156333015+dhernandeez13@users.noreply.github.com>
3841
Daniel Killenberger <daniel.killenberger@gmail.com>
3942
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
4043
Debashis Maharana <debashismaharana7854@gmail.com>
@@ -61,6 +64,7 @@ Girish Garg <garggirish2020@gmail.com>
6164
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
6265
Gunj Joshi <gunjjoshi8372@gmail.com>
6366
Gururaj Gurram <gururajgurram1512@gmail.com>
67+
Harishchandra Reddy <harish.7000@gmail.com>
6468
Haroon Rasheed <51189276+haroon26@users.noreply.github.com>
6569
Harsh <harshyadav6078@gmail.com>
6670
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
@@ -93,6 +97,7 @@ Krishnam Agarwal <83017176+888krishnam@users.noreply.github.com>
9397
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
9498
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
9599
Lalit Narayan Yadav <162928571+LalitNarayanYadav@users.noreply.github.com>
100+
Lokesh Ranjan <lokesh.ranjan.phe23@itbhu.ac.in>
96101
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
97102
MANI <77221000+Eternity0207@users.noreply.github.com>
98103
Mahfuza Humayra Mohona <mhmohona@gmail.com>
@@ -121,6 +126,7 @@ Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
121126
Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
122127
Ori Miles <97595296+orimiles5@users.noreply.github.com>
123128
Philipp Burckhardt <pburckhardt@outlook.com>
129+
Pierre Forstmann <15964998+pierreforstmann@users.noreply.github.com>
124130
Prajjwal Bajpai <142303989+prajjwalbajpai@users.noreply.github.com>
125131
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
126132
Pranav Goswami <pranavchiku11@gmail.com>
@@ -197,6 +203,7 @@ ditsu <170345142+ditsus@users.noreply.github.com>
197203
ekambains <bainsinbusiness@gmail.com>
198204
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
199205
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
206+
jsai28 <54253219+jsai28@users.noreply.github.com>
200207
lohithganni <116790357+lohithganni@users.noreply.github.com>
201208
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
202209
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>

README.md

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

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

89-
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x` using an improved Kahan–Babuška algorithm.
89+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm.
9090

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

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

97-
var v = smeankbn( N, x, 1 );
96+
var v = smeankbn( 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`.
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 ] );
114-
var N = floor( x.length / 2 );
115112

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

@@ -123,45 +120,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
123120

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

128124
var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
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 = smeankbn( N, x1, 2 );
127+
var v = smeankbn( 4, x1, 2 );
134128
// returns 1.25
135129
```
136130

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

139133
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm and alternative indexing semantics.
140134

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

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

147-
var v = smeankbn.ndarray( N, x, 1, 0 );
140+
var v = smeankbn.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 for `x`.
154147

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
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
156149

157150
```javascript
158151
var Float32Array = require( '@stdlib/array-float32' );
159-
var floor = require( '@stdlib/math-base-special-floor' );
160152

161153
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
162-
var N = floor( x.length / 2 );
163154

164-
var v = smeankbn.ndarray( N, x, 2, 1 );
155+
var v = smeankbn.ndarray( 4, x, 2, 1 );
165156
// returns 1.25
166157
```
167158

@@ -186,18 +177,12 @@ var v = smeankbn.ndarray( N, x, 2, 1 );
186177
<!-- eslint no-undef: "error" -->
187178

188179
```javascript
189-
var randu = require( '@stdlib/random-base-randu' );
190-
var round = require( '@stdlib/math-base-special-round' );
191-
var Float32Array = require( '@stdlib/array-float32' );
180+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
192181
var smeankbn = require( '@stdlib/stats-base-smeankbn' );
193182

194-
var x;
195-
var i;
196-
197-
x = new Float32Array( 10 );
198-
for ( i = 0; i < x.length; i++ ) {
199-
x[ i ] = round( (randu()*100.0) - 50.0 );
200-
}
183+
var x = discreteUniform( 10, -50, 50, {
184+
'dtype': 'float32'
185+
});
201186
console.log( x );
202187

203188
var v = smeankbn( x.length, x, 1 );
@@ -208,6 +193,123 @@ console.log( v );
208193

209194
<!-- /.examples -->
210195

196+
<!-- C interface documentation. -->
197+
198+
* * *
199+
200+
<section class="c">
201+
202+
## C APIs
203+
204+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
205+
206+
<section class="intro">
207+
208+
</section>
209+
210+
<!-- /.intro -->
211+
212+
<!-- C usage documentation. -->
213+
214+
<section class="usage">
215+
216+
### Usage
217+
218+
```c
219+
#include "stdlib/stats/base/smeankbn.h"
220+
```
221+
222+
#### stdlib_strided_smeankbn( N, \*X, strideX )
223+
224+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm.
225+
226+
```c
227+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
228+
229+
float v = stdlib_strided_smeankbn( 4, x, 2 );
230+
// returns 4.0f
231+
```
232+
233+
The function accepts the following arguments:
234+
235+
- **N**: `[in] CBLAS_INT` number of indexed elements.
236+
- **X**: `[in] float*` input array.
237+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
238+
239+
```c
240+
float stdlib_strided_smeankbn( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
241+
```
242+
243+
#### stdlib_strided_smeankbn_ndarray( N, \*X, strideX, offsetX )
244+
245+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using an improved Kahan–Babuška algorithm and alternative indexing semantics.
246+
247+
```c
248+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
249+
250+
float v = stdlib_strided_smeankbn_ndarray( 4, x, 2, 0 );
251+
// returns 4.0f
252+
```
253+
254+
The function accepts the following arguments:
255+
256+
- **N**: `[in] CBLAS_INT` number of indexed elements.
257+
- **X**: `[in] float*` input array.
258+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
259+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
260+
261+
```c
262+
float stdlib_strided_smeankbn_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
263+
```
264+
265+
</section>
266+
267+
<!-- /.usage -->
268+
269+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
270+
271+
<section class="notes">
272+
273+
</section>
274+
275+
<!-- /.notes -->
276+
277+
<!-- C API usage examples. -->
278+
279+
<section class="examples">
280+
281+
### Examples
282+
283+
```c
284+
#include "stdlib/stats/base/smeankbn.h"
285+
#include <stdio.h>
286+
287+
int main( void ) {
288+
// Create a strided array:
289+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
290+
291+
// Specify the number of elements:
292+
const int N = 4;
293+
294+
// Specify the stride length:
295+
const int strideX = 2;
296+
297+
// Compute the arithmetic mean:
298+
float v = stdlib_strided_smeankbn( N, x, strideX );
299+
300+
// Print the result:
301+
printf( "mean: %f\n", v );
302+
}
303+
```
304+
305+
</section>
306+
307+
<!-- /.examples -->
308+
309+
</section>
310+
311+
<!-- /.c -->
312+
211313
* * *
212314
213315
<section class="references">
@@ -229,7 +331,7 @@ console.log( v );
229331
## See Also
230332
231333
- <span class="package-name">[`@stdlib/stats-strided/dmeankbn`][@stdlib/stats/strided/dmeankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using an improved Kahan–Babuška algorithm.</span>
232-
- <span class="package-name">[`@stdlib/stats-base/meankbn`][@stdlib/stats/base/meankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using an improved Kahan–Babuška algorithm.</span>
334+
- <span class="package-name">[`@stdlib/stats-strided/meankbn`][@stdlib/stats/strided/meankbn]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a strided array using an improved Kahan–Babuška algorithm.</span>
233335
- <span class="package-name">[`@stdlib/stats-strided/smean`][@stdlib/stats/strided/smean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a single-precision floating-point strided array.</span>
234336
235337
</section>
@@ -320,7 +422,7 @@ Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
320422
321423
[@stdlib/stats/strided/dmeankbn]: https://github.com/stdlib-js/stats-strided-dmeankbn
322424
323-
[@stdlib/stats/base/meankbn]: https://github.com/stdlib-js/stats-base-meankbn
425+
[@stdlib/stats/strided/meankbn]: https://github.com/stdlib-js/stats-strided-meankbn
324426
325427
[@stdlib/stats/strided/smean]: https://github.com/stdlib-js/stats-strided-smean
326428

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 Float32Array = require( '@stdlib/array-float32' );
2827
var pkg = require( './../package.json' ).name;
2928
var smeankbn = require( './../lib/smeankbn.js' );
3029

3130

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

3440
/**
@@ -39,13 +45,7 @@ var smeankbn = require( './../lib/smeankbn.js' );
3945
* @returns {Function} benchmark function
4046
*/
4147
function createBenchmark( len ) {
42-
var x;
43-
var i;
44-
45-
x = new Float32Array( 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 ) {

0 commit comments

Comments
 (0)