From d4c94d2cd1dd05df0045a6be88fd4cc9eae5d27d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Sep 2024 21:47:38 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 23 +++ base/sdot/README.md | 132 ++++++++++++++++++ base/sdot/benchmark/c/benchmark.length.c | 46 +++++- base/sdot/examples/c/example.c | 6 + base/sdot/include/stdlib/blas/base/sdot.h | 9 +- .../include/stdlib/blas/base/sdot_cblas.h | 4 +- base/sdot/lib/ndarray.native.js | 15 +- base/sdot/manifest.json | 101 +++++++++++--- base/sdot/src/addon.c | 25 +++- base/sdot/src/sdot.c | 51 +------ base/sdot/src/sdot_cblas.c | 24 +++- base/sdot/src/sdot_f.c | 27 +++- base/sdot/src/sdot_ndarray.c | 84 +++++++++++ 13 files changed, 459 insertions(+), 88 deletions(-) create mode 100644 base/sdot/src/sdot_ndarray.c diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b8a3d1c8..c571f040d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -187,6 +187,28 @@ +
+ +#### [@stdlib/blas/base/sdot](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/sdot) + +
+ +
+ +##### Features + +- [`2bedae9`](https://github.com/stdlib-js/stdlib/commit/2bedae91dbdd0080b38ae0413f5e8f26b88db95b) - add C `ndarray` implementation for `blas/base/sdot` [(#2919)](https://github.com/stdlib-js/stdlib/pull/2919) + +
+ + + +
+ +
+ + +
#### [@stdlib/blas/base/sspr](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/sspr) @@ -471,6 +493,7 @@ A total of 6 people contributed to this release. Thank you to the following cont
+- [`2bedae9`](https://github.com/stdlib-js/stdlib/commit/2bedae91dbdd0080b38ae0413f5e8f26b88db95b) - **feat:** add C `ndarray` implementation for `blas/base/sdot` [(#2919)](https://github.com/stdlib-js/stdlib/pull/2919) _(by Aman Bhansali, Athan Reines)_ - [`e85f394`](https://github.com/stdlib-js/stdlib/commit/e85f3947aaca3cbbd6ab4f84e41577928e0a10a4) - **feat:** add C `ndarray` implementation for `blas/base/saxpy` [(#2918)](https://github.com/stdlib-js/stdlib/pull/2918) _(by Aman Bhansali)_ - [`6ae1c10`](https://github.com/stdlib-js/stdlib/commit/6ae1c10d70d86520a0c915864440ef6e8d255a21) - **docs:** rename parameter _(by Athan Reines)_ - [`7eb1266`](https://github.com/stdlib-js/stdlib/commit/7eb12667e2052db9fc1e678bf0cc2082e2993aec) - **docs:** rename parameters _(by Athan Reines)_ diff --git a/base/sdot/README.md b/base/sdot/README.md index efb312b2c..3ae6e8d9f 100644 --- a/base/sdot/README.md +++ b/base/sdot/README.md @@ -177,6 +177,138 @@ console.log( out ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/sdot.h" +``` + +#### c_sdot( N, \*X, strideX, \*Y, strideY ) + +Computes the dot product of two single-precision floating-point vectors. + +```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 }; + +float d = c_sdot( 5, x, 1, y, 1 ); +// returns -5.0f +``` + +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 +float c_sdot( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ); +``` + +#### c_sdot_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY ) + +Computes the dot product of two single-precision floating-point vectors using alternative indexing semantics. + +```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 }; + +float d = c_sdot_ndarray( 3, x, 1, 2, y, 1, 2 ); +// returns -25.0f +``` + +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`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[in] float*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. + +```c +float c_sdot_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/sdot.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 indexed elements: + const int N = 8; + + // Specify strides: + const int strideX = 1; + const int strideY = -1; + + // Compute the dot product: + float d = c_sdot( N, x, strideX, y, strideY ); + + // Print the result: + printf( "dot product: %f\n", d ); + + // Compute the dot product: + d = c_sdot_ndarray( N, x, strideX, 0, y, strideY, 7 ); + + // Print the result: + printf( "dot product: %f\n", d ); +} +``` + +
+ + + +
+ + +