diff --git a/lib/node_modules/@stdlib/blas/base/drotm/README.md b/lib/node_modules/@stdlib/blas/base/drotm/README.md index cb081be59f5f..1c3cbd622814 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/README.md +++ b/lib/node_modules/@stdlib/blas/base/drotm/README.md @@ -223,6 +223,33 @@ The function accepts the following arguments: void c_drotm( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double *param ); ``` +#### c_drotm_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY, param ) + +Applies a modified Givens plane rotation using alternative indexing semantics. + +```c +double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0 }; +double y[] = { 6.0, 7.0, 8.0, 9.0, 10.0 }; +const double param[5] = { 0.0, 0.0, 2.0, -3.0, 0.0 }; + +c_drotm_ndarray( 5, x, -1, 4, y, -1, 4, param ); +``` + +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`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[inout] double*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. +- **param**: `[in] double` parameters for the modified Givens transformation. + +```c +void c_drotm_ndarray( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const double *param ); +``` + @@ -267,6 +294,14 @@ int main( void ) { for ( int i = 0; i < 5; i++ ) { printf( "x[ %i ] = %lf, y[ %i ] = %lf\n", i, x[ i ], i, y[ i ] ); } + + // Apply plane rotation: + c_drotm_ndarray( N, x, -strideX, N-1, y, -strideY, N-1, param ); + + // Print the result: + for ( int i = 0; i < 5; i++ ) { + printf( "x[ %i ] = %lf, y[ %i ] = %lf\n", i, x[ i ], i, y[ i ] ); + } } ``` diff --git a/lib/node_modules/@stdlib/blas/base/drotm/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/drotm/benchmark/c/benchmark.length.c index acdd303740f0..2af81b067cd1 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/drotm/benchmark/c/benchmark.length.c @@ -94,7 +94,7 @@ static double rand_double( 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; double x[ len ]; double 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; + double x[ len ]; + double y[ len ]; + double t; + int i; + + const double param[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_double()*200.0 ) - 100.0; + y[ i ] = ( rand_double()*200.0 ) - 100.0; + } + + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_drotm_ndarray( len, x, 1, 0, y, 1, 0, param ); + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y[ 0 ] != y[ 0 ] ) { + 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/drotm/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/drotm/examples/c/example.c index 41f1bada0a91..ebf177a066a2 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/drotm/examples/c/example.c @@ -41,4 +41,12 @@ int main( void ) { for ( int i = 0; i < 5; i++ ) { printf( "x[ %i ] = %lf, y[ %i ] = %lf\n", i, x[ i ], i, y[ i ] ); } + + // Apply plane rotation: + c_drotm_ndarray( N, x, -strideX, N-1, y, -strideY, N-1, param ); + + // Print the result: + for ( int i = 0; i < 5; i++ ) { + printf( "x[ %i ] = %lf, y[ %i ] = %lf\n", i, x[ i ], i, y[ i ] ); + } } diff --git a/lib/node_modules/@stdlib/blas/base/drotm/include/stdlib/blas/base/drotm.h b/lib/node_modules/@stdlib/blas/base/drotm/include/stdlib/blas/base/drotm.h index a2781b54bbbf..a84806149bec 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/include/stdlib/blas/base/drotm.h +++ b/lib/node_modules/@stdlib/blas/base/drotm/include/stdlib/blas/base/drotm.h @@ -36,6 +36,11 @@ extern "C" { */ void API_SUFFIX(c_drotm)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double *param ); +/** +* Applies a modified Givens plane rotation using alternative indexing semantics. +*/ +void API_SUFFIX(c_drotm_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const double *param ); + #ifdef __cplusplus } #endif diff --git a/lib/node_modules/@stdlib/blas/base/drotm/lib/drotm.js b/lib/node_modules/@stdlib/blas/base/drotm/lib/drotm.js index a529c9c5fc55..22bdc2601d42 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/lib/drotm.js +++ b/lib/node_modules/@stdlib/blas/base/drotm/lib/drotm.js @@ -49,16 +49,8 @@ var ndarray = require( './ndarray.js' ); * // y => [ 1.7, -0.9, 0.5, 0.7, -1.6, 0.2, 2.4 ] */ function drotm( N, x, strideX, y, strideY, param ) { - var dflag; - var ix; - var iy; - - dflag = param[ 0 ]; - if ( N <= 0 || dflag === -2.0 ) { - return y; - } - ix = stride2offset( N, strideX ); - iy = stride2offset( N, strideY ); + var ix = stride2offset( N, strideX ); + var iy = stride2offset( N, strideY ); return ndarray( N, x, strideX, ix, y, strideY, iy, param ); } diff --git a/lib/node_modules/@stdlib/blas/base/drotm/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/drotm/lib/ndarray.js index d2bafae0c0f5..766717ea5e32 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/drotm/lib/ndarray.js @@ -26,10 +26,10 @@ * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {NonNegativeInteger} offsetX - starting index for `x` * @param {Float64Array} y - second input array * @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - starting `y` index +* @param {NonNegativeInteger} offsetY - starting index for `y` * @param {Float64Array} param - parameters for the modified Givens transformation * @returns {Float64Array} `y` * diff --git a/lib/node_modules/@stdlib/blas/base/drotm/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/drotm/lib/ndarray.native.js index fde49ad2efb9..e6a4bd92ff2c 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/drotm/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( './drotm.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -33,10 +31,10 @@ var addon = require( './drotm.native.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {NonNegativeInteger} offsetX - starting index for `x` * @param {Float64Array} y - second input array * @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - starting `y` index +* @param {NonNegativeInteger} offsetY - starting index for `y` * @param {Float64Array} param - parameters for the modified Givens transformation * @returns {Float64Array} `y` * @@ -52,16 +50,7 @@ var addon = require( './drotm.native.js' ); * // y => [ 1.7, -0.9, 0.5, 0.7, -1.6, 0.2, 2.4 ] */ function drotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) { - var viewX; - var viewY; - - offsetX = minViewBufferIndex( N, strideX, offsetX ); - offsetY = minViewBufferIndex( N, strideY, offsetY ); - - viewX = offsetView( x, offsetX ); - viewY = offsetView( y, offsetY ); - - addon( N, viewX, strideX, viewY, strideY, param ); + addon.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, param ); return y; } diff --git a/lib/node_modules/@stdlib/blas/base/drotm/manifest.json b/lib/node_modules/@stdlib/blas/base/drotm/manifest.json index c4a0be751a6a..49b335b91396 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/drotm/manifest.json @@ -44,6 +44,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -57,7 +58,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -65,7 +67,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -74,7 +77,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -82,7 +86,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -104,6 +109,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -128,7 +134,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -148,7 +155,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -168,6 +176,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -181,7 +190,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -189,7 +199,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -198,7 +209,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -206,7 +218,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -227,6 +240,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -250,7 +264,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -269,7 +284,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -291,6 +307,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -315,7 +332,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -335,7 +353,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -345,7 +364,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -354,6 +374,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -367,7 +388,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -375,7 +397,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -384,7 +407,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -392,7 +416,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -402,7 +427,8 @@ "blas": "", "wasm": true, "src": [ - "./src/drotm.c" + "./src/drotm.c", + "./src/drotm_ndarray.c" ], "include": [ "./include" @@ -410,7 +436,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] } ] diff --git a/lib/node_modules/@stdlib/blas/base/drotm/src/addon.c b/lib/node_modules/@stdlib/blas/base/drotm/src/addon.c index 2f9038b228d6..4711afe7d893 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/drotm/src/addon.c @@ -44,4 +44,25 @@ static napi_value addon( napi_env env, napi_callback_info info ) { return NULL; } -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_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 6 ); + STDLIB_NAPI_ARGV_FLOAT64ARRAY( env, param, paramlen, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 ); + API_SUFFIX(c_drotm_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY, param ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/drotm/src/drotm.c b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm.c index f568ab1de61a..ec5a3ec725e6 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/src/drotm.c +++ b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/drotm.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" /** * Applies a plane rotation. @@ -30,107 +31,7 @@ * @param param parameters for the modified Givens transformation */ void API_SUFFIX(c_drotm)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double *param ) { - CBLAS_INT ix; - CBLAS_INT iy; - double dflag; - double dh11; - double dh12; - double dh21; - double dh22; - CBLAS_INT i; - double w; - double z; - - dflag = param[ 0 ]; - if ( N <= 0 || dflag == -2.0 ) { - return; - } - if ( strideX == strideY && strideX > 0 ) { - ix = 0; - if ( dflag < 0.0 ) { - dh11 = param[ 1 ]; - dh12 = param[ 3 ]; - dh21 = param[ 2 ]; - dh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ ix ]; - X[ ix ] = ( w * dh11 ) + ( z * dh12 ); - Y[ ix ] = ( w * dh21 ) + ( z * dh22 ); - ix += strideX; - } - return; - } - if ( dflag == 0.0 ) { - dh12 = param[ 3 ]; - dh21 = param[ 2 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ ix ]; - X[ ix ] = w + ( z * dh12 ); - Y[ ix ] = ( w * dh21 ) + z; - ix += strideX; - } - return; - } - dh11 = param[ 1 ]; - dh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ ix ]; - X[ ix ] = ( w * dh11 ) + z; - Y[ ix ] = -w + ( z * dh22 ); - ix += strideX; - } - return; - } - if ( strideX < 0 ) { - ix = ( 1 - N ) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = ( 1 - N ) * strideY; - } else { - iy = 0; - } - if ( dflag < 0.0 ) { - dh11 = param[ 1 ]; - dh12 = param[ 3 ]; - dh21 = param[ 2 ]; - dh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ iy ]; - X[ ix ] = ( w * dh11 ) + ( z * dh12 ); - Y[ iy ] = ( w * dh21 ) + ( z * dh22 ); - ix += strideX; - iy += strideY; - } - return; - } - if ( dflag == 0.0 ) { - dh12 = param[ 3 ]; - dh21 = param[ 2 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ iy ]; - X[ ix ] = w + ( z * dh12 ); - Y[ iy ] = ( w * dh21 ) + z; - ix += strideX; - iy += strideY; - } - return; - } - dh11 = param[ 1 ]; - dh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ iy ]; - X[ ix ] = ( w * dh11 ) + z; - Y[ iy ] = -w + ( z * dh22 ); - ix += strideX; - iy += strideY; - } - return; + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(c_drotm_ndarray)( N, X, strideX, ox, Y, strideY, oy, param ); } diff --git a/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_cblas.c b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_cblas.c index 5dc04f172c0c..c228a40bda12 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_cblas.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/drotm.h" #include "stdlib/blas/base/drotm_cblas.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" /** * Applies a modified Givens plane rotation. @@ -33,3 +34,21 @@ void API_SUFFIX(c_drotm)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double *param ) { API_SUFFIX(cblas_drotm)( N, X, strideX, Y, strideY, param ); } + +/** +* Applies a modified Givens plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y second input array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param param parameters for the modified Givens transformation +*/ +void API_SUFFIX(c_drotm_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const double *param ) { + 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 + API_SUFFIX(cblas_drotm)( N, X, strideX, Y, strideY, param ); +} diff --git a/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_f.c b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_f.c index b1c3bcb35838..889a7f7bb011 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_f.c +++ b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_f.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/drotm.h" #include "stdlib/blas/base/drotm_fortran.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" /** * Applies a modified Givens plane rotation. @@ -33,3 +34,21 @@ void API_SUFFIX(c_drotm)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double *param ) { drotm( &N, X, &strideX, Y, &strideY, param ); } + +/** +* Applies a modified Givens plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y second input array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param param parameters for the modified Givens transformation +*/ +void API_SUFFIX(c_drotm_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const double *param ) { + 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 + drotm( &N, X, &strideX, Y, &strideY, param ); +} diff --git a/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_ndarray.c b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_ndarray.c new file mode 100644 index 000000000000..5bcd16dccbc6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm/src/drotm_ndarray.c @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +#include "stdlib/blas/base/drotm.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y second input array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param param parameters for the modified Givens transformation +*/ +void API_SUFFIX(c_drotm_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const double *param ) { + CBLAS_INT ix; + CBLAS_INT iy; + double dflag; + double dh11; + double dh12; + double dh21; + double dh22; + CBLAS_INT i; + double w; + double z; + + dflag = param[ 0 ]; + if ( N <= 0 || dflag == -2.0 ) { + return; + } + ix = offsetX; + iy = offsetY; + if ( strideX == strideY && strideX > 0 ) { + if ( dflag < 0.0 ) { + dh11 = param[ 1 ]; + dh12 = param[ 3 ]; + dh21 = param[ 2 ]; + dh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ ix ]; + X[ ix ] = ( w * dh11 ) + ( z * dh12 ); + Y[ ix ] = ( w * dh21 ) + ( z * dh22 ); + ix += strideX; + } + return; + } + if ( dflag == 0.0 ) { + dh12 = param[ 3 ]; + dh21 = param[ 2 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ ix ]; + X[ ix ] = w + ( z * dh12 ); + Y[ ix ] = ( w * dh21 ) + z; + ix += strideX; + } + return; + } + dh11 = param[ 1 ]; + dh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ ix ]; + X[ ix ] = ( w * dh11 ) + z; + Y[ ix ] = -w + ( z * dh22 ); + ix += strideX; + } + return; + } + if ( dflag < 0.0 ) { + dh11 = param[ 1 ]; + dh12 = param[ 3 ]; + dh21 = param[ 2 ]; + dh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ iy ]; + X[ ix ] = ( w * dh11 ) + ( z * dh12 ); + Y[ iy ] = ( w * dh21 ) + ( z * dh22 ); + ix += strideX; + iy += strideY; + } + return; + } + if ( dflag == 0.0 ) { + dh12 = param[ 3 ]; + dh21 = param[ 2 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ iy ]; + X[ ix ] = w + ( z * dh12 ); + Y[ iy ] = ( w * dh21 ) + z; + ix += strideX; + iy += strideY; + } + return; + } + dh11 = param[ 1 ]; + dh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ iy ]; + X[ ix ] = ( w * dh11 ) + z; + Y[ iy ] = -w + ( z * dh22 ); + ix += strideX; + iy += strideY; + } + return; +}