From 36bdfb00224ab0bae35ece2fa9a3cea03865b820 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Apr 2024 21:05:37 +0000 Subject: [PATCH] Auto-generated commit --- base/ddot/src/ddot.c | 5 - base/ddot/src/ddot_f.c | 5 - base/dsdot/README.md | 100 ++++++++++++++++++ base/dsdot/examples/c/example.c | 4 +- base/dsdot/include/stdlib/blas/base/dsdot.h | 4 +- .../include/stdlib/blas/base/dsdot_cblas.h | 4 +- base/dsdot/manifest.json | 58 +++++++--- base/dsdot/src/dsdot.c | 16 ++- base/dsdot/src/dsdot_cblas.c | 3 +- base/dsdot/src/dsdot_f.c | 8 +- 10 files changed, 163 insertions(+), 44 deletions(-) diff --git a/base/ddot/src/ddot.c b/base/ddot/src/ddot.c index 6fe983820..755f64d2b 100644 --- a/base/ddot/src/ddot.c +++ b/base/ddot/src/ddot.c @@ -16,11 +16,6 @@ * limitations under the License. */ -/** - * Compute the dot product of two double-precision floating-point vectors. - * - * @see ddot - */ #include "stdlib/blas/base/ddot.h" #include "stdlib/blas/base/shared.h" diff --git a/base/ddot/src/ddot_f.c b/base/ddot/src/ddot_f.c index 989561487..8a80f1ad2 100644 --- a/base/ddot/src/ddot_f.c +++ b/base/ddot/src/ddot_f.c @@ -16,11 +16,6 @@ * limitations under the License. */ -/** - * Compute the dot product of two double-precision floating-point vectors. - * - * @see ddot - */ #include "stdlib/blas/base/ddot.h" #include "stdlib/blas/base/ddot_fortran.h" #include "stdlib/blas/base/shared.h" diff --git a/base/dsdot/README.md b/base/dsdot/README.md index a9dbd3f2a..cc42886a9 100644 --- a/base/dsdot/README.md +++ b/base/dsdot/README.md @@ -177,6 +177,106 @@ console.log( out ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/dsdot.h" +``` + +#### c_dsdot( N, X, strideX, Y, strideY ) + +Computes the dot product of two single-precision floating-point vectors with extended accumulation and result. + +```c +const float x[] = { 4.0f, 2.0f, -3.0f, 5.0f, -1.0f }; +const float y[] = { 2.0f, 6.0f, -1.0f, -4.0f, 8.0f }; + +double v = c_dsdot( 5, x, 1, y, 1 ); +// returns -5.0 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] float*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **Y**: `[in] float*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. + +```c +double c_dsdot( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/dsdot.h" +#include + +int main( void ) { + // Create strided arrays: + const float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f }; + const float y[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f }; + + // 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_dsdot( N, x, strideX, y, strideY ); + + // Print the result: + printf( "dot product: %lf\n", d ); +} +``` + +
+ + + +
+ + + * * *
diff --git a/base/dsdot/examples/c/example.c b/base/dsdot/examples/c/example.c index e889b2960..7c3054f27 100644 --- a/base/dsdot/examples/c/example.c +++ b/base/dsdot/examples/c/example.c @@ -21,8 +21,8 @@ int main( void ) { // Create strided arrays: - const float x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - const float y[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f }; + const float y[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f }; // Specify the number of elements: const int N = 8; diff --git a/base/dsdot/include/stdlib/blas/base/dsdot.h b/base/dsdot/include/stdlib/blas/base/dsdot.h index ba0262739..0bfb0869c 100644 --- a/base/dsdot/include/stdlib/blas/base/dsdot.h +++ b/base/dsdot/include/stdlib/blas/base/dsdot.h @@ -22,6 +22,8 @@ #ifndef DSDOT_H #define DSDOT_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. */ @@ -32,7 +34,7 @@ extern "C" { /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation and result. */ -double c_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ); +double c_dsdot( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ); #ifdef __cplusplus } diff --git a/base/dsdot/include/stdlib/blas/base/dsdot_cblas.h b/base/dsdot/include/stdlib/blas/base/dsdot_cblas.h index 2e1958abb..bbd8c038d 100644 --- a/base/dsdot/include/stdlib/blas/base/dsdot_cblas.h +++ b/base/dsdot/include/stdlib/blas/base/dsdot_cblas.h @@ -22,6 +22,8 @@ #ifndef DSDOT_CBLAS_H #define DSDOT_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. */ @@ -32,7 +34,7 @@ extern "C" { /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation and result. */ -double cblas_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ); +double cblas_dsdot( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ); #ifdef __cplusplus } diff --git a/base/dsdot/manifest.json b/base/dsdot/manifest.json index b65ee1db9..934a31c1b 100644 --- a/base/dsdot/manifest.json +++ b/base/dsdot/manifest.json @@ -44,6 +44,7 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -64,7 +65,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { "task": "examples", @@ -79,7 +82,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { @@ -99,6 +104,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -122,7 +128,9 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { "task": "examples", @@ -140,7 +148,9 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { @@ -159,6 +169,7 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -179,7 +190,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { "task": "examples", @@ -194,7 +207,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { @@ -213,6 +228,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -235,7 +251,9 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { "task": "examples", @@ -252,7 +270,9 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { @@ -272,6 +292,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -295,7 +316,9 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { "task": "examples", @@ -313,7 +336,9 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { @@ -330,6 +355,7 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -350,7 +376,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { "task": "examples", @@ -365,7 +393,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] }, { @@ -381,7 +411,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared" + ] } ] } diff --git a/base/dsdot/src/dsdot.c b/base/dsdot/src/dsdot.c index 21b1117e8..77ba959d1 100644 --- a/base/dsdot/src/dsdot.c +++ b/base/dsdot/src/dsdot.c @@ -16,12 +16,8 @@ * limitations under the License. */ -/** - * Compute the dot product of two single-precision floating-point vectors with extended accumulation and result. - * - * @see dsdot - */ #include "stdlib/blas/base/dsdot.h" +#include "stdlib/blas/base/shared.h" /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation and result. @@ -33,12 +29,12 @@ * @param strideY Y stride length * @return the dot product */ -double c_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { +double c_dsdot( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *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 ) { diff --git a/base/dsdot/src/dsdot_cblas.c b/base/dsdot/src/dsdot_cblas.c index 31cda7eaa..814bc19df 100644 --- a/base/dsdot/src/dsdot_cblas.c +++ b/base/dsdot/src/dsdot_cblas.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/dsdot.h" #include "stdlib/blas/base/dsdot_cblas.h" +#include "stdlib/blas/base/shared.h" /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation and result. @@ -29,6 +30,6 @@ * @param strideY Y stride length * @return the dot product */ -double c_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { +double c_dsdot( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ) { return cblas_dsdot( N, X, strideX, Y, strideY ); } diff --git a/base/dsdot/src/dsdot_f.c b/base/dsdot/src/dsdot_f.c index 1c06f1645..0e1f7e1db 100644 --- a/base/dsdot/src/dsdot_f.c +++ b/base/dsdot/src/dsdot_f.c @@ -16,13 +16,9 @@ * limitations under the License. */ -/** - * Compute the dot product of two single-precision floating-point vectors with extended accumulation and result. - * - * @see dsdot - */ #include "stdlib/blas/base/dsdot.h" #include "stdlib/blas/base/dsdot_fortran.h" +#include "stdlib/blas/base/shared.h" /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation and result. @@ -34,7 +30,7 @@ * @param strideY Y stride length * @return the dot product */ -double c_dsdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { +double c_dsdot( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ) { double dot; dsdotsub( &N, X, &strideX, Y, &strideY, &dot ); return dot;