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 Nov 11, 2024
1 parent 8691015 commit 1b07604
Show file tree
Hide file tree
Showing 26 changed files with 493 additions and 212 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
<section class="release" id="unreleased">

## Unreleased (2024-11-01)
## Unreleased (2024-11-11)

<section class="features">

### Features

- [`a341f85`](https://github.com/stdlib-js/stdlib/commit/a341f857ab541502a4e2b0b4b805c41e68e46fd6) - add C `ndarray` API and refactor `blas/ext/base/dsnannsumors` [(#3086)](https://github.com/stdlib-js/stdlib/pull/3086)

</section>

<!-- /.features -->

<section class="bug-fixes">

Expand All @@ -22,6 +32,7 @@

<details>

- [`a341f85`](https://github.com/stdlib-js/stdlib/commit/a341f857ab541502a4e2b0b4b805c41e68e46fd6) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dsnannsumors` [(#3086)](https://github.com/stdlib-js/stdlib/pull/3086) _(by Muhammad Haris)_
- [`e454c91`](https://github.com/stdlib-js/stdlib/commit/e454c91ae2af928b61effcddadb31548758f8675) - **chore:** improve code style and conditionals _(by Philipp Burckhardt)_
- [`898b50d`](https://github.com/stdlib-js/stdlib/commit/898b50d8d705bdf6a55db8cf1858ea1e1d257c35) - **fix:** fix includes and types _(by Philipp Burckhardt)_
- [`7cc8bb9`](https://github.com/stdlib-js/stdlib/commit/7cc8bb9a96147bb94fe8cfddc180a6ec535fc368) - **refactor:** update `blas/ext/base/dsnannsumors` _(by HarshaNP, Philipp Burckhardt)_
Expand All @@ -38,10 +49,11 @@

### Contributors

A total of 3 people contributed to this release. Thank you to the following contributors:
A total of 4 people contributed to this release. Thank you to the following contributors:

- Athan Reines
- HarshaNP
- Muhammad Haris
- Philipp Burckhardt

</section>
Expand Down
136 changes: 131 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ The function has the following parameters:

- **N**: number of indexed elements.
- **x**: input [`Float32Array`][@stdlib/array/float32].
- **strideX**: index increment for `x`.
- **strideX**: stride length for `x`.
- **out**: output [`Float64Array`][@stdlib/array/float64] whose first element is the sum and whose second element is the number of non-NaN elements.
- **strideOut**: index increment for `out`.
- **strideOut**: stride length for `out`.

The `N` and stride parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element in `x`,
The `N` and stride parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element:

```javascript
var Float32Array = require( '@stdlib/array-float32' );
Expand Down Expand Up @@ -125,7 +125,7 @@ var v = dsnannsumors( 4, x1, 2, out1, 1 );

#### dsnannsumors.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut )

Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics.
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics and returning an extended precision result.

```javascript
var Float32Array = require( '@stdlib/array-float32' );
Expand All @@ -143,7 +143,7 @@ The function has the following additional parameters:
- **offsetX**: starting index for `x`.
- **offsetOut**: starting index for `out`.

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 sum of every other value in `x` starting from the second value
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to calculate the sum of every other element starting from the second element:

```javascript
var Float32Array = require( '@stdlib/array-float32' );
Expand Down Expand Up @@ -204,6 +204,132 @@ console.log( out );

<!-- /.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/blas/ext/base/dsnannsumors.h"
```

#### stdlib_strided_dsnannsumors( N, \*X, strideX, \*n )

Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation, and returning an extended precision result.

```c
const float x[] = { 1.0f, -2.0f, 0.0/0.0, 2.0f };
CBLAS_INT n = 0;

double v = stdlib_strided_dsnannsumors( 4, x, 1, &n );
// returns 1.0
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] float*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **n**: `[out] CBLAS_INT*` number of non-NaN elements.
```c
double stdlib_strided_dsnannsumors( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, CBLAS_INT *n );
```

#### stdlib_strided_dsnannsumors_ndarray( N, \*X, strideX, offsetX, \*n )

Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics and returning an extended precision result.

```c
const float x[] = { 1.0f, -2.0f, 0.0/0.0, 2.0f };
CBLAS_INT n = 0;

double v = stdlib_strided_dsnannsumors_ndarray( 4, x, 1, 0, &n );
// returns 1.0
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] float*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
- **n**: `[out] CBLAS_INT*` number of non-NaN elements.
```c
double stdlib_strided_dsnannsumors_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n );
```

</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/blas/ext/base/dsnannsumors.h"
#include "stdlib/blas/base/shared.h"
#include <stdio.h>

int main( void ) {
// Create a strided array:
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 0.0/0.0, 0.0/0.0 };

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

// Specify the stride length:
const int strideX = 2;

// Initialize a variable for storing the number of non-NaN elements:
CBLAS_INT n = 0;

// Compute the sum:
double v = stdlib_strided_dsnannsumors( N, x, strideX, &n );

// Print the result:
printf( "sum: %lf\n", v );
printf( "n: %"CBLAS_IFMT"\n", n );
}
```
</section>
<!-- /.examples -->
</section>
<!-- /.c -->
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
<section class="related">
Expand Down
20 changes: 13 additions & 7 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ var dsnannsumors = require( './../lib/dsnannsumors.js' );

// FUNCTIONS //

/**
* Returns a random number.
*
* @private
* @returns {number} random number
*/
function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

/**
* Creates a benchmark function.
*
Expand All @@ -48,13 +61,6 @@ function createBenchmark( len ) {
out = new Float64Array( 2 );
return benchmark;

function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

function benchmark( b ) {
var i;

Expand Down
20 changes: 13 additions & 7 deletions benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ var opts = {

// FUNCTIONS //

/**
* Returns a random number.
*
* @private
* @returns {number} random number
*/
function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

/**
* Creates a benchmark function.
*
Expand All @@ -57,13 +70,6 @@ function createBenchmark( len ) {
out = new Float64Array( 2 );
return benchmark;

function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

function benchmark( b ) {
var i;

Expand Down
20 changes: 13 additions & 7 deletions benchmark/benchmark.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ var dsnannsumors = require( './../lib/ndarray.js' );

// FUNCTIONS //

/**
* Returns a random number.
*
* @private
* @returns {number} random number
*/
function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

/**
* Creates a benchmark function.
*
Expand All @@ -48,13 +61,6 @@ function createBenchmark( len ) {
out = new Float64Array( 2 );
return benchmark;

function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

function benchmark( b ) {
var i;

Expand Down
20 changes: 13 additions & 7 deletions benchmark/benchmark.ndarray.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ var opts = {

// FUNCTIONS //

/**
* Returns a random number.
*
* @private
* @returns {number} random number
*/
function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

/**
* Creates a benchmark function.
*
Expand All @@ -57,13 +70,6 @@ function createBenchmark( len ) {
out = new Float64Array( 2 );
return benchmark;

function rand() {
if ( bernoulli( 0.2 ) ) {
return NaN;
}
return uniform( -10.0, 10.0 );
}

function benchmark( b ) {
var i;

Expand Down
Loading

0 comments on commit 1b07604

Please sign in to comment.