Skip to content

Commit dc00c70

Browse files
committed
Auto-generated commit
1 parent bb510ee commit dc00c70

30 files changed

+394
-253
lines changed

.editorconfig

-1
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}]

CHANGELOG.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@
44
55
<section class="release" id="unreleased">
66

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

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

15-
- [`5f718b7`](https://github.com/stdlib-js/stdlib/commit/5f718b70ecd483de6fa502efbfed3da4cac79ce2) - **refactor:** update `stats/base/smeanli` native addon from C++ to C [(#4465)](https://github.com/stdlib-js/stdlib/pull/4465) _(by Vivek maurya)_
25+
- [`cbb399f`](https://github.com/stdlib-js/stdlib/commit/cbb399f69098247acb31497af6e1370b51fe285d) - **feat:** add C ndarray interface and refactor implementation for `stats/base/smeanli` [(#4785)](https://github.com/stdlib-js/stdlib/pull/4785) _(by Aayush Khanna, Athan Reines, stdlib-bot)_
26+
- [`5f718b7`](https://github.com/stdlib-js/stdlib/commit/5f718b70ecd483de6fa502efbfed3da4cac79ce2) - **refactor:** update `stats/base/smeanli` native addon from C++ to C [(#4465)](https://github.com/stdlib-js/stdlib/pull/4465) _(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

@@ -26,10 +37,12 @@
2637

2738
### Contributors
2839

29-
A total of 2 people contributed to this release. Thank you to the following contributors:
40+
A total of 4 people contributed to this release. Thank you to the following contributors:
3041

42+
- Aayush Khanna
43+
- Athan Reines
3144
- Philipp Burckhardt
32-
- Vivek maurya
45+
- Vivek Maurya
3346

3447
</section>
3548

CONTRIBUTORS

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ 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]>
@@ -49,6 +51,7 @@ Joey Reed <[email protected]>
4951
Jordan Gallivan <[email protected]>
5052
Joris Labie <[email protected]>
5153
Justin Dennison <[email protected]>
54+
Karan Anand <[email protected]>
5255
Karthik Prakash <[email protected]>
5356
Kohantika Nath <[email protected]>
5457
Krishnendu Das <[email protected]>
@@ -117,7 +120,7 @@ UtkershBasnet <[email protected]>
117120
Vaibhav Patel <[email protected]>
118121
Varad Gupta <[email protected]>
119122
Vinit Pandit <[email protected]>
120-
Vivek maurya <[email protected].com>
123+
Vivek Maurya <vm8118134@gmail.com>
121124
Xiaochuan Ye <[email protected]>
122125
Yaswanth Kosuru <[email protected]>
123126
Yernar Yergaziyev <[email protected]>

NOTICE

+1-1
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

+131-29
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 smeanli = require( '@stdlib/stats-base-smeanli' );
8585
```
8686

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

8989
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x` using a one-pass trial mean 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 = smeanli( N, x, 1 );
96+
var v = smeanli( 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**: index increment 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 = smeanli( N, x, 2 );
113+
var v = smeanli( 4, x, 2 );
117114
// returns 1.25
118115
```
119116

@@ -123,14 +120,11 @@ 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 = smeanli( N, x1, 2 );
127+
var v = smeanli( 4, x1, 2 );
134128
// returns 1.25
135129
```
136130

@@ -142,26 +136,23 @@ Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-p
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 = smeanli.ndarray( N, x, 1, 0 );
140+
var v = smeanli.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 = smeanli.ndarray( N, x, 2, 1 );
155+
var v = smeanli.ndarray( 4, x, 2, 1 );
165156
// returns 1.25
166157
```
167158

@@ -187,18 +178,12 @@ var v = smeanli.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 smeanli = require( '@stdlib/stats-base-smeanli' );
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 = smeanli( 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/smeanli.h"
221+
```
222+
223+
#### stdlib_strided_smeanli( 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.
226+
227+
```c
228+
const float x[] = { 1.0f, 2.0f, 3.0f };
229+
230+
float v = stdlib_strided_smeanli( 3, x, 1 );
231+
// returns 2.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.
239+
240+
```c
241+
float stdlib_strided_smeanli( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
242+
```
243+
244+
#### stdlib_strided_smeanli_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 and alternative indexing semantics.
247+
248+
```c
249+
const float x[] = { 1.0f, 2.0f, 3.0f };
250+
251+
float v = stdlib_strided_smeanli_ndarray( 3, x, 1, 0 );
252+
// returns 2.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.
260+
- **offsetX**: `[in] CBLAS_INT` starting index.
261+
262+
```c
263+
float stdlib_strided_smeanli_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/smeanli.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_smeanli( 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

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

3130

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

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

+5-9
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 smeanli = tryRequire( resolve( __dirname, './../lib/smeanli.native.js' ) );
3635
var opts = {
3736
'skip': ( smeanli 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)