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 Apr 27, 2024
1 parent 1348e37 commit 2786730
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 17 deletions.
104 changes: 103 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ daxpy( x.length, alpha, x, 1, y, 1 );
The function has the following parameters:

- **N**: number of indexed elements.
- **alpha**: `numeric` constant.
- **alpha**: scalar constant.
- **x**: input [`Float64Array`][mdn-float64array].
- **strideX**: index increment for `x`.
- **y**: input [`Float64Array`][mdn-float64array].
Expand Down Expand Up @@ -196,6 +196,108 @@ console.log( y );

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

#### c_daxpy( N, alpha, X, strideX, Y, strideY )

Multiplies a vector `X` by a constant and adds the result to `Y`.

```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, y, 1 );
```
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`.
- **Y**: `[out] double*` output array.
- **strideY**: `[in CBLAS_INT` index increment for `Y`.
```c
void c_daxpy( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );
```

</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/base/daxpy.h"
#include <stdio.h>

int main( void ) {
// Create strided arrays:
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

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

// Specify stride lengths:
const int strideX = 2;
const int strideY = -2;

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

// Print the result:
for ( int i = 0; i < 8; i++ ) {
printf( "y[ %i ] = %lf\n", i, y[ i ] );
}
}
```
</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
4 changes: 3 additions & 1 deletion include/stdlib/blas/base/daxpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef DAXPY_H
#define DAXPY_H

#include "stdlib/blas/base/shared.h"

/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
*/
Expand All @@ -32,7 +34,7 @@ extern "C" {
/**
* Multiplies a vector `X` by a constant and adds the result to `Y`.
*/
void c_daxpy( const int N, const double alpha, const double *X, const int strideX, double *Y, const int strideY );
void c_daxpy( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );

#ifdef __cplusplus
}
Expand Down
4 changes: 3 additions & 1 deletion include/stdlib/blas/base/daxpy_cblas.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef DAXPY_CBLAS_H
#define DAXPY_CBLAS_H

#include "stdlib/blas/base/shared.h"

/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
*/
Expand All @@ -32,7 +34,7 @@ extern "C" {
/**
* Multiplies a vector `X` by a constant and adds the result to `Y`.
*/
void cblas_daxpy( const int N, const double alpha, const double *X, const int strideX, double *Y, const int strideY );
void cblas_daxpy( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );

#ifdef __cplusplus
}
Expand Down
34 changes: 27 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-double",
Expand All @@ -63,7 +64,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -78,7 +81,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -98,6 +103,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-double",
Expand Down Expand Up @@ -157,6 +163,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-double",
Expand All @@ -177,7 +184,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -192,7 +201,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -211,6 +222,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-double",
Expand Down Expand Up @@ -270,6 +282,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-double",
Expand Down Expand Up @@ -328,6 +341,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-double",
Expand All @@ -348,7 +362,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -363,7 +379,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -379,7 +397,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
}
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"dependencies": {
"@stdlib/assert-is-error": "^0.2.1",
"@stdlib/blas-base-shared": "github:stdlib-js/blas-base-shared#main",
"@stdlib/napi-argv": "^0.2.1",
"@stdlib/napi-argv-double": "^0.2.1",
"@stdlib/napi-argv-int64": "^0.2.1",
Expand Down
11 changes: 6 additions & 5 deletions src/daxpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "stdlib/blas/base/daxpy.h"
#include "stdlib/blas/base/shared.h"

/**
* Multiplies a vector `X` by a constant and adds the result to `Y`.
Expand All @@ -28,11 +29,11 @@
* @param Y output array
* @param strideY Y stride length
*/
void c_daxpy( const int N, const double alpha, const double *X, const int strideX, double *Y, const int strideY ) {
int ix;
int iy;
int i;
int m;
void c_daxpy( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ) {
CBLAS_INT ix;
CBLAS_INT iy;
CBLAS_INT i;
CBLAS_INT m;

if ( N <= 0 ) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/daxpy_cblas.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "stdlib/blas/base/daxpy.h"
#include "stdlib/blas/base/daxpy_cblas.h"
#include "stdlib/blas/base/shared.h"

/**
* Multiplies a vector `X` by a constant and adds the result to `Y`.
Expand All @@ -29,6 +30,6 @@
* @param Y output array
* @param strideY Y stride length
*/
void c_daxpy( const int N, const double alpha, const double *X, const int strideX, double *Y, const int strideY ) {
void c_daxpy( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ) {
cblas_daxpy( N, alpha, X, strideX, Y, strideY );
}
3 changes: 2 additions & 1 deletion src/daxpy_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "stdlib/blas/base/daxpy.h"
#include "stdlib/blas/base/daxpy_fortran.h"
#include "stdlib/blas/base/shared.h"

/**
* Multiplies a vector `X` by a constant and adds the result to `Y`.
Expand All @@ -29,6 +30,6 @@
* @param Y output array
* @param strideY Y stride length
*/
void c_daxpy( const int N, const double alpha, const double *X, const int strideX, double *Y, const int strideY ) {
void c_daxpy( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ) {
daxpy( &N, &alpha, X, &strideX, Y, &strideY );
}

0 comments on commit 2786730

Please sign in to comment.