diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/README.md b/lib/node_modules/@stdlib/blas/base/sdsdot/README.md
index 4f0416880954..d6b8f9131d58 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/README.md
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/README.md
@@ -178,6 +178,140 @@ console.log( out );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/base/sdsdot.h"
+```
+
+#### c_sdsdot( N, scalar, \*X, strideX, \*Y, strideY )
+
+Calculates the dot product of vectors `x` and `y` with extended accumulation.
+
+```c
+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 };
+
+float v = c_sdsdot( 5, 0.0f, x, 1, y, -1 );
+// returns -120.0f
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **scalar**: `[in] float` scalar constant to add to dot product.
+- **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_sdsdot( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY );
+```
+
+#### c_sdsdot_ndarray( N, scalar, \*X, strideX, offsetX, \*Y, strideY, offsetY )
+
+Calculates the dot product of vectors `x` and `y` with extended accumulation using alternative indexing semantics.
+
+```c
+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 };
+
+float v = c_sdsdot_ndarray( 5, 0.0f, x, 1, 0, y, -1, 7 );
+// returns -80.0f
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **scalar**: `[in] float` scalar constant to add to dot product.
+- **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_sdsdot_ndarray( const CBLAS_INT N, const float scalar, 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/sdsdot.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_sdsdot( N, 0.0f, x, strideX, y, strideY );
+
+ // Print the result:
+ printf( "dot product: %f\n", d );
+
+ // Compute the dot product:
+ d = c_sdsdot_ndarray( N, 0.0f, x, strideX, 0, y, strideY, 7 );
+
+ // Print the result:
+ printf( "dot product: %f\n", d );
+}
+```
+
+
+
+
+
+
+
+
+
* * *
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/c/benchmark.length.c
index 82512090bde1..565da1c58332 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/c/benchmark.length.c
@@ -94,7 +94,7 @@ static float rand_float( void ) {
* @param len array length
* @return elapsed time in seconds
*/
-static double benchmark( int iterations, int len ) {
+static double benchmark1( int iterations, int len ) {
double elapsed;
float x[ len ];
float y[ len ];
@@ -122,6 +122,41 @@ static double benchmark( int iterations, int len ) {
return elapsed;
}
+/**
+* Runs a benchmark.
+*
+* @param iterations number of iterations
+* @param len array length
+* @return elapsed time in seconds
+*/
+static double benchmark2( int iterations, int len ) {
+ double elapsed;
+ float x[ len ];
+ float y[ len ];
+ float z;
+ double t;
+ int i;
+
+ for ( i = 0; i < len; i++ ) {
+ x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
+ y[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
+ }
+ z = 0.0f;
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ z = c_sdsdot_ndarray( len, 0.0f, x, 1, 0, y, 1, 0 );
+ if ( z != z ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( z != z ) {
+ printf( "should not return NaN\n" );
+ }
+ return elapsed;
+}
+
/**
* Main execution sequence.
*/
@@ -144,7 +179,14 @@ int main( void ) {
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:len=%d\n", NAME, len );
- elapsed = benchmark( iter, len );
+ elapsed = benchmark1( iter, len );
+ print_results( iter, elapsed );
+ printf( "ok %d benchmark finished\n", count );
+ }
+ for ( j = 0; j < REPEATS; j++ ) {
+ count += 1;
+ printf( "# c::%s:ndarray:len=%d\n", NAME, len );
+ elapsed = benchmark2( iter, len );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sdsdot/examples/c/example.c
index 0238b0ff825b..c46ff68ceb75 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/examples/c/example.c
@@ -36,4 +36,10 @@ int main( void ) {
// Print the result:
printf( "dot product: %f\n", d );
+
+ // Compute the dot product:
+ d = c_sdsdot_ndarray( N, 0.0f, x, strideX, 0, y, strideY, 7 );
+
+ // Print the result:
+ printf( "dot product: %f\n", d );
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot.h b/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot.h
index d4832b5a3b7a..96c7690223d1 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot.h
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot.h
@@ -22,6 +22,8 @@
#ifndef SDSDOT_H
#define SDSDOT_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,12 @@ extern "C" {
/**
* Computes the dot product of two single-precision floating-point vectors with extended accumulation.
*/
-float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY );
+float API_SUFFIX(c_sdsdot)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY );
+
+/**
+* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.
+*/
+float API_SUFFIX(c_sdsdot_ndarray)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot_cblas.h b/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot_cblas.h
index b2b0274eef4e..31a15464d1ce 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot_cblas.h
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/include/stdlib/blas/base/sdsdot_cblas.h
@@ -22,6 +22,8 @@
#ifndef SDSDOT_CBLAS_H
#define SDSDOT_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.
*/
-float cblas_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY );
+float API_SUFFIX(cblas_sdsdot)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js
index 5a2d55a1a1e5..8ab1aa3dd7f8 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js
@@ -20,9 +20,7 @@
// MODULES //
-var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
-var offsetView = require( '@stdlib/strided/base/offset-view' );
-var addon = require( './sdsdot.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -50,16 +48,7 @@ var addon = require( './sdsdot.native.js' );
* // returns -5.0
*/
function sdsdot( N, scalar, x, strideX, offsetX, y, strideY, offsetY ) {
- var viewX;
- var viewY;
-
- offsetX = minViewBufferIndex( N, strideX, offsetX );
- offsetY = minViewBufferIndex( N, strideY, offsetY );
-
- viewX = offsetView( x, offsetX );
- viewY = offsetView( y, offsetY );
-
- return addon( N, scalar, viewX, strideX, viewY, strideY );
+ return addon.ndarray( N, scalar, x, strideX, offsetX, y, strideY, offsetY );
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json b/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json
index 417ab8fdfff0..5dd3391921a5 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json
@@ -45,9 +45,11 @@
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/argv",
- "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-float",
+ "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double"
]
@@ -58,14 +60,18 @@
"blas": "",
"wasm": false,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
"task": "examples",
@@ -73,14 +79,18 @@
"blas": "",
"wasm": false,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
@@ -101,9 +111,11 @@
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/argv",
- "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-float",
+ "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double"
]
@@ -124,7 +136,10 @@
"-lpthread"
],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index"
+ ]
},
{
"task": "examples",
@@ -142,7 +157,10 @@
"-lpthread"
],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index"
+ ]
},
{
@@ -162,9 +180,11 @@
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/argv",
- "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-float",
+ "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double"
]
@@ -175,14 +195,18 @@
"blas": "",
"wasm": false,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
"task": "examples",
@@ -190,14 +214,18 @@
"blas": "",
"wasm": false,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
@@ -217,9 +245,11 @@
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/argv",
- "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-float",
+ "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double"
]
@@ -239,7 +269,10 @@
"-lblas"
],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index"
+ ]
},
{
"task": "examples",
@@ -256,7 +289,10 @@
"-lblas"
],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index"
+ ]
},
{
@@ -277,9 +313,11 @@
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/argv",
- "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-float",
+ "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double"
]
@@ -300,7 +338,10 @@
"-lpthread"
],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index"
+ ]
},
{
"task": "examples",
@@ -318,7 +359,10 @@
"-lpthread"
],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/min-view-buffer-index"
+ ]
},
{
@@ -327,7 +371,8 @@
"blas": "",
"wasm": false,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
@@ -336,9 +381,11 @@
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
"@stdlib/napi/argv",
- "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-float",
+ "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double"
]
@@ -349,14 +396,18 @@
"blas": "",
"wasm": false,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
"task": "examples",
@@ -364,14 +415,18 @@
"blas": "",
"wasm": false,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
@@ -380,14 +435,18 @@
"blas": "",
"wasm": true,
"src": [
- "./src/sdsdot.c"
+ "./src/sdsdot.c",
+ "./src/sdsdot_ndarray.c"
],
"include": [
"./include"
],
"libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset"
+ ]
}
]
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c
index 637e4371357b..597ffa2c1617 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c
@@ -17,6 +17,7 @@
*/
#include "stdlib/blas/base/sdsdot.h"
+#include "stdlib/blas/base/shared.h"
#include "stdlib/napi/export.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_int64.h"
@@ -40,8 +41,29 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 );
- STDLIB_NAPI_CREATE_DOUBLE( env, (double)c_sdsdot( N, scalar, X, strideX, Y, strideY ), v );
+ STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(c_sdsdot)( N, scalar, X, strideX, Y, strideY ), v );
return v;
}
-STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
+/**
+* Receives JavaScript callback invocation data.
+*
+* @param env environment under which the function is invoked
+* @param info callback data
+* @return Node-API value
+*/
+static napi_value addon_method( napi_env env, napi_callback_info info ) {
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 8 );
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
+ STDLIB_NAPI_ARGV_FLOAT( env, scalar, argv, 1 );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
+ STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 6 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 7 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 5 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(c_sdsdot_ndarray)( N, scalar, X, strideX, offsetX, Y, strideY, offsetY ), v );
+ return v;
+}
+
+STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c
index ba3d601c02d5..1d745b1cc2e5 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c
@@ -22,6 +22,8 @@
* @see sdsdot
*/
#include "stdlib/blas/base/sdsdot.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
/**
* Computes the dot product of two single-precision floating-point vectors with extended accumulation.
@@ -34,50 +36,9 @@
* @param strideY Y stride length
* @return dot product
*/
-float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) {
- double dot;
- int ix;
- int iy;
- int m;
- int i;
-
- dot = (double)scalar;
- if ( N <= 0 ) {
- return dot;
- }
- // If both strides are equal to `1`, use unrolled loops...
- if ( strideX == 1 && strideY == 1 ) {
- m = N % 5;
-
- // If we have a remainder, do a clean-up loop...
- if ( m > 0 ) {
- for ( i = 0; i < m; i++ ) {
- dot += (double)X[ i ] * (double)Y[ i ];
- }
- }
- if ( N < 5 ) {
- return dot;
- }
- for ( i = m; i < N; i += 5 ) {
- dot += ( (double)X[i]*(double)Y[i] ) + ( (double)X[i+1]*(double)Y[i+1]) + ( (double)X[i+2]*(double)Y[i+2] ) + ( (double)X[i+3]*(double)Y[i+3] ) + ( (double)X[i+4]*(double)Y[i+4] );
- }
- return dot;
- }
- if ( strideX < 0 ) {
- ix = (1-N) * strideX;
- } else {
- ix = 0;
- }
- if ( strideY < 0 ) {
- iy = (1-N) * strideY;
- } else {
- iy = 0;
- }
- for ( i = 0; i < N; i++ ) {
- dot += (double)X[ ix ] * (double)Y[ iy ];
- ix += strideX;
- iy += strideY;
- }
- return dot;
+float API_SUFFIX(c_sdsdot)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY );
+ return API_SUFFIX(c_sdsdot_ndarray)( N, scalar, X, strideX, ox, Y, strideY, oy );
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c
index bd47331e1331..8a8fdeca4fe0 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c
@@ -18,6 +18,8 @@
#include "stdlib/blas/base/sdsdot.h"
#include "stdlib/blas/base/sdsdot_cblas.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/min_view_buffer_index.h"
/**
* Computes the dot product of two single-precision floating-point vectors with extended accumulation.
@@ -30,6 +32,25 @@
* @param strideY Y stride length
* @return dot product
*/
-float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) {
- return cblas_sdsdot( N, scalar, X, strideX, Y, strideY );
+float API_SUFFIX(c_sdsdot)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ) {
+ return API_SUFFIX(cblas_sdsdot)( N, scalar, X, strideX, Y, strideY );
+}
+
+/**
+* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.
+*
+* @param N number of indexed elements
+* @param scalar scalar constant added to the dot product
+* @param X first array
+* @param strideX X stride length
+* @param offsetX starting index for X
+* @param Y second array
+* @param strideY Y stride length
+* @param offsetY starting index for Y
+* @return dot product
+*/
+float API_SUFFIX(c_sdsdot_ndarray)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
+ X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
+ Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
+ return API_SUFFIX(cblas_sdsdot)( N, scalar, X, strideX, Y, strideY );
}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c
index 8e5de1ca0cde..e99160eaa696 100644
--- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c
@@ -23,6 +23,8 @@
*/
#include "stdlib/blas/base/sdsdot.h"
#include "stdlib/blas/base/sdsdot_fortran.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/min_view_buffer_index.h"
/**
* Computes the dot product of two single-precision floating-point vectors with extended accumulation.
@@ -37,8 +39,32 @@
* @param strideY Y stride length
* @return dot product
*/
-float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) {
+float API_SUFFIX(c_sdsdot)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const float *Y, const CBLAS_INT strideY ) {
float dot;
sdsdotsub( &N, &scalar, X, &strideX, Y, &strideY, &dot );
return dot;
}
+
+/**
+* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.
+*
+* Arguments are passed by reference to a Fortran subroutine implementing `sdsdot`.
+*
+* @param N number of indexed elements
+* @param scalar scalar constant added to the dot product
+* @param X first array
+* @param strideX X stride length
+* @param offsetX starting index for X
+* @param Y second array
+* @param strideY Y stride length
+* @param offsetY starting index for Y
+* @return dot product
+*/
+float API_SUFFIX(c_sdsdot_ndarray)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
+ float dot;
+
+ X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
+ Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
+ sdsdotsub( &N, &scalar, X, &strideX, Y, &strideY, &dot );
+ return dot;
+}
diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_ndarray.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_ndarray.c
new file mode 100644
index 000000000000..6aed77a944cc
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_ndarray.c
@@ -0,0 +1,85 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+* Compute the dot product of two single-precision floating-point vectors with extended accumulation.
+*
+* @see sdsdot
+*/
+#include "stdlib/blas/base/sdsdot.h"
+#include "stdlib/blas/base/shared.h"
+
+static const CBLAS_INT M = 5;
+
+/**
+* Computes the dot product of two single-precision floating-point vectors with extended accumulation using alternative indexing semantics.
+*
+* @param N number of indexed elements
+* @param scalar scalar constant added to the dot product
+* @param X first array
+* @param strideX X stride length
+* @param offsetX starting index for X
+* @param Y second array
+* @param strideY Y stride length
+* @param offsetY starting index for Y
+* @return dot product
+*/
+float API_SUFFIX(c_sdsdot_ndarray)( const CBLAS_INT N, const float scalar, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
+ CBLAS_INT ix;
+ CBLAS_INT iy;
+ CBLAS_INT m;
+ CBLAS_INT i;
+ double dot;
+
+ dot = (double)scalar;
+ if ( N <= 0 ) {
+ return dot;
+ }
+ ix = offsetX;
+ iy = offsetY;
+
+ // If both strides are equal to `1`, use unrolled loops...
+ if ( strideX == 1 && strideY == 1 ) {
+ m = N % M;
+
+ // If we have a remainder, do a clean-up loop...
+ if ( m > 0 ) {
+ for ( i = 0; i < m; i++ ) {
+ dot += (double)X[ ix ] * (double)Y[ iy ];
+ ix += strideX;
+ iy += strideY;
+ }
+ }
+ if ( N < M ) {
+ return dot;
+ }
+ for ( i = m; i < N; i += M ) {
+ dot += ( (double)X[ ix ]*(double)Y[ iy ] ) + ( (double)X[ ix+1 ]*(double)Y[ iy+1 ]) + ( (double)X[ ix+2 ]*(double)Y[ iy+2 ] ) + ( (double)X[ ix+3 ]*(double)Y[ iy+3 ] ) + ( (double)X[ ix+4 ]*(double)Y[ iy+4 ] );
+ ix += M;
+ iy += M;
+ }
+ return dot;
+ }
+ for ( i = 0; i < N; i++ ) {
+ dot += (double)X[ ix ] * (double)Y[ iy ];
+ ix += strideX;
+ iy += strideY;
+ }
+ return dot;
+}
+