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 db3d9a9 commit f14cafa
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 22 deletions.
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,106 @@ console.log( out );

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

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

Computes the sum of absolute values.

```c
const double x[] = { 4.0, 2.0, -3.0, 5.0, -1.0 };
const double y[] = { 2.0, 6.0, -1.0, -4.0, 8.0 };

double v = c_ddot( 5, x, 1, y, 1 );
// returns -5.0
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` first input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
- **Y**: `[in] double*` second input array.
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
```c
double c_ddot( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const 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/ddot.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 };
const double y[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 };

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

// Specify strides:
const int strideX = 1;
const int strideY = -1;

// Compute the dot product:
double d = c_ddot( N, x, strideX, y, strideY );

// Print the result:
printf( "dot product: %lf\n", d );
}
```
</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/ddot.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef DDOT_H
#define DDOT_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" {
/**
* Computes the dot product of two double-precision floating-point vectors.
*/
double c_ddot( const int N, const double *X, const int strideX, const double *Y, const int strideY );
double c_ddot( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY );

#ifdef __cplusplus
}
Expand Down
4 changes: 3 additions & 1 deletion include/stdlib/blas/base/ddot_cblas.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef DDOT_CBLAS_H
#define DDOT_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" {
/**
* Computes the dot product of two double-precision floating-point vectors.
*/
double cblas_ddot( const int N, const double *X, const int strideX, const double *Y, const int strideY );
double cblas_ddot( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const 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 @@ -44,6 +44,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -64,7 +65,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -79,7 +82,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -99,6 +104,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -122,7 +128,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -140,7 +148,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -159,6 +169,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -179,7 +190,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -194,7 +207,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -213,6 +228,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -235,7 +251,9 @@
"-lblas"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -252,7 +270,9 @@
"-lblas"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -272,6 +292,7 @@
],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -295,7 +316,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -313,7 +336,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -330,6 +355,7 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas-base-shared",
"@stdlib/napi-export",
"@stdlib/napi-argv",
"@stdlib/napi-argv-int64",
Expand All @@ -350,7 +376,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},
{
"task": "examples",
Expand All @@ -365,7 +393,9 @@
],
"libraries": [],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/blas-base-shared"
]
},

{
Expand All @@ -381,7 +411,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/ddot.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @see <a href="http://www.netlib.org/lapack/expolore-html/df/d28/group__single__blas__level1.html">ddot</a>
*/
#include "stdlib/blas/base/ddot.h"
#include "stdlib/blas/base/shared.h"

/**
* Computes the dot product of two double-precision floating-point vectors.
Expand All @@ -33,12 +34,12 @@
* @param strideY Y stride length
* @return the dot product
*/
double c_ddot( const int N, const double *X, const int strideX, const double *Y, const int strideY ) {
double c_ddot( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY ) {
double dot;
int ix;
int iy;
int m;
int i;
CBLAS_INT ix;
CBLAS_INT iy;
CBLAS_INT m;
CBLAS_INT i;

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

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

/**
* Computes the dot product of two double-precision floating-point vectors.
Expand All @@ -29,6 +30,6 @@
* @param strideY Y stride length
* @return the dot product
*/
double c_ddot( const int N, const double *X, const int strideX, const double *Y, const int strideY ) {
double c_ddot( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY ) {
return cblas_ddot( N, X, strideX, Y, strideY );
}
Loading

0 comments on commit f14cafa

Please sign in to comment.