Skip to content

Commit b393f9e

Browse files
committed
Auto-generated commit
1 parent 257e985 commit b393f9e

25 files changed

+400
-253
lines changed

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -6428,6 +6428,28 @@ This release closes the following issue:
64286428

64296429
<!-- /.package -->
64306430

6431+
<section class="package" id="stats-base-dsmeanpw-unreleased">
6432+
6433+
#### [@stdlib/stats/base/dsmeanpw](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dsmeanpw)
6434+
6435+
<details>
6436+
6437+
<section class="features">
6438+
6439+
##### Features
6440+
6441+
- [`deabf53`](https://github.com/stdlib-js/stdlib/commit/deabf5358fdce4a99aa6f060e3d296a69538ed24) - add C `ndarray` interface and refactor implementation for `stats/base/dsmeanpw` [(#4338)](https://github.com/stdlib-js/stdlib/pull/4338)
6442+
6443+
</section>
6444+
6445+
<!-- /.features -->
6446+
6447+
</details>
6448+
6449+
</section>
6450+
6451+
<!-- /.package -->
6452+
64316453
<section class="package" id="stats-base-dsmeanwd-unreleased">
64326454

64336455
#### [@stdlib/stats/base/dsmeanwd](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dsmeanwd)
@@ -7776,6 +7798,7 @@ A total of 20 people contributed to this release. Thank you to the following con
77767798

77777799
<details>
77787800

7801+
- [`deabf53`](https://github.com/stdlib-js/stdlib/commit/deabf5358fdce4a99aa6f060e3d296a69538ed24) - **feat:** add C `ndarray` interface and refactor implementation for `stats/base/dsmeanpw` [(#4338)](https://github.com/stdlib-js/stdlib/pull/4338) _(by Neeraj Pathak, stdlib-bot)_
77797802
- [`3f740e8`](https://github.com/stdlib-js/stdlib/commit/3f740e88f3d1e0a42e50e351603a0d4eb0e9cf2e) - **feat:** add C implementation for `stats/base/dists/chisquare/stdev` [(#3996)](https://github.com/stdlib-js/stdlib/pull/3996) _(by Vivek Maurya, Philipp Burckhardt, stdlib-bot)_
77807803
- [`2b91a43`](https://github.com/stdlib-js/stdlib/commit/2b91a43344d32f63fd50185d17fadf13e9c977a7) - **feat:** add C implementation for `stats/base/dists/chisquare/mean` [(#3989)](https://github.com/stdlib-js/stdlib/pull/3989) _(by Vivek Maurya, Philipp Burckhardt, stdlib-bot)_
77817804
- [`21c2f38`](https://github.com/stdlib-js/stdlib/commit/21c2f3822dd61cce49ec0e38ea0add2b91006162) - **docs:** update namespace table of contents [(#4811)](https://github.com/stdlib-js/stdlib/pull/4811) _(by stdlib-bot)_

base/dsmeanpw/README.md

+115-29
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,33 @@ The [arithmetic mean][arithmetic-mean] is defined as
5151
var dsmeanpw = require( '@stdlib/stats/base/dsmeanpw' );
5252
```
5353

54-
#### dsmeanpw( N, x, stride )
54+
#### dsmeanpw( N, x, strideX )
5555

5656
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x` using pairwise summation with extended accumulation and returning an extended precision result.
5757

5858
```javascript
5959
var Float32Array = require( '@stdlib/array/float32' );
6060

6161
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
62-
var N = x.length;
6362

64-
var v = dsmeanpw( N, x, 1 );
63+
var v = dsmeanpw( x.length, x, 1 );
6564
// returns ~0.3333
6665
```
6766

6867
The function has the following parameters:
6968

7069
- **N**: number of indexed elements.
7170
- **x**: input [`Float32Array`][@stdlib/array/float32].
72-
- **stride**: index increment for `x`.
71+
- **strideX**: stride length for `x`.
7372

7473
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`,
7574

7675
```javascript
7776
var Float32Array = require( '@stdlib/array/float32' );
78-
var floor = require( '@stdlib/math/base/special/floor' );
7977

8078
var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
81-
var N = floor( x.length / 2 );
8279

83-
var v = dsmeanpw( N, x, 2 );
80+
var v = dsmeanpw( 4, x, 2 );
8481
// returns 1.25
8582
```
8683

@@ -90,45 +87,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
9087

9188
```javascript
9289
var Float32Array = require( '@stdlib/array/float32' );
93-
var floor = require( '@stdlib/math/base/special/floor' );
9490

9591
var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
9692
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9793

98-
var N = floor( x0.length / 2 );
99-
100-
var v = dsmeanpw( N, x1, 2 );
94+
var v = dsmeanpw( 4, x1, 2 );
10195
// returns 1.25
10296
```
10397

104-
#### dsmeanpw.ndarray( N, x, stride, offset )
98+
#### dsmeanpw.ndarray( N, x, strideX, offsetX )
10599

106100
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array using pairwise summation with extended accumulation and alternative indexing semantics and returning an extended precision result.
107101

108102
```javascript
109103
var Float32Array = require( '@stdlib/array/float32' );
110104

111105
var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
112-
var N = x.length;
113106

114-
var v = dsmeanpw.ndarray( N, x, 1, 0 );
107+
var v = dsmeanpw.ndarray( x.length, x, 1, 0 );
115108
// returns ~0.33333
116109
```
117110

118111
The function has the following additional parameters:
119112

120-
- **offset**: starting index for `x`.
113+
- **offsetX**: starting index for `x`.
121114

122-
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
115+
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
123116

124117
```javascript
125118
var Float32Array = require( '@stdlib/array/float32' );
126-
var floor = require( '@stdlib/math/base/special/floor' );
127119

128120
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
129-
var N = floor( x.length / 2 );
130121

131-
var v = dsmeanpw.ndarray( N, x, 2, 1 );
122+
var v = dsmeanpw.ndarray( 4, x, 2, 1 );
132123
// returns 1.25
133124
```
134125

@@ -155,18 +146,12 @@ var v = dsmeanpw.ndarray( N, x, 2, 1 );
155146
<!-- eslint no-undef: "error" -->
156147

157148
```javascript
158-
var randu = require( '@stdlib/random/base/randu' );
159-
var round = require( '@stdlib/math/base/special/round' );
160-
var Float32Array = require( '@stdlib/array/float32' );
149+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
161150
var dsmeanpw = require( '@stdlib/stats/base/dsmeanpw' );
162151

163-
var x;
164-
var i;
165-
166-
x = new Float32Array( 10 );
167-
for ( i = 0; i < x.length; i++ ) {
168-
x[ i ] = round( (randu()*100.0) - 50.0 );
169-
}
152+
var x = discreteUniform( 10, -50, 50, {
153+
'dtype': 'float32'
154+
});
170155
console.log( x );
171156

172157
var v = dsmeanpw( x.length, x, 1 );
@@ -177,6 +162,107 @@ console.log( v );
177162

178163
<!-- /.examples -->
179164

165+
<!-- C usage documentation. -->
166+
167+
<section class="usage">
168+
169+
### Usage
170+
171+
```c
172+
#include "stdlib/stats/base/dsmeanpw.h"
173+
```
174+
175+
#### stdlib_strided_dsmeanpw( N, \*X, strideX )
176+
177+
Computes the arithmetic mean of a single-precision floating-point strided array using pairwise summation with extended accumulation and returning an extended precision result.
178+
179+
```c
180+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
181+
182+
double v = stdlib_strided_dsmeanpw( 4, x, 2 );
183+
// returns 4.0
184+
```
185+
186+
The function accepts the following arguments:
187+
188+
- **N**: `[in] CBLAS_INT` number of indexed elements.
189+
- **X**: `[in] float*` input array.
190+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
191+
192+
```c
193+
double stdlib_strided_dsmeanpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
194+
```
195+
196+
#### stdlib_strided_dsmeanpw_ndarray( N, \*X, strideX, offsetX )
197+
198+
Computes the arithmetic mean of a single-precision floating-point strided array using pairwise summation with extended accumulation and alternative indexing semantics and returning an extended precision result.
199+
200+
```c
201+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
202+
203+
double v = stdlib_strided_dsmeanpw_ndarray( 4, x, 2, 0 );
204+
// returns 4.0
205+
```
206+
207+
The function accepts the following arguments:
208+
209+
- **N**: `[in] CBLAS_INT` number of indexed elements.
210+
- **X**: `[in] float*` input array.
211+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
212+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
213+
214+
```c
215+
double stdlib_strided_dsmeanpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
216+
```
217+
218+
</section>
219+
220+
<!-- /.usage -->
221+
222+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
223+
224+
<section class="notes">
225+
226+
</section>
227+
228+
<!-- /.notes -->
229+
230+
<!-- C API usage examples. -->
231+
232+
<section class="examples">
233+
234+
### Examples
235+
236+
```c
237+
#include "stdlib/stats/base/dsmeanpw.h"
238+
#include <stdio.h>
239+
240+
int main( void ) {
241+
// Create a strided array:
242+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
243+
244+
// Specify the number of elements:
245+
const int N = 4;
246+
247+
// Specify the stride length:
248+
const int strideX = 2;
249+
250+
// Compute the arithmetic mean:
251+
double v = stdlib_strided_dsmeanpw( N, x, strideX );
252+
253+
// Print the result:
254+
printf( "mean: %lf\n", v );
255+
}
256+
```
257+
258+
</section>
259+
260+
<!-- /.examples -->
261+
262+
</section>
263+
264+
<!-- /.c -->
265+
180266
* * *
181267
182268
<section class="references">

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

3130

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

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

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

base/dsmeanpw/benchmark/benchmark.ndarray.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
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 dsmeanpw = require( './../lib/ndarray.js' );
3029

3130

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

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