Skip to content

Commit 147a845

Browse files
committed
Auto-generated commit
1 parent 6d1dff8 commit 147a845

29 files changed

+437
-285
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
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+
- [`716275f`](https://github.com/stdlib-js/stdlib/commit/716275fdf515090bb85f78ca5099be9011abcb66) - add C ndarray interface and refactor implementation for `stats/base/smeanlipw` [(#7500)](https://github.com/stdlib-js/stdlib/pull/7500)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`716275f`](https://github.com/stdlib-js/stdlib/commit/716275fdf515090bb85f78ca5099be9011abcb66) - **feat:** add C ndarray interface and refactor implementation for `stats/base/smeanlipw` [(#7500)](https://github.com/stdlib-js/stdlib/pull/7500) _(by Gururaj Gurram, Athan Reines, stdlib-bot)_
1526
- [`bcd0411`](https://github.com/stdlib-js/stdlib/commit/bcd04112308e7d7b42de2bc04599d490e429ebc8) - **refactor:** update paths _(by Gururaj Gurram)_
1627
- [`9f85b5d`](https://github.com/stdlib-js/stdlib/commit/9f85b5d90cb6fcaf052116cd06aa4a693757f0ec) - **test:** fix description _(by Philipp Burckhardt)_
1728
- [`44ca2b2`](https://github.com/stdlib-js/stdlib/commit/44ca2b23d9db331afa5718b3f1d0401ede95c3b0) - **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: 133 additions & 31 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 smeanlipw = require( '@stdlib/stats-base-smeanlipw' );
8585
```
8686

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

89-
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x` using a one-pass trial mean algorithm with pairwise summation.
89+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using a one-pass trial mean algorithm with pairwise summation.
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 = smeanlipw( N, x, 1 );
96+
var v = smeanlipw( 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 = smeanlipw( N, x, 2 );
113+
var v = smeanlipw( 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 = smeanlipw( N, x1, 2 );
127+
var v = smeanlipw( 4, x1, 2 );
134128
// returns 1.25
135129
```
136130

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

139133
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using a one-pass trial mean algorithm with pairwise summation 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 = smeanlipw.ndarray( N, x, 1, 0 );
140+
var v = smeanlipw.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 = smeanlipw.ndarray( N, x, 2, 1 );
155+
var v = smeanlipw.ndarray( 4, x, 2, 1 );
165156
// returns 1.25
166157
```
167158

@@ -187,18 +178,12 @@ var v = smeanlipw.ndarray( N, x, 2, 1 );
187178
<!-- eslint no-undef: "error" -->
188179

189180
```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' );
181+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
193182
var smeanlipw = require( '@stdlib/stats-base-smeanlipw' );
194183

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

204189
var v = smeanlipw( x.length, x, 1 );
@@ -209,6 +194,123 @@ console.log( v );
209194

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

197+
<!-- C interface documentation. -->
198+
199+
* * *
200+
201+
<section class="c">
202+
203+
## C APIs
204+
205+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
206+
207+
<section class="intro">
208+
209+
</section>
210+
211+
<!-- /.intro -->
212+
213+
<!-- C usage documentation. -->
214+
215+
<section class="usage">
216+
217+
### Usage
218+
219+
```c
220+
#include "stdlib/stats/base/smeanlipw.h"
221+
```
222+
223+
#### stdlib_strided_smeanlipw( N, \*X, strideX )
224+
225+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using a one-pass trial mean algorithm with pairwise summation.
226+
227+
```c
228+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
229+
230+
float v = stdlib_strided_smeanlipw( 4, x, 2 );
231+
// returns 4.0f
232+
```
233+
234+
The function accepts the following arguments:
235+
236+
- **N**: `[in] CBLAS_INT` number of indexed elements.
237+
- **X**: `[in] float*` input array.
238+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
239+
240+
```c
241+
float stdlib_strided_smeanlipw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
242+
```
243+
244+
#### stdlib_strided_smeanlipw_ndarray( N, \*X, strideX, offsetX )
245+
246+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using a one-pass trial mean algorithm with pairwise summation and alternative indexing semantics.
247+
248+
```c
249+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
250+
251+
float v = stdlib_strided_smeanlipw_ndarray( 4, x, 2, 0 );
252+
// returns 4.0f
253+
```
254+
255+
The function accepts the following arguments:
256+
257+
- **N**: `[in] CBLAS_INT` number of indexed elements.
258+
- **X**: `[in] float*` input array.
259+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
260+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
261+
262+
```c
263+
float stdlib_strided_smeanlipw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
264+
```
265+
266+
</section>
267+
268+
<!-- /.usage -->
269+
270+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
271+
272+
<section class="notes">
273+
274+
</section>
275+
276+
<!-- /.notes -->
277+
278+
<!-- C API usage examples. -->
279+
280+
<section class="examples">
281+
282+
### Examples
283+
284+
```c
285+
#include "stdlib/stats/base/smeanlipw.h"
286+
#include <stdio.h>
287+
288+
int main( void ) {
289+
// Create a strided array:
290+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
291+
292+
// Specify the number of elements:
293+
const int N = 4;
294+
295+
// Specify the stride length:
296+
const int strideX = 2;
297+
298+
// Compute the arithmetic mean:
299+
float v = stdlib_strided_smeanlipw( N, x, strideX );
300+
301+
// Print the result:
302+
printf( "mean: %f\n", v );
303+
}
304+
```
305+
306+
</section>
307+
308+
<!-- /.examples -->
309+
310+
</section>
311+
312+
<!-- /.c -->
313+
212314
* * *
213315
214316
<section class="references">

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 smeanlipw = require( './../lib/smeanlipw.js' );
3029

3130

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

3440
/**
@@ -39,13 +45,7 @@ var smeanlipw = require( './../lib/smeanlipw.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 ) {

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 Float32Array = require( '@stdlib/array-float32' );
2928
var tryRequire = require( '@stdlib/utils-try-require' );
3029
var pkg = require( './../package.json' ).name;
3130

@@ -36,6 +35,9 @@ var smeanlipw = tryRequire( resolve( __dirname, './../lib/smeanlipw.native.js' )
3635
var opts = {
3736
'skip': ( smeanlipw instanceof Error )
3837
};
38+
var options = {
39+
'dtype': 'float32'
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 Float32Array( 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)