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 Dec 13, 2024
1 parent 855ce90 commit dcf5cd4
Show file tree
Hide file tree
Showing 24 changed files with 340 additions and 153 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,28 @@ This release closes the following issue:

<!-- /.package -->

<section class="package" id="blas-ext-base-ssumors-unreleased">

#### [@stdlib/blas/ext/base/ssumors](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/ext/base/ssumors)

<details>

<section class="features">

##### Features

- [`1f596cb`](https://github.com/stdlib-js/stdlib/commit/1f596cb9bd3a26c2a7a82ab578d460f88df8dea5) - add C `ndarray` API and refactor `blas/ext/base/ssumors` [(#3891)](https://github.com/stdlib-js/stdlib/pull/3891)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="blas-ext-base-ssumpw-unreleased">

#### [@stdlib/blas/ext/base/ssumpw](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/ext/base/ssumpw)
Expand Down Expand Up @@ -1135,6 +1157,7 @@ A total of 8 people contributed to this release. Thank you to the following cont

<details>

- [`1f596cb`](https://github.com/stdlib-js/stdlib/commit/1f596cb9bd3a26c2a7a82ab578d460f88df8dea5) - **feat:** add C `ndarray` API and refactor `blas/ext/base/ssumors` [(#3891)](https://github.com/stdlib-js/stdlib/pull/3891) _(by Snehil Shah)_
- [`5cb36ef`](https://github.com/stdlib-js/stdlib/commit/5cb36ef4c6f8158585ac88867a8dec21ed3fa372) - **docs:** update related packages sections [(#3890)](https://github.com/stdlib-js/stdlib/pull/3890) _(by stdlib-bot)_
- [`a04a9e3`](https://github.com/stdlib-js/stdlib/commit/a04a9e31780bfb285f51dba041da0c07b905a30d) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dssumpw` [(#3528)](https://github.com/stdlib-js/stdlib/pull/3528) _(by Muhammad Haris, Athan Reines)_
- [`5a3d324`](https://github.com/stdlib-js/stdlib/commit/5a3d324e7e80752fad34d120df3e6c85636f20c5) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dssumors` [(#3396)](https://github.com/stdlib-js/stdlib/pull/3396) _(by Muhammad Haris, Athan Reines)_
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ UtkershBasnet <[email protected]>
Vaibhav Patel <[email protected]>
Varad Gupta <[email protected]>
Vinit Pandit <[email protected]>
Vivek maurya <[email protected]>
Xiaochuan Ye <[email protected]>
Yaswanth Kosuru <[email protected]>
Yernar Yergaziyev <[email protected]>
Expand Down
135 changes: 125 additions & 10 deletions ext/base/ssumors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,26 @@ limitations under the License.
var ssumors = require( '@stdlib/blas/ext/base/ssumors' );
```

#### ssumors( N, x, stride )
#### ssumors( N, x, strideX )

Computes the sum of single-precision floating-point strided array elements using ordinary recursive summation.

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

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

var v = ssumors( N, x, 1 );
var v = ssumors( x.length, x, 1 );
// returns 1.0
```

The function has the following parameters:

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

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

```javascript
var Float32Array = require( '@stdlib/array/float32' );
Expand All @@ -81,25 +80,24 @@ var v = ssumors( 4, x1, 2 );
// returns 5.0
```

#### ssumors.ndarray( N, x, stride, offset )
#### ssumors.ndarray( N, x, strideX, offsetX )

Computes the sum of single-precision floating-point strided array elements using ordinary recursive summation and alternative indexing semantics.

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

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

var v = ssumors.ndarray( N, x, 1, 0 );
var v = ssumors.ndarray( x.length, x, 1, 0 );
// returns 1.0
```

The function has the following additional parameters:

- **offset**: starting index for `x`.
- **offsetX**: starting index for `x`.

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 parameter supports indexing semantics based on a starting index. 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 @@ -147,6 +145,123 @@ console.log( v );

<!-- /.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/ssumors.h"
```

#### stdlib_strided_ssumors( N, \*X, strideX )

Computes the sum of single-precision floating-point strided array elements using ordinary recursive summation.

```c
const float x[] = { 1.0f, -2.0f, 2.0f };

float v = stdlib_strided_ssumors( 3, x, 1 );
// returns 1.0f
```
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`.
```c
float stdlib_strided_ssumors( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
```

#### stdlib_strided_ssumors_ndarray( N, \*X, strideX, offsetX )

Computes the sum of single-precision floating-point strided array elements using ordinary recursive summation and alternative indexing semantics.

```c
const float x[] = { 1.0f, -2.0f, 2.0f };

float v = stdlib_strided_ssumors_ndarray( 3, x, 1, 0 );
// returns 1.0f
```
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`.
```c
float stdlib_strided_ssumors_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</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/ssumors.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 };

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

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

// Compute the sum:
float v = stdlib_strided_ssumors( N, x, strideX );

// Print the result:
printf( "sum: %f\n", v );
}
```
</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
9 changes: 5 additions & 4 deletions ext/base/ssumors/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
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 pkg = require( './../package.json' ).name;
Expand All @@ -31,7 +30,9 @@ var ssumors = require( './../lib/ssumors.js' );

// VARIABLES //

var rand = uniform( -100.0, 100.0 );
var options = {
'dtype': 'float32'
};


// FUNCTIONS //
Expand All @@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = filledarrayBy( len, 'float32', rand );
var x = uniform( len, -100, 100, options );
return benchmark;

function benchmark( b ) {
Expand Down
9 changes: 5 additions & 4 deletions ext/base/ssumors/benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
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 tryRequire = require( '@stdlib/utils/try-require' );
Expand All @@ -36,7 +35,9 @@ var ssumors = tryRequire( resolve( __dirname, './../lib/ssumors.native.js' ) );
var opts = {
'skip': ( ssumors instanceof Error )
};
var rand = uniform( -100.0, 100.0 );
var options = {
'dtype': 'float32'
};


// FUNCTIONS //
Expand All @@ -49,7 +50,7 @@ var rand = uniform( -100.0, 100.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = filledarrayBy( len, 'float32', rand );
var x = uniform( len, -100, 100, options );
return benchmark;

function benchmark( b ) {
Expand Down
9 changes: 5 additions & 4 deletions ext/base/ssumors/benchmark/benchmark.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
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 pkg = require( './../package.json' ).name;
Expand All @@ -31,7 +30,9 @@ var ssumors = require( './../lib/ndarray.js' );

// VARIABLES //

var rand = uniform( -100.0, 100.0 );
var options = {
'dtype': 'float32'
};


// FUNCTIONS //
Expand All @@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = filledarrayBy( len, 'float32', rand );
var x = uniform( len, -100, 100, options );
return benchmark;

function benchmark( b ) {
Expand Down
9 changes: 5 additions & 4 deletions ext/base/ssumors/benchmark/benchmark.ndarray.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
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 tryRequire = require( '@stdlib/utils/try-require' );
Expand All @@ -36,7 +35,9 @@ var ssumors = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( ssumors instanceof Error )
};
var rand = uniform( -100.0, 100.0 );
var options = {
'dtype': 'float32'
};


// FUNCTIONS //
Expand All @@ -49,7 +50,7 @@ var rand = uniform( -100.0, 100.0 );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = filledarrayBy( len, 'float32', rand );
var x = uniform( len, -100, 100, options );
return benchmark;

function benchmark( b ) {
Expand Down
Loading

0 comments on commit dcf5cd4

Please sign in to comment.