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 18, 2024
1 parent 1b07604 commit 3ff9729
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 55 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-11-11)
## Unreleased (2024-11-18)

<section class="features">

Expand Down Expand Up @@ -32,6 +32,7 @@

<details>

- [`22b7505`](https://github.com/stdlib-js/stdlib/commit/22b75056694840ce79b3493940e442672bab96c6) - **refactor:** update `offset` handling and function documentation for `blas/ext/base/dsnannsumors` [(#3129)](https://github.com/stdlib-js/stdlib/pull/3129) _(by Muhammad Haris, stdlib-bot)_
- [`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)_
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Mohammad Kaif <[email protected]>
Momtchil Momtchev <[email protected]>
Muhammad Haris <[email protected]>
Naresh Jagadeesan <[email protected]>
Neeraj Pathak <[email protected]>
NightKnight <[email protected]>
Nithin Katta <[email protected]>
Nourhan Hasan <[email protected]>
Expand All @@ -69,6 +70,7 @@ Prajwal Kulkarni <[email protected]>
Pranav Goswami <[email protected]>
Praneki <[email protected]>
Pratik <[email protected]>
Pratyush Kumar Chouhan <[email protected]>
Priyansh <[email protected]>
Pushpendra Chandravanshi <[email protected]>
RISHAV <[email protected]>
Expand All @@ -79,6 +81,7 @@ Ridam Garg <[email protected]>
Robert Gislason <[email protected]>
Roman Stetsyk <[email protected]>
Rutam <[email protected]>
Ruthwik Chikoti <[email protected]>
Ryan Seal <[email protected]>
Sai Srikar Dumpeti <[email protected]>
SarthakPaandey <[email protected]>
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
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 and returning an extended precision result.
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, 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 Down Expand Up @@ -235,7 +235,7 @@ console.log( out );
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 };
const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
CBLAS_INT n = 0;

double v = stdlib_strided_dsnannsumors( 4, x, 1, &n );
Expand All @@ -247,18 +247,18 @@ 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.
- **n**: `[out] CBLAS_INT*` pointer for storing the 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.
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, 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 };
const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
CBLAS_INT n = 0;

double v = stdlib_strided_dsnannsumors_ndarray( 4, x, 1, 0, &n );
Expand All @@ -271,7 +271,7 @@ The function accepts the following arguments:
- **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.
- **n**: `[out] CBLAS_INT*` pointer for storing the 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 );
Expand Down Expand Up @@ -302,7 +302,7 @@ double stdlib_strided_dsnannsumors_ndarray( const CBLAS_INT N, const float *X, c

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 };
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 0.0f/0.0f, 0.0f/0.0f };

// Specify the number of elements:
const int N = 5;
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@

{{alias}}.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 and returning an extended
ignoring `NaN` values, using ordinary recursive summation with extended
accumulation and alternative indexing semantics, and returning an extended
precision result.

While typed array views mandate a view offset based on the underlying
Expand Down
2 changes: 1 addition & 1 deletion examples/c/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

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 };
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 0.0f/0.0f, 0.0f/0.0f };

// Specify the number of elements:
const int N = 5;
Expand Down
2 changes: 1 addition & 1 deletion include/stdlib/blas/ext/base/dsnannsumors.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
double API_SUFFIX(stdlib_strided_dsnannsumors)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, CBLAS_INT *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.
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
*/
double API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n );

Expand Down
6 changes: 1 addition & 5 deletions lib/dsnannsumors.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ function dsnannsumors( N, x, strideX, out, strideOut ) {
var io;

ix = stride2offset( N, strideX );
if ( strideOut < 0 ) {
io = -strideOut;
} else {
io = 0;
}
io = stride2offset( 2, strideOut );
return ndarray( N, x, strideX, ix, out, strideOut, io );
}

Expand Down
18 changes: 8 additions & 10 deletions lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,24 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
function dsnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
var sum;
var ix;
var io;
var n;
var i;

sum = 0.0;
io = offsetOut;
if ( N <= 0 ) {
out[ io ] = sum;
out[ io+strideOut ] = 0;
out[ offsetOut ] = sum;
out[ offsetOut+strideOut ] = 0;
return out;
}
ix = offsetX;
if ( strideX === 0 ) {
if ( isnan( x[ ix ] ) ) {
out[ io ] = sum;
out[ io+strideOut ] = 0;
out[ offsetOut ] = sum;
out[ offsetOut+strideOut ] = 0;
return out;
}
out[ io ] = x[ ix ] * N;
out[ io+strideOut ] = N;
out[ offsetOut ] = x[ ix ] * N;
out[ offsetOut+strideOut ] = N;
return out;
}
n = 0;
Expand All @@ -80,8 +78,8 @@ function dsnannsumors( N, x, strideX, offsetX, out, strideOut, offsetOut ) {
}
ix += strideX;
}
out[ io ] = sum;
out[ io+strideOut ] = n;
out[ offsetOut ] = sum;
out[ offsetOut+strideOut ] = n;
return out;
}

Expand Down
21 changes: 7 additions & 14 deletions src/addon.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "stdlib/napi/argv_int64.h"
#include "stdlib/napi/argv_strided_float32array.h"
#include "stdlib/napi/argv_strided_float64array.h"
#include "stdlib/strided/base/stride2offset.h"
#include <stdint.h>
#include <node_api.h>

/**
Expand All @@ -41,17 +43,10 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 3 );

int io;
if ( strideOut < 0 ) {
io = -strideOut;
} else {
io = 0;
}

double *out = Out;
int64_t io = stdlib_strided_stride2offset( 2, strideOut );
CBLAS_INT n;
out[ io ] = API_SUFFIX(stdlib_strided_dsnannsumors)( N, X, strideX, &n );
out[ io + strideOut ] = (double)n;
Out[ io ] = API_SUFFIX(stdlib_strided_dsnannsumors)( N, X, strideX, &n );
Out[ io + strideOut ] = (double)n;

return NULL;
}
Expand All @@ -74,11 +69,9 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 4 );

int io = offsetOut;
double *out = Out;
CBLAS_INT n;
out[ io ] = API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( N, X, strideX, offsetX, &n );
out[ io + strideOut ] = (double)n;
Out[ offsetOut ] = API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( N, X, strideX, offsetX, &n );
Out[ offsetOut + strideOut ] = (double)n;

return NULL;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @param N number of indexed elements
* @param X input array
* @param strideX stride length
* @param n number of non-NaN elements
* @param n pointer for storing the number of non-NaN elements
* @return output value
*/
double API_SUFFIX(stdlib_strided_dsnannsumors)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, CBLAS_INT *n ) {
Expand All @@ -36,19 +36,19 @@ double API_SUFFIX(stdlib_strided_dsnannsumors)( const CBLAS_INT N, const float *
}

/**
* 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.
* Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values, using ordinary recursive summation with extended accumulation and alternative indexing semantics, and returning an extended precision result.
*
* @param N number of indexed elements
* @param X input array
* @param strideX stride length
* @param offsetX starting index
* @param n number of non-NaN elements
* @param n pointer for storing the number of non-NaN elements
* @return output value
*/
double API_SUFFIX(stdlib_strided_dsnannsumors_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n ) {
double sum;
CBLAS_INT ix;
CBLAS_INT i;
double sum;

sum = 0.0;
*n = 0;
Expand Down

0 comments on commit 3ff9729

Please sign in to comment.