Skip to content

Commit dd38acf

Browse files
committed
Auto-generated commit
1 parent 7122668 commit dd38acf

31 files changed

+405
-268
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}]

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 (2024-12-23)
7+
## Unreleased (2025-01-17)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`70f187e`](https://github.com/stdlib-js/stdlib/commit/70f187e31fed72289590585dbc5da0254df82c9b) - add C ndarray interface and refactor implementation for `stats/base/dmeanpw` [(#4743)](https://github.com/stdlib-js/stdlib/pull/4743)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`70f187e`](https://github.com/stdlib-js/stdlib/commit/70f187e31fed72289590585dbc5da0254df82c9b) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dmeanpw` [(#4743)](https://github.com/stdlib-js/stdlib/pull/4743) _(by Aayush Khanna)_
1526
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
1627
- [`430e40e`](https://github.com/stdlib-js/stdlib/commit/430e40eda1d5a379561b434df31fc3bc5dcc2ce3) - **refactor:** update `stats/base/dmeanpw` native addon from C++ to C [(#4101)](https://github.com/stdlib-js/stdlib/pull/4101) _(by Aayush Khanna)_
1728
- [`9e689ff`](https://github.com/stdlib-js/stdlib/commit/9e689ffcb7c6223afc521f1e574b42f10921cf5e) - **chore:** fix indentation in manifest.json files _(by Philipp Burckhardt)_

CONTRIBUTORS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Daniel Killenberger <daniel.killenberger@gmail.com>
2727
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
2828
Debashis Maharana <debashismaharana7854@gmail.com>
2929
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
30+
Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
3031
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
3132
Dominic Lim <46486515+domlimm@users.noreply.github.com>
3233
Dominik Moritz <domoritz@gmail.com>
@@ -49,6 +50,7 @@ Joey Reed <joeyrreed@gmail.com>
4950
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
5051
Joris Labie <joris.labie1@gmail.com>
5152
Justin Dennison <justin1dennison@gmail.com>
53+
Karan Anand <119553199+anandkaranubc@users.noreply.github.com>
5254
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
5355
Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
5456
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
@@ -117,7 +119,7 @@ UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
117119
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
118120
Varad Gupta <varadgupta21@gmail.com>
119121
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
120-
Vivek maurya <155618190+vivekmaurya001@users.noreply.github.com>
122+
Vivek Maurya <vm8118134@gmail.com>
121123
Xiaochuan Ye <tap91624@gmail.com>
122124
Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
123125
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>

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: 117 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 dmeanpw = require( '@stdlib/stats-base-dmeanpw' );
8585
```
8686

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

8989
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array `x` using pairwise summation.
9090

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

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

97-
var v = dmeanpw( N, x, 1 );
96+
var v = dmeanpw( 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 [`Float64Array`][@stdlib/array/float64].
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 Float64Array = require( '@stdlib/array-float64' );
111-
var floor = require( '@stdlib/math-base-special-floor' );
112110

113111
var x = new Float64Array( [ 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 = dmeanpw( N, x, 2 );
113+
var v = dmeanpw( 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 Float64Array = require( '@stdlib/array-float64' );
126-
var floor = require( '@stdlib/math-base-special-floor' );
127123

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

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

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

139133
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using pairwise summation and alternative indexing semantics.
140134

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

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

147-
var v = dmeanpw.ndarray( N, x, 1, 0 );
140+
var v = dmeanpw.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 Float64Array = require( '@stdlib/array-float64' );
159-
var floor = require( '@stdlib/math-base-special-floor' );
160152

161153
var x = new Float64Array( [ 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 = dmeanpw.ndarray( N, x, 2, 1 );
155+
var v = dmeanpw.ndarray( 4, x, 2, 1 );
165156
// returns 1.25
166157
```
167158

@@ -187,18 +178,12 @@ var v = dmeanpw.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 Float64Array = require( '@stdlib/array-float64' );
181+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
193182
var dmeanpw = require( '@stdlib/stats-base-dmeanpw' );
194183

195-
var x;
196-
var i;
197-
198-
x = new Float64Array( 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': 'float64'
186+
});
202187
console.log( x );
203188

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

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

197+
<!-- C usage documentation. -->
198+
199+
<section class="usage">
200+
201+
### Usage
202+
203+
```c
204+
#include "stdlib/stats/base/dmeanpw.h"
205+
```
206+
207+
#### stdlib_strided_dmeanpw( N, \*X, strideX )
208+
209+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using pairwise summation.
210+
211+
```c
212+
const double x[] = { 1.0, -2.0, 2.0 };
213+
214+
double v = stdlib_strided_dmeanpw( 3, x, 1 );
215+
// returns ~0.3333
216+
```
217+
218+
The function accepts the following arguments:
219+
220+
- **N**: `[in] CBLAS_INT` number of indexed elements.
221+
- **X**: `[in] double*` input array.
222+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
223+
224+
```c
225+
double stdlib_strided_dmeanpw( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
226+
```
227+
228+
#### stdlib_strided_dmeanpw_ndarray( N, \*X, strideX, offsetX )
229+
230+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array using pairwise summation and alternative indexing semantics.
231+
232+
```c
233+
const double x[] = { 1.0, -2.0, 2.0 };
234+
235+
double v = stdlib_strided_dmeanpw_ndarray( 3, x, 1, 0 );
236+
// returns ~0.3333
237+
```
238+
239+
The function accepts the following arguments:
240+
241+
- **N**: `[in] CBLAS_INT` number of indexed elements.
242+
- **X**: `[in] double*` input array.
243+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
244+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
245+
246+
```c
247+
double stdlib_strided_dmeanpw_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
248+
```
249+
250+
</section>
251+
252+
<!-- /.usage -->
253+
254+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
255+
256+
<section class="notes">
257+
258+
</section>
259+
260+
<!-- /.notes -->
261+
262+
<!-- C API usage examples. -->
263+
264+
<section class="examples">
265+
266+
### Examples
267+
268+
```c
269+
#include "stdlib/stats/base/dmeanpw.h"
270+
#include <stdio.h>
271+
272+
int main( void ) {
273+
// Create a strided array:
274+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
275+
276+
// Specify the number of elements:
277+
const int N = 4;
278+
279+
// Specify the stride length:
280+
const int strideX = 2;
281+
282+
// Compute the arithmetic mean:
283+
double v = stdlib_strided_dmeanpw( N, x, strideX );
284+
285+
// Print the result:
286+
printf( "mean: %lf\n", v );
287+
}
288+
```
289+
290+
</section>
291+
292+
<!-- /.examples -->
293+
294+
</section>
295+
296+
<!-- /.c -->
297+
212298
* * *
213299
214300
<section class="references">
@@ -264,7 +350,7 @@ See [LICENSE][stdlib-license].
264350
265351
## Copyright
266352
267-
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
353+
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
268354
269355
</section>
270356

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

3130

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

3440
/**
@@ -39,13 +45,7 @@ var dmeanpw = require( './../lib/dmeanpw.js' );
3945
* @returns {Function} benchmark function
4046
*/
4147
function createBenchmark( len ) {
42-
var x;
43-
var i;
44-
45-
x = new Float64Array( 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 Float64Array = require( '@stdlib/array-float64' );
2928
var tryRequire = require( '@stdlib/utils-try-require' );
3029
var pkg = require( './../package.json' ).name;
3130

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