Skip to content

Commit 1071a0f

Browse files
committed
Auto-generated commit
1 parent 194c1ff commit 1071a0f

24 files changed

+402
-232
lines changed

CHANGELOG.md

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

7-
## Unreleased (2024-09-21)
7+
## Unreleased (2024-09-22)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`a187bfc`](https://github.com/stdlib-js/stdlib/commit/a187bfc1f71912625823d786f7b1234b224b323d) - add C `ndarray` API and refactor `blas/ext/base/dapx` [(#2929)](https://github.com/stdlib-js/stdlib/pull/2929)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

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

@@ -22,6 +32,7 @@
2232

2333
<details>
2434

35+
- [`a187bfc`](https://github.com/stdlib-js/stdlib/commit/a187bfc1f71912625823d786f7b1234b224b323d) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dapx` [(#2929)](https://github.com/stdlib-js/stdlib/pull/2929) _(by Muhammad Haris, Athan Reines)_
2536
- [`e4de24f`](https://github.com/stdlib-js/stdlib/commit/e4de24f1e086063876214e73f1f6b659dc624eb1) - **fix:** resolve bugs in addon.c files _(by Philipp Burckhardt)_
2637
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
2738
- [`2777e4b`](https://github.com/stdlib-js/stdlib/commit/2777e4be161869d09406e3b17947d24c64b47af2) - **bench:** resolve lint errors in benchmarks _(by Athan Reines)_
@@ -36,9 +47,10 @@
3647

3748
### Contributors
3849

39-
A total of 2 people contributed to this release. Thank you to the following contributors:
50+
A total of 3 people contributed to this release. Thank you to the following contributors:
4051

4152
- Athan Reines
53+
- Muhammad Haris
4254
- Philipp Burckhardt
4355

4456
</section>

README.md

Lines changed: 132 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ To view installation and usage instructions specific to each branch build, be su
6363
var dapx = require( '@stdlib/blas-ext-base-dapx' );
6464
```
6565

66-
#### dapx( N, alpha, x, stride )
66+
#### dapx( N, alpha, x, strideX )
6767

68-
Adds a constant `alpha` to each element in a double-precision floating-point strided array.
68+
Adds a scalar constant `alpha` to each element in a double-precision floating-point strided array.
6969

7070
```javascript
7171
var Float64Array = require( '@stdlib/array-float64' );
@@ -81,9 +81,9 @@ The function has the following parameters:
8181
- **N**: number of indexed elements.
8282
- **alpha**: scalar constant.
8383
- **x**: input [`Float64Array`][@stdlib/array/float64].
84-
- **stride**: index increment.
84+
- **strideX**: index increment.
8585

86-
The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element
86+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element
8787

8888
```javascript
8989
var Float64Array = require( '@stdlib/array-float64' );
@@ -110,9 +110,9 @@ dapx( 3, 5.0, x1, 2 );
110110
// x0 => <Float64Array>[ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ]
111111
```
112112

113-
#### dapx.ndarray( N, alpha, x, stride, offset )
113+
#### dapx.ndarray( N, alpha, x, strideX, offsetX )
114114

115-
Adds a constant `alpha` to each element in a double-precision floating-point strided array using alternative indexing semantics.
115+
Adds a scalar constant `alpha` to each element in a double-precision floating-point strided array using alternative indexing semantics.
116116

117117
```javascript
118118
var Float64Array = require( '@stdlib/array-float64' );
@@ -125,9 +125,9 @@ dapx.ndarray( x.length, 5.0, x, 1, 0 );
125125

126126
The function has the following additional parameters:
127127

128-
- **offset**: starting index.
128+
- **offsetX**: starting index.
129129

130-
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 only the last three elements of the strided array
130+
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 only the last three elements of the strided array
131131

132132
```javascript
133133
var Float64Array = require( '@stdlib/array-float64' );
@@ -159,11 +159,12 @@ dapx.ndarray( 3, 5.0, x, 1, x.length-3 );
159159
<!-- eslint no-undef: "error" -->
160160

161161
```javascript
162-
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
163-
var filledarrayBy = require( '@stdlib/array-filled-by' );
162+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
164163
var dapx = require( '@stdlib/blas-ext-base-dapx' );
165164

166-
var x = filledarrayBy( 10, 'float64', discreteUniform( -100, 100 ) );
165+
var x = discreteUniform( 10, -100, 100, {
166+
'dtype': 'float64'
167+
});
167168
console.log( x );
168169

169170
dapx( x.length, 5.0, x, 1 );
@@ -174,6 +175,126 @@ console.log( x );
174175

175176
<!-- /.examples -->
176177

178+
<!-- C interface documentation. -->
179+
180+
* * *
181+
182+
<section class="c">
183+
184+
## C APIs
185+
186+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
187+
188+
<section class="intro">
189+
190+
</section>
191+
192+
<!-- /.intro -->
193+
194+
<!-- C usage documentation. -->
195+
196+
<section class="usage">
197+
198+
### Usage
199+
200+
```c
201+
#include "stdlib/blas/ext/base/dapx.h"
202+
```
203+
204+
#### c_dapx( N, alpha, \*X, strideX )
205+
206+
Adds a scalar constant `alpha` to each element in a double-precision floating-point strided array.
207+
208+
```c
209+
double x[] = { 1.0, 2.0, 3.0, 4.0 };
210+
211+
c_dapx( 4, 5.0, x, 1 );
212+
213+
```
214+
215+
The function accepts the following arguments:
216+
217+
- **N**: `[in] CBLAS_INT` number of indexed elements.
218+
- **alpha**: `[in] double` scalar constant.
219+
- **X**: `[inout] double*` input array.
220+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
221+
222+
```c
223+
void c_dapx( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX );
224+
```
225+
226+
#### c_dapx_ndarray( N, alpha, \*X, strideX, offsetX )
227+
228+
Adds a scalar constant `alpha` to each element in a double-precision floating-point strided array `X` using alternative indexing semantics.
229+
230+
```c
231+
double x[] = { 1.0, 2.0, 3.0, 4.0 };
232+
233+
c_dapx_ndarray( 4, 5.0, x, 1, 0 );
234+
```
235+
236+
The function accepts the following arguments:
237+
238+
- **N**: `[in] CBLAS_INT` number of indexed elements.
239+
- **alpha**: `[in] double` scalar constant.
240+
- **X**: `[inout] double*` input array.
241+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
242+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
243+
244+
```c
245+
void c_dapx_ndarray( const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
246+
```
247+
248+
</section>
249+
250+
<!-- /.usage -->
251+
252+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
253+
254+
<section class="notes">
255+
256+
</section>
257+
258+
<!-- /.notes -->
259+
260+
<!-- C API usage examples. -->
261+
262+
<section class="examples">
263+
264+
### Examples
265+
266+
```c
267+
#include "stdlib/blas/ext/base/dapx.h"
268+
#include <stdio.h>
269+
270+
int main( void ) {
271+
// Create a strided array:
272+
double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 };
273+
274+
// Specify the number of indexed elements:
275+
const int N = 8;
276+
277+
// Specify a stride:
278+
const int strideX = 1;
279+
280+
// Fill the array:
281+
c_dapx( N, 5.0, x, strideX );
282+
283+
// Print the result:
284+
for ( int i = 0; i < 8; i++ ) {
285+
printf( "x[ %i ] = %lf\n", i, x[ i ] );
286+
}
287+
}
288+
```
289+
290+
</section>
291+
292+
<!-- /.examples -->
293+
294+
</section>
295+
296+
<!-- /.c -->
297+
177298
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
178299
179300
<section class="related">

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 dapx = require( './../lib/dapx.js' );
3130

3231
// VARIABLES //
3332

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

3637

3738
// FUNCTIONS //
@@ -46,7 +47,7 @@ var rand = uniform( -10.0, 10.0 );
4647
function createBenchmark( len ) {
4748
var x;
4849

49-
x = filledarrayBy( len, 'float64', rand );
50+
x = uniform( len, -10.0, 10.0, options );
5051
return benchmark;
5152

5253
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 dapx = tryRequire( resolve( __dirname, './../lib/dapx.native.js' ) );
3635
var opts = {
3736
'skip': ( dapx instanceof Error )
3837
};
39-
var rand = uniform( -10.0, 10.0 );
38+
var options = {
39+
'dtype': 'float64'
40+
};
4041

4142

4243
// FUNCTIONS //
@@ -51,7 +52,7 @@ var rand = uniform( -10.0, 10.0 );
5152
function createBenchmark( len ) {
5253
var x;
5354

54-
x = filledarrayBy( len, 'float64', rand );
55+
x = uniform( len, -10.0, 10.0, options );
5556
return benchmark;
5657

5758
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 dapx = require( './../lib/ndarray.js' );
3130

3231
// VARIABLES //
3332

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

3637

3738
// FUNCTIONS //
@@ -46,7 +47,7 @@ var rand = uniform( -10.0, 10.0 );
4647
function createBenchmark( len ) {
4748
var x;
4849

49-
x = filledarrayBy( len, 'float64', rand );
50+
x = uniform( len, -10.0, 10.0, options );
5051
return benchmark;
5152

5253
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 dapx = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
3635
var opts = {
3736
'skip': ( dapx instanceof Error )
3837
};
39-
var rand = uniform( -10.0, 10.0 );
38+
var options = {
39+
'dtype': 'float64'
40+
};
4041

4142

4243
// FUNCTIONS //
@@ -51,7 +52,7 @@ var rand = uniform( -10.0, 10.0 );
5152
function createBenchmark( len ) {
5253
var x;
5354

54-
x = filledarrayBy( len, 'float64', rand );
55+
x = uniform( len, -10.0, 10.0, options );
5556
return benchmark;
5657

5758
function benchmark( b ) {

0 commit comments

Comments
 (0)