Skip to content

Commit c200b9e

Browse files
committed
Auto-generated commit
1 parent e2677e5 commit c200b9e

26 files changed

+389
-283
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 (2024-12-23)
7+
## Unreleased (2024-12-25)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`6ec8074`](https://github.com/stdlib-js/stdlib/commit/6ec8074bd6e6c406a743cb8a18a7eb220efa7423) - add C ndarray interface and refactor implementation for `stats/base/dcumax` [(#4137)](https://github.com/stdlib-js/stdlib/pull/4137)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`6ec8074`](https://github.com/stdlib-js/stdlib/commit/6ec8074bd6e6c406a743cb8a18a7eb220efa7423) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dcumax` [(#4137)](https://github.com/stdlib-js/stdlib/pull/4137) _(by Aayush Khanna, Athan Reines)_
1526
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
1627
- [`2ea848b`](https://github.com/stdlib-js/stdlib/commit/2ea848b62b686e1e9d861f7df25ece23a7d80798) - **style:** update to use tabs for indentation _(by Philipp Burckhardt)_
1728
- [`267321a`](https://github.com/stdlib-js/stdlib/commit/267321a4e77cf14de5e85b36fa223a973eb605bc) - **refactor:** update `stats/base/dcumax` native addon from C++ to C [(#4072)](https://github.com/stdlib-js/stdlib/pull/4072) _(by Aayush Khanna)_

README.md

Lines changed: 136 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ The function has the following parameters:
8787

8888
- **N**: number of indexed elements.
8989
- **x**: input [`Float64Array`][@stdlib/array/float64].
90-
- **strideX**: index increment for `x`.
90+
- **strideX**: stride length for `x`.
9191
- **y**: output [`Float64Array`][@stdlib/array/float64].
92-
- **strideY**: index increment for `y`.
92+
- **strideY**: stride length for `y`.
9393

94-
The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative maximum of every other element in `x`,
94+
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative maximum of every other element in `x`,
9595

9696
```javascript
9797
var Float64Array = require( '@stdlib/array-float64' );
@@ -141,7 +141,7 @@ The function has the following additional parameters:
141141
- **offsetX**: starting index for `x`.
142142
- **offsetY**: starting index for `y`.
143143

144-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative maximum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element
144+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative maximum of every other element in `x` starting from the second element and to store in the last `N` elements of `y` starting from the last element
145145

146146
```javascript
147147
var Float64Array = require( '@stdlib/array-float64' );
@@ -174,21 +174,16 @@ dcumax.ndarray( 4, x, 2, 1, y, -1, y.length-1 );
174174
<!-- eslint no-undef: "error" -->
175175

176176
```javascript
177-
var randu = require( '@stdlib/random-base-randu' );
178-
var round = require( '@stdlib/math-base-special-round' );
177+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
179178
var Float64Array = require( '@stdlib/array-float64' );
180179
var dcumax = require( '@stdlib/stats-base-dcumax' );
181180

182-
var y;
183-
var x;
184-
var i;
185-
186-
x = new Float64Array( 10 );
187-
y = new Float64Array( x.length );
188-
for ( i = 0; i < x.length; i++ ) {
189-
x[ i ] = round( randu()*100.0 );
190-
}
181+
var x = discreteUniform( 10, -50, 50, {
182+
'dtype': 'float64'
183+
});
191184
console.log( x );
185+
186+
var y = new Float64Array( x.length );
192187
console.log( y );
193188

194189
dcumax( x.length, x, 1, y, -1 );
@@ -199,6 +194,132 @@ console.log( y );
199194

200195
<!-- /.examples -->
201196

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/dcumax.h"
221+
```
222+
223+
#### stdlib_strided_dcumax( N, \*X, strideX, \*Y, strideY )
224+
225+
Computes the cumulative maximum of double-precision floating-point strided array elements.
226+
227+
```c
228+
const double x[] = { 1.0, 2.0, -3.0, 4.0, -5.0, 6.0, 7.0, 8.0 };
229+
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
230+
231+
stdlib_strided_dcumax( 4, x, 2, y, -2 );
232+
```
233+
234+
The function accepts the following arguments:
235+
236+
- **N**: `[in] CBLAS_INT` number of indexed elements.
237+
- **X**: `[in] double*` input array.
238+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
239+
- **Y**: `[out] double*` output array.
240+
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
241+
242+
```c
243+
void stdlib_strided_dcumax( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );
244+
```
245+
246+
#### stdlib_strided_dcumax_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY )
247+
248+
Computes the cumulative maximum of double-precision floating-point strided array elements using alternative indexing semantics.
249+
250+
```c
251+
const double x[] = { 1.0, 2.0, -3.0, 4.0, -5.0, 6.0, 7.0, 8.0 };
252+
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
253+
254+
stdlib_strided_dcumax_ndarray( 4, x, 2, 0, y, -2, 0 );
255+
```
256+
257+
The function accepts the following arguments:
258+
259+
- **N**: `[in] CBLAS_INT` number of indexed elements.
260+
- **X**: `[in] double*` input array.
261+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
262+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
263+
- **Y**: `[out] double*` output array.
264+
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
265+
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
266+
267+
```c
268+
void stdlib_strided_dcumax_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
269+
```
270+
271+
</section>
272+
273+
<!-- /.usage -->
274+
275+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
276+
277+
<section class="notes">
278+
279+
</section>
280+
281+
<!-- /.notes -->
282+
283+
<!-- C API usage examples. -->
284+
285+
<section class="examples">
286+
287+
### Examples
288+
289+
```c
290+
#include "stdlib/stats/base/dcumax.h"
291+
#include <stdio.h>
292+
293+
int main( void ) {
294+
// Create strided arrays:
295+
const double x[] = { 1.0, 2.0, -3.0, 4.0, -5.0, 6.0, 7.0, 8.0 };
296+
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
297+
298+
// Specify the number of elements:
299+
const int N = 4;
300+
301+
// Specify stride lengths:
302+
const int strideX = 2;
303+
const int strideY = -2;
304+
305+
// Compute the cumulative maximum:
306+
stdlib_strided_dcumax( N, x, strideX, y, strideY );
307+
308+
// Print the result:
309+
for ( int i = 0; i < 8; i++ ) {
310+
printf( "y[ %d ] = %lf\n", i, y[ i ] );
311+
}
312+
}
313+
```
314+
315+
</section>
316+
317+
<!-- /.examples -->
318+
319+
</section>
320+
321+
<!-- /.c -->
322+
202323
<section class="references">
203324
204325
</section>

benchmark/benchmark.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@
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' );
2727
var Float64Array = require( '@stdlib/array-float64' );
2828
var pkg = require( './../package.json' ).name;
2929
var dcumax = require( './../lib/dcumax.js' );
3030

3131

32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'float64'
36+
};
37+
38+
3239
// FUNCTIONS //
3340

3441
/**
@@ -39,15 +46,8 @@ var dcumax = require( './../lib/dcumax.js' );
3946
* @returns {Function} benchmark function
4047
*/
4148
function createBenchmark( len ) {
42-
var y;
43-
var x;
44-
var i;
45-
46-
x = new Float64Array( len );
47-
y = new Float64Array( len );
48-
for ( i = 0; i < x.length; i++ ) {
49-
x[ i ] = ( randu()*20.0 ) - 10.0;
50-
}
49+
var x = uniform( len, -10.0, 10.0, options );
50+
var y = new Float64Array( len );
5151
return benchmark;
5252

5353
function benchmark( b ) {

benchmark/benchmark.native.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
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' );
2828
var Float64Array = require( '@stdlib/array-float64' );
@@ -36,6 +36,9 @@ var dcumax = tryRequire( resolve( __dirname, './../lib/dcumax.native.js' ) );
3636
var opts = {
3737
'skip': ( dcumax instanceof Error )
3838
};
39+
var options = {
40+
'dtype': 'float64'
41+
};
3942

4043

4144
// FUNCTIONS //
@@ -48,15 +51,8 @@ var opts = {
4851
* @returns {Function} benchmark function
4952
*/
5053
function createBenchmark( len ) {
51-
var x;
52-
var y;
53-
var i;
54-
55-
x = new Float64Array( len );
56-
y = new Float64Array( len );
57-
for ( i = 0; i < x.length; i++ ) {
58-
x[ i ] = ( randu()*20.0 ) - 10.0;
59-
}
54+
var x = uniform( len, -10.0, 10.0, options );
55+
var y = new Float64Array( len );
6056
return benchmark;
6157

6258
function benchmark( b ) {

benchmark/benchmark.ndarray.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@
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' );
2727
var Float64Array = require( '@stdlib/array-float64' );
2828
var pkg = require( './../package.json' ).name;
2929
var dcumax = require( './../lib/ndarray.js' );
3030

3131

32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'float64'
36+
};
37+
38+
3239
// FUNCTIONS //
3340

3441
/**
@@ -39,15 +46,8 @@ var dcumax = require( './../lib/ndarray.js' );
3946
* @returns {Function} benchmark function
4047
*/
4148
function createBenchmark( len ) {
42-
var x;
43-
var y;
44-
var i;
45-
46-
x = new Float64Array( len );
47-
y = new Float64Array( len );
48-
for ( i = 0; i < x.length; i++ ) {
49-
x[ i ] = ( randu()*20.0 ) - 10.0;
50-
}
49+
var x = uniform( len, -10.0, 10.0, options );
50+
var y = new Float64Array( len );
5151
return benchmark;
5252

5353
function benchmark( b ) {

benchmark/benchmark.ndarray.native.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
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' );
2828
var Float64Array = require( '@stdlib/array-float64' );
@@ -36,6 +36,9 @@ var dcumax = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
3636
var opts = {
3737
'skip': ( dcumax instanceof Error )
3838
};
39+
var options = {
40+
'dtype': 'float64'
41+
};
3942

4043

4144
// FUNCTIONS //
@@ -48,15 +51,8 @@ var opts = {
4851
* @returns {Function} benchmark function
4952
*/
5053
function createBenchmark( len ) {
51-
var x;
52-
var y;
53-
var i;
54-
55-
x = new Float64Array( len );
56-
y = new Float64Array( len );
57-
for ( i = 0; i < x.length; i++ ) {
58-
x[ i ] = ( randu()*20.0 ) - 10.0;
59-
}
54+
var x = uniform( len, -10.0, 10.0, options );
55+
var y = new Float64Array( len );
6056
return benchmark;
6157

6258
function benchmark( b ) {

0 commit comments

Comments
 (0)