Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jan 2, 2025
1 parent d506f4c commit d345b96
Show file tree
Hide file tree
Showing 26 changed files with 395 additions and 282 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@
<section class="release" id="unreleased">

## Unreleased (2024-12-23)
## Unreleased (2025-01-02)

<section class="features">

### Features

- [`a510d78`](https://github.com/stdlib-js/stdlib/commit/a510d781f292a698c2c51afda15405795363324c) - add C ndarray interface and refactor implementation for `stats/base/dcuminabs` [(#4156)](https://github.com/stdlib-js/stdlib/pull/4156)

</section>

<!-- /.features -->

<section class="commits">

### Commits

<details>

- [`a510d78`](https://github.com/stdlib-js/stdlib/commit/a510d781f292a698c2c51afda15405795363324c) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dcuminabs` [(#4156)](https://github.com/stdlib-js/stdlib/pull/4156) _(by Aayush Khanna)_
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
- [`c13062e`](https://github.com/stdlib-js/stdlib/commit/c13062e5b90cbe28ec62f0b690211bd14b626cf3) - **style:** update to use tabs for indentation _(by Philipp Burckhardt)_
- [`2cbb06c`](https://github.com/stdlib-js/stdlib/commit/2cbb06c836012da88b028b373948705de9ccd970) - **refactor:** update `stats/base/dcuminabs` native addon from C++ to C [(#4075)](https://github.com/stdlib-js/stdlib/pull/4075) _(by Aayush Khanna)_
Expand Down
153 changes: 137 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ The function has the following parameters:

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

The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative minimum absolute value of every other element in `x`,
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative minimum absolute value of every other element in `x`,

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

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 minimum absolute value 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
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 minimum absolute value 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

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

```javascript
var randu = require( '@stdlib/random-base-randu' );
var round = require( '@stdlib/math-base-special-round' );
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
var Float64Array = require( '@stdlib/array-float64' );
var dcuminabs = require( '@stdlib/stats-base-dcuminabs' );

var y;
var x;
var i;

x = new Float64Array( 10 );
y = new Float64Array( x.length );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( (randu()*100.0) - 50.0 );
}
var x = discreteUniform( 10, -50, 50, {
'dtype': 'float64'
});
console.log( x );

var y = new Float64Array( x.length );
console.log( y );

dcuminabs( x.length, x, 1, y, -1 );
Expand All @@ -199,6 +194,132 @@ console.log( y );

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/stats/base/dcuminabs.h"
```

#### stdlib_strided_dcuminabs( N, \*X, strideX, \*Y, strideY )

Computes the cumulative minumum absolute value of double-precision floating-point strided array elements.

```c
const double x[] = { 1.0, 2.0, -3.0, 4.0, -5.0, 6.0, 7.0, 8.0 };
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

stdlib_strided_dcuminabs( 4, x, 2, y, -2 );
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **Y**: `[out] double*` output array.
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
```c
void stdlib_strided_dcuminabs( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );
```

#### stdlib_strided_dcuminabs_ndarray(N, \*X, strideX, offsetX, \*Y, strideY, offsetY)

Computes the cumulative minumum absolute value of double-precision floating-point strided array elements using alternative indexing semantics.

```c
const double x[] = { 1.0, 2.0, -3.0, 4.0, -5.0, 6.0, 7.0, 8.0 };
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

stdlib_strided_dcuminabs_ndarray( 4, x, 2, 0, y, -2, 0 );
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
- **Y**: `[out] double*` output array.
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
```c
void stdlib_strided_dcuminabs_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 );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/stats/base/dcuminabs.h"
#include <stdio.h>

int main( void ) {
// Create strided arrays:
const double x[] = { 1.0, 2.0, -3.0, 4.0, -5.0, 6.0, 7.0, 8.0 };
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

// Specify the number of elements:
const int N = 4;

// Specify stride lengths:
const int strideX = 2;
const int strideY = -2;

// Compute the cumulative minumum absolute value:
stdlib_strided_dcuminabs( N, x, strideX, y, strideY );

// Print the result:
for ( int i = 0; i < 8; i++ ) {
printf( "y[ %d ] = %lf\n", i, y[ i ] );
}
}
```
</section>
<!-- /.examples -->
</section>
<!-- /.c -->
<section class="references">
</section>
Expand Down Expand Up @@ -248,7 +369,7 @@ See [LICENSE][stdlib-license].
## Copyright
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
</section>
Expand Down
20 changes: 10 additions & 10 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@
// MODULES //

var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-array-uniform' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var pkg = require( './../package.json' ).name;
var dcuminabs = require( './../lib/dcuminabs.js' );


// VARIABLES //

var options = {
'dtype': 'float64'
};


// FUNCTIONS //

/**
Expand All @@ -39,15 +46,8 @@ var dcuminabs = require( './../lib/dcuminabs.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var y;
var x;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = uniform( len, -10.0, 10.0, options );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
16 changes: 6 additions & 10 deletions benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-array-uniform' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
Expand All @@ -36,6 +36,9 @@ var dcuminabs = tryRequire( resolve( __dirname, './../lib/dcuminabs.native.js' )
var opts = {
'skip': ( dcuminabs instanceof Error )
};
var options = {
'dtype': 'float64'
};


// FUNCTIONS //
Expand All @@ -48,15 +51,8 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = uniform( len, -10.0, 10.0, options );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
20 changes: 10 additions & 10 deletions benchmark/benchmark.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@
// MODULES //

var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-array-uniform' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var pkg = require( './../package.json' ).name;
var dcuminabs = require( './../lib/ndarray.js' );


// VARIABLES //

var options = {
'dtype': 'float64'
};


// FUNCTIONS //

/**
Expand All @@ -39,15 +46,8 @@ var dcuminabs = require( './../lib/ndarray.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = uniform( len, -10.0, 10.0, options );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
16 changes: 6 additions & 10 deletions benchmark/benchmark.ndarray.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench-harness' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-array-uniform' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
Expand All @@ -36,6 +36,9 @@ var dcuminabs = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) )
var opts = {
'skip': ( dcuminabs instanceof Error )
};
var options = {
'dtype': 'float64'
};


// FUNCTIONS //
Expand All @@ -48,15 +51,8 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20.0 ) - 10.0;
}
var x = uniform( len, -10.0, 10.0, options );
var y = new Float64Array( len );
return benchmark;

function benchmark( b ) {
Expand Down
Loading

0 comments on commit d345b96

Please sign in to comment.