Skip to content

Commit d095588

Browse files
committed
Auto-generated commit
1 parent 8320810 commit d095588

28 files changed

+373
-169
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
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 (2025-01-02)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`f78ae7b`](https://github.com/stdlib-js/stdlib/commit/f78ae7b4ed12879282a4e9c20e6c7b5baf2d6e39) - add C `ndarray` API and refactor `blas/ext/base/dssum` [(#4262)](https://github.com/stdlib-js/stdlib/pull/4262)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`f78ae7b`](https://github.com/stdlib-js/stdlib/commit/f78ae7b4ed12879282a4e9c20e6c7b5baf2d6e39) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dssum` [(#4262)](https://github.com/stdlib-js/stdlib/pull/4262) _(by Muhammad Haris)_
1526
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
1627
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
1728
- [`2777e4b`](https://github.com/stdlib-js/stdlib/commit/2777e4be161869d09406e3b17947d24c64b47af2) - **bench:** resolve lint errors in benchmarks _(by Athan Reines)_
@@ -26,9 +37,10 @@
2637

2738
### Contributors
2839

29-
A total of 2 people contributed to this release. Thank you to the following contributors:
40+
A total of 3 people contributed to this release. Thank you to the following contributors:
3041

3142
- Athan Reines
43+
- Muhammad Haris
3244
- Philipp Burckhardt
3345

3446
</section>

README.md

Lines changed: 129 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,26 @@ To view installation and usage instructions specific to each branch build, be su
6969
var dssum = require( '@stdlib/blas-ext-base-dssum' );
7070
```
7171

72-
#### dssum( N, x, stride )
72+
#### dssum( N, x, strideX )
7373

7474
Computes the sum of single-precision floating-point strided array elements using extended accumulation and returning an extended precision result.
7575

7676
```javascript
7777
var Float32Array = require( '@stdlib/array-float32' );
7878

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

82-
var v = dssum( N, x, 1 );
81+
var v = dssum( x.length, x, 1 );
8382
// returns 1.0
8483
```
8584

8685
The function has the following parameters:
8786

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

92-
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 the strided array,
91+
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:
9392

9493
```javascript
9594
var Float32Array = require( '@stdlib/array-float32' );
@@ -114,7 +113,7 @@ var v = dssum( 4, x1, 2 );
114113
// returns 5.0
115114
```
116115

117-
#### dssum.ndarray( N, x, stride, offset )
116+
#### dssum.ndarray( N, x, strideX, offsetX )
118117

119118
Computes the sum of single-precision floating-point strided array elements using extended accumulation and alternative indexing semantics and returning an extended precision result.
120119

@@ -129,9 +128,9 @@ var v = dssum.ndarray( 3, x, 1, 0 );
129128

130129
The function has the following additional parameters:
131130

132-
- **offset**: starting index for `x`.
131+
- **offsetX**: starting index for `x`.
133132

134-
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 the strided array starting from the second value
133+
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:
135134

136135
```javascript
137136
var Float32Array = require( '@stdlib/array-float32' );
@@ -164,11 +163,12 @@ var v = dssum.ndarray( 4, x, 2, 1 );
164163
<!-- eslint no-undef: "error" -->
165164

166165
```javascript
167-
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
168-
var filledarrayBy = require( '@stdlib/array-filled-by' );
166+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
169167
var dssum = require( '@stdlib/blas-ext-base-dssum' );
170168

171-
var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
169+
var x = discreteUniform( 10.0, -100, 100, {
170+
'dtype': 'float32'
171+
});
172172
console.log( x );
173173

174174
var v = dssum( x.length, x, 1 );
@@ -179,6 +179,123 @@ console.log( v );
179179

180180
<!-- /.examples -->
181181

182+
<!-- C interface documentation. -->
183+
184+
* * *
185+
186+
<section class="c">
187+
188+
## C APIs
189+
190+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
191+
192+
<section class="intro">
193+
194+
</section>
195+
196+
<!-- /.intro -->
197+
198+
<!-- C usage documentation. -->
199+
200+
<section class="usage">
201+
202+
### Usage
203+
204+
```c
205+
#include "stdlib/blas/ext/base/dssum.h"
206+
```
207+
208+
#### stdlib_strided_dssum( N, \*X, strideX )
209+
210+
Computes the sum of single-precision floating-point strided array elements using extended accumulation and returning an extended precision result.
211+
212+
```c
213+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
214+
215+
double v = stdlib_strided_dssum( 4, x, 1 );
216+
// returns 10.0
217+
```
218+
219+
The function accepts the following arguments:
220+
221+
- **N**: `[in] CBLAS_INT` number of indexed elements.
222+
- **X**: `[in] float*` input array.
223+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
224+
225+
```c
226+
double stdlib_strided_dssum( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
227+
```
228+
229+
#### stdlib_strided_dssum_ndarray( N, \*X, strideX, offsetX )
230+
231+
Computes the sum of single-precision floating-point strided array elements using extended accumulation and alternative indexing semantics and returning an extended precision result.
232+
233+
```c
234+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
235+
236+
double v = stdlib_strided_dssum_ndarray( 4, x, 1, 0 );
237+
// returns 10.0
238+
```
239+
240+
The function accepts the following arguments:
241+
242+
- **N**: `[in] CBLAS_INT` number of indexed elements.
243+
- **X**: `[in] float*` input array.
244+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
245+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
246+
247+
```c
248+
double stdlib_strided_dssum_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
249+
```
250+
251+
</section>
252+
253+
<!-- /.usage -->
254+
255+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
256+
257+
<section class="notes">
258+
259+
</section>
260+
261+
<!-- /.notes -->
262+
263+
<!-- C API usage examples. -->
264+
265+
<section class="examples">
266+
267+
### Examples
268+
269+
```c
270+
#include "stdlib/blas/ext/base/dssum.h"
271+
#include <stdio.h>
272+
273+
int main( void ) {
274+
// Create a strided array:
275+
const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
276+
277+
// Specify the number of elements:
278+
const int N = 5;
279+
280+
// Specify the stride length:
281+
const int strideX = 2;
282+
283+
// Compute the sum:
284+
double v = stdlib_strided_dssum( N, x, strideX );
285+
286+
// Print the result:
287+
printf( "sum: %lf\n", v );
288+
}
289+
```
290+
291+
</section>
292+
293+
<!-- /.examples -->
294+
295+
</section>
296+
297+
<!-- /.c -->
298+
182299
<section class="references">
183300
184301
</section>
@@ -228,7 +345,7 @@ See [LICENSE][stdlib-license].
228345
229346
## Copyright
230347
231-
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
348+
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
232349
233350
</section>
234351

benchmark/benchmark.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var uniform = require( '@stdlib/random-base-uniform' ).factory;
25-
var filledarrayBy = require( '@stdlib/array-filled-by' );
24+
var uniform = require( '@stdlib/random-array-uniform' );
2625
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2726
var pow = require( '@stdlib/math-base-special-pow' );
2827
var pkg = require( './../package.json' ).name;
@@ -31,7 +30,9 @@ var dssum = require( './../lib/dssum.js' );
3130

3231
// VARIABLES //
3332

34-
var rand = uniform( -10.0, 10.0 );
33+
var options = {
34+
'dtype': 'float32'
35+
};
3536

3637

3738
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 );
4445
* @returns {Function} benchmark function
4546
*/
4647
function createBenchmark( len ) {
47-
var x = filledarrayBy( len, 'float32', rand );
48+
var x = uniform( len, -100, 100, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

benchmark/benchmark.native.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
25-
var uniform = require( '@stdlib/random-base-uniform' ).factory;
26-
var filledarrayBy = require( '@stdlib/array-filled-by' );
25+
var uniform = require( '@stdlib/random-array-uniform' );
2726
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2827
var pow = require( '@stdlib/math-base-special-pow' );
2928
var tryRequire = require( '@stdlib/utils-try-require' );
@@ -36,7 +35,9 @@ var dssum = tryRequire( resolve( __dirname, './../lib/dssum.native.js' ) );
3635
var opts = {
3736
'skip': ( dssum instanceof Error )
3837
};
39-
var rand = uniform( -10.0, 10.0 );
38+
var options = {
39+
'dtype': 'float32'
40+
};
4041

4142

4243
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 );
4950
* @returns {Function} benchmark function
5051
*/
5152
function createBenchmark( len ) {
52-
var x = filledarrayBy( len, 'float32', rand );
53+
var x = uniform( len, -100, 100, options );
5354
return benchmark;
5455

5556
function benchmark( b ) {

benchmark/benchmark.ndarray.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var uniform = require( '@stdlib/random-base-uniform' ).factory;
25-
var filledarrayBy = require( '@stdlib/array-filled-by' );
24+
var uniform = require( '@stdlib/random-array-uniform' );
2625
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2726
var pow = require( '@stdlib/math-base-special-pow' );
2827
var pkg = require( './../package.json' ).name;
@@ -31,7 +30,9 @@ var dssum = require( './../lib/ndarray.js' );
3130

3231
// VARIABLES //
3332

34-
var rand = uniform( -10.0, 10.0 );
33+
var options = {
34+
'dtype': 'float32'
35+
};
3536

3637

3738
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -10.0, 10.0 );
4445
* @returns {Function} benchmark function
4546
*/
4647
function createBenchmark( len ) {
47-
var x = filledarrayBy( len, 'float32', rand );
48+
var x = uniform( len, -100, 100, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

benchmark/benchmark.ndarray.native.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
25-
var uniform = require( '@stdlib/random-base-uniform' ).factory;
26-
var filledarrayBy = require( '@stdlib/array-filled-by' );
25+
var uniform = require( '@stdlib/random-array-uniform' );
2726
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2827
var pow = require( '@stdlib/math-base-special-pow' );
2928
var tryRequire = require( '@stdlib/utils-try-require' );
@@ -36,7 +35,9 @@ var dssum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
3635
var opts = {
3736
'skip': ( dssum instanceof Error )
3837
};
39-
var rand = uniform( -10.0, 10.0 );
38+
var options = {
39+
'dtype': 'float32'
40+
};
4041

4142

4243
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -10.0, 10.0 );
4950
* @returns {Function} benchmark function
5051
*/
5152
function createBenchmark( len ) {
52-
var x = filledarrayBy( len, 'float32', rand );
53+
var x = uniform( len, -100, 100, options );
5354
return benchmark;
5455

5556
function benchmark( b ) {

0 commit comments

Comments
 (0)