Skip to content

Commit c14abf8

Browse files
committed
Auto-generated commit
1 parent 1219200 commit c14abf8

30 files changed

+407
-229
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ indent_style = tab
8686
[*.{f,f.txt}]
8787
indent_style = space
8888
indent_size = 2
89-
insert_final_newline = false
9089

9190
# Set properties for shell files:
9291
[*.{sh,sh.txt}]

CHANGELOG.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-12-23)
7+
## Unreleased (2025-01-18)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`04950f3`](https://github.com/stdlib-js/stdlib/commit/04950f32082d53f9dc2fa114c3885a69c02e3246) - add C `ndarray` API and refactor `blas/ext/base/sapxsumkbn2` [(#4730)](https://github.com/stdlib-js/stdlib/pull/4730)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="bug-fixes">
1020

@@ -23,6 +33,7 @@
2333

2434
<details>
2535

36+
- [`04950f3`](https://github.com/stdlib-js/stdlib/commit/04950f32082d53f9dc2fa114c3885a69c02e3246) - **feat:** add C `ndarray` API and refactor `blas/ext/base/sapxsumkbn2` [(#4730)](https://github.com/stdlib-js/stdlib/pull/4730) _(by Muhammad Haris, Athan Reines)_
2637
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
2738
- [`2ea848b`](https://github.com/stdlib-js/stdlib/commit/2ea848b62b686e1e9d861f7df25ece23a7d80798) - **style:** update to use tabs for indentation _(by Philipp Burckhardt)_
2839
- [`2222d50`](https://github.com/stdlib-js/stdlib/commit/2222d505c97a6c4f8acf89bdb3aae6f504589e04) - **fix:** update include path and refactor addon _(by Athan Reines)_
@@ -42,9 +53,10 @@
4253

4354
### Contributors
4455

45-
A total of 2 people contributed to this release. Thank you to the following contributors:
56+
A total of 3 people contributed to this release. Thank you to the following contributors:
4657

4758
- Athan Reines
59+
- Muhammad Haris
4860
- Philipp Burckhardt
4961

5062
</section>

CONTRIBUTORS

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Daniel Killenberger <daniel.killenberger@gmail.com>
2727
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
2828
Debashis Maharana <debashismaharana7854@gmail.com>
2929
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
30+
Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
3031
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
3132
Dominic Lim <46486515+domlimm@users.noreply.github.com>
3233
Dominik Moritz <domoritz@gmail.com>
@@ -49,6 +50,7 @@ Joey Reed <joeyrreed@gmail.com>
4950
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
5051
Joris Labie <joris.labie1@gmail.com>
5152
Justin Dennison <justin1dennison@gmail.com>
53+
Karan Anand <119553199+anandkaranubc@users.noreply.github.com>
5254
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
5355
Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
5456
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
@@ -117,7 +119,7 @@ UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
117119
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
118120
Varad Gupta <varadgupta21@gmail.com>
119121
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
120-
Vivek maurya <155618190+vivekmaurya001@users.noreply.github.com>
122+
Vivek Maurya <vm8118134@gmail.com>
121123
Xiaochuan Ye <tap91624@gmail.com>
122124
Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
123125
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>

NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copyright (c) 2016-2024 The Stdlib Authors.
1+
Copyright (c) 2016-2025 The Stdlib Authors.

README.md

+133-17
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ limitations under the License.
3333

3434
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
3535

36-
> Add a constant to each single-precision floating-point strided array element and compute the sum using a second-order iterative Kahan–Babuška algorithm.
36+
> Add a scalar constant to each single-precision floating-point strided array element and compute the sum using a second-order iterative Kahan–Babuška algorithm.
3737
3838
<section class="intro">
3939

@@ -69,27 +69,26 @@ To view installation and usage instructions specific to each branch build, be su
6969
var sapxsumkbn2 = require( '@stdlib/blas-ext-base-sapxsumkbn2' );
7070
```
7171

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

74-
Adds a constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm.
74+
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm.
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 = sapxsumkbn2( N, 5.0, x, 1 );
81+
var v = sapxsumkbn2( x.length, 5.0, x, 1 );
8382
// returns 16.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.
9190

92-
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element in `x`,
91+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element:
9392

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

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

119-
Adds a constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
118+
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
120119

121120
```javascript
122121
var Float32Array = require( '@stdlib/array-float32' );
123122

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

127-
var v = sapxsumkbn2.ndarray( N, 5.0, x, 1, 0 );
125+
var v = sapxsumkbn2.ndarray( x.length, 5.0, x, 1, 0 );
128126
// returns 16.0
129127
```
130128

131129
The function has the following additional parameters:
132130

133-
- **offset**: starting index for `x`.
131+
- **offsetX**: starting index.
134132

135-
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 access every other value in `x` 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 access every other element starting from the second element:
136134

137135
```javascript
138136
var Float32Array = require( '@stdlib/array-float32' );
@@ -164,11 +162,12 @@ var v = sapxsumkbn2.ndarray( 4, 5.0, x, 2, 1 );
164162
<!-- eslint no-undef: "error" -->
165163

166164
```javascript
167-
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
168-
var filledarrayBy = require( '@stdlib/array-filled-by' );
165+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
169166
var sapxsumkbn2 = require( '@stdlib/blas-ext-base-sapxsumkbn2' );
170167

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

174173
var v = sapxsumkbn2( x.length, 5.0, x, 1 );
@@ -179,8 +178,125 @@ console.log( v );
179178

180179
<!-- /.examples -->
181180

181+
<!-- C interface documentation. -->
182+
182183
* * *
183184

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

benchmark/benchmark.js

+5-4
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 sapxsumkbn2 = require( './../lib/sapxsumkbn2.js' );
3130

3231
// VARIABLES //
3332

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

3637

3738
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.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

+5-4
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 sapxsumkbn2 = tryRequire( resolve( __dirname, './../lib/sapxsumkbn2.native.j
3635
var opts = {
3736
'skip': ( sapxsumkbn2 instanceof Error )
3837
};
39-
var rand = uniform( -100.0, 100.0 );
38+
var options = {
39+
'dtype': 'float32'
40+
};
4041

4142

4243
// FUNCTIONS //
@@ -49,7 +50,7 @@ var rand = uniform( -100.0, 100.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

+5-4
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 sapxsumkbn2 = require( './../lib/ndarray.js' );
3130

3231
// VARIABLES //
3332

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

3637

3738
// FUNCTIONS //
@@ -44,7 +45,7 @@ var rand = uniform( -100.0, 100.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 ) {

0 commit comments

Comments
 (0)