Skip to content

Commit

Permalink
docs: document C API
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Sep 10, 2024
1 parent ae54d13 commit 44ebe3c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/node_modules/@stdlib/blas/base/daxpy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@ The function accepts the following arguments:
void c_daxpy( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );
```

#### c_daxpy_ndarray( N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY )

Multiplies a vector `X` by a constant and adds the result to `Y` using alternative indexing semantics.

```c
const double x[] = { 1.0, 2.0, 3.0, 4.0 };
double y[] = { 0.0, 0.0, 0.0, 0.0 };

c_daxpy( 4, 5.0, x, 1, 0, y, 1, 0 );
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **alpha**: `[in] double` scalar constant.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
- **Y**: `[inout] double*` output array.
- **strideY**: `[in CBLAS_INT` index increment for `Y`.
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
```c
void c_daxpy_ndarray( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
```

</section>

<!-- /.usage -->
Expand Down Expand Up @@ -254,6 +280,14 @@ int main( void ) {
for ( int i = 0; i < 8; i++ ) {
printf( "y[ %i ] = %lf\n", i, y[ i ] );
}

// Compute `a*x + y`:
c_daxpy_ndarray( N, 5.0, x, strideX, 1, y, strideY, 7 );

// Print the result:
for ( int i = 0; i < 8; i++ ) {
printf( "y[ %i ] = %lf\n", i, y[ i ] );
}
}
```
Expand Down

0 comments on commit 44ebe3c

Please sign in to comment.