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 f438147 commit 36ad267
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 22 deletions.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,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/dswap.h"
```

#### c_dswap( N, X, strideX, Y, strideY )

Interchanges two double-precision floating-point vectors.

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

c_dswap( 4, x, 1, y, 1 );
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[inout] double*` first input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
- **Y**: `[inout] double*` first input array.
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
```c
void c_dswap( const CBLAS_INT N, 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/dswap.h"
#include <stdio.h>

int main( void ) {
// Create strided arrays:
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;

// Interchange elements:
c_dswap( N, x, strideX, y, strideY );

// Print the result:
for ( int i = 0; i < 8; i++ ) {
printf( "x[ %i ] = %lf\n", i, x[ 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/dswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef DSWAP_H
#define DSWAP_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" {
/**
* Interchanges two double-precision floating-point vectors.
*/
void c_dswap( const int N, double *X, const int strideX, double *Y, const int strideY );
void c_dswap( const CBLAS_INT N, 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/dswap_cblas.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef DSWAP_CBLAS_H
#define DSWAP_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" {
/**
* Interchanges two double-precision floating-point vectors.
*/
void cblas_dswap( const int N, double *X, const int strideX, double *Y, const int strideY );
void cblas_dswap( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );

#ifdef __cplusplus
}
Expand Down
58 changes: 45 additions & 13 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-int64",
Expand All @@ -62,7 +63,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -77,7 +80,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -97,6 +102,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -119,7 +125,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -137,7 +145,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -155,6 +165,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -174,7 +185,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -189,7 +202,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -208,6 +223,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -229,7 +245,9 @@
"-lblas"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -246,7 +264,9 @@
"-lblas"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -266,6 +286,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -288,7 +309,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -306,7 +329,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -323,6 +348,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -342,7 +368,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -357,7 +385,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -373,7 +403,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-int64": "^0.2.1",
"@stdlib/napi-argv-strided-float64array": "^0.2.1",
Expand Down
11 changes: 6 additions & 5 deletions src/dswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

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

/**
* Interchanges two double-precision floating-point vectors.
Expand All @@ -27,12 +28,12 @@
* @param Y second input array
* @param strideY Y stride length
*/
void c_dswap( const int N, double *X, const int strideX, double *Y, const int strideY ) {
void c_dswap( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ) {
double tmp;
int ix;
int iy;
int i;
int m;
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/dswap_cblas.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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

/**
* Interchanges two double-precision floating-point vectors.
Expand All @@ -28,6 +29,6 @@
* @param Y second input array
* @param strideY Y stride length
*/
void c_dswap( const int N, double *X, const int strideX, double *Y, const int strideY ) {
void c_dswap( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ) {
cblas_dswap( N, X, strideX, Y, strideY );
}
Loading

0 comments on commit 36ad267

Please sign in to comment.