diff --git a/lib/node_modules/@stdlib/blas/base/srotm/README.md b/lib/node_modules/@stdlib/blas/base/srotm/README.md index 0cc3f3b264c..d5d0fbdf379 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/README.md +++ b/lib/node_modules/@stdlib/blas/base/srotm/README.md @@ -223,6 +223,33 @@ The function accepts the following arguments: void c_srotm( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float *param ); ``` +#### c_srotm_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY, param ) + +Applies a modified Givens plane rotation using alternative indexing semantics. + +```c +float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; +float y[] = { 6.0f, 7.0f, 8.0f, 9.0f, 10.0f }; +const float param[5] = { 0.0f, 0.0f, 2.0f, -3.0f, 0.0f }; + +c_srotm_ndarray( 5, x, 1, 0, y, 1, 0, param ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[inout] float*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[inout] float*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. +- **param**: `[in] float` parameters for the modified Givens transformation. + +```c +void c_srotm_ndarray( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float *param ); +``` + @@ -267,6 +294,14 @@ int main( void ) { for ( int i = 0; i < 5; i++ ) { printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] ); } + + // Apply plane rotation: + c_srotm_ndarray( N, x, -strideX, N-1, y, -strideY, N-1, param ); + + // Print the result: + for ( int i = 0; i < 5; i++ ) { + printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] ); + } } ``` diff --git a/lib/node_modules/@stdlib/blas/base/srotm/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/srotm/benchmark/c/benchmark.length.c index b8a5597f2a3..fb37d69a76e 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/srotm/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 ]; + double t; + int i; + + const float param[5] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float()*200.0f ) - 100.0f; + y[ i ] = ( rand_float()*200.0f ) - 100.0f; + } + + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_srotm_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/srotm/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/srotm/examples/c/example.c index 033f115a9f7..2f73fc99d48 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/srotm/examples/c/example.c @@ -41,4 +41,12 @@ int main( void ) { for ( int i = 0; i < 5; i++ ) { printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] ); } + + // Apply plane rotation: + c_srotm_ndarray( N, x, -strideX, N-1, y, -strideY, N-1, param ); + + // Print the result: + for ( int i = 0; i < 5; i++ ) { + printf( "x[ %i ] = %f, y[ %i ] = %f\n", i, x[ i ], i, y[ i ] ); + } } diff --git a/lib/node_modules/@stdlib/blas/base/srotm/include/stdlib/blas/base/srotm.h b/lib/node_modules/@stdlib/blas/base/srotm/include/stdlib/blas/base/srotm.h index b7507179f0f..3ea129f453a 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/include/stdlib/blas/base/srotm.h +++ b/lib/node_modules/@stdlib/blas/base/srotm/include/stdlib/blas/base/srotm.h @@ -36,6 +36,11 @@ extern "C" { */ void API_SUFFIX(c_srotm)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float *param ); +/** +* Applies a modified Givens plane rotation using alternative indexing semantics. +*/ +void API_SUFFIX(c_srotm_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float *param ); + #ifdef __cplusplus } #endif diff --git a/lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.js index 186079dd3c0..094b2691a15 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.js @@ -31,10 +31,10 @@ var f32 = require( '@stdlib/number/float64/base/to-float32' ); * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {NonNegativeInteger} offsetX - starting index for `x` * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - starting `y` index +* @param {NonNegativeInteger} offsetY - starting index for `y` * @param {Float32Array} param - parameters for the modified Givens transformation * @returns {Float32Array} `y` * diff --git a/lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.native.js index 5c0ce5ec198..308290c8274 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/srotm/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( './srotm.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -33,10 +31,10 @@ var addon = require( './srotm.native.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {NonNegativeInteger} offsetX - starting index for `x` * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - starting `y` index +* @param {NonNegativeInteger} offsetY - starting index for `y` * @param {Float32Array} param - parameters for the modified Givens transformation * @returns {Float32Array} `y` * @@ -52,16 +50,7 @@ var addon = require( './srotm.native.js' ); * // y => [ ~1.7, ~-0.9, ~0.5, ~0.7, ~-1.6, ~0.2, ~2.4 ] */ function srotm( 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/srotm/lib/srotm.js b/lib/node_modules/@stdlib/blas/base/srotm/lib/srotm.js index c4e028821d3..b80a75bc6ad 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/lib/srotm.js +++ b/lib/node_modules/@stdlib/blas/base/srotm/lib/srotm.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 srotm( N, x, strideX, y, strideY, param ) { - var sflag; - var ix; - var iy; - - sflag = param[ 0 ]; - if ( N <= 0 || sflag === -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/srotm/manifest.json b/lib/node_modules/@stdlib/blas/base/srotm/manifest.json index 717d6dd283b..fec31a73753 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/srotm/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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm.c" + "./src/srotm.c", + "./src/srotm_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/srotm/src/addon.c b/lib/node_modules/@stdlib/blas/base/srotm/src/addon.c index f7b4faf9af5..bc183c64358 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/srotm/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_FLOAT32ARRAY( env, param, paramlen, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 ); + API_SUFFIX(c_srotm_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/srotm/src/srotm.c b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm.c index 01402944f29..129f69fac6f 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/src/srotm.c +++ b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/srotm.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_srotm)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float *param ) { - CBLAS_INT ix; - CBLAS_INT iy; - float sflag; - float sh11; - float sh12; - float sh21; - float sh22; - CBLAS_INT i; - float w; - float z; - - sflag = param[ 0 ]; - if ( N <= 0 || sflag == -2.0f ) { - return; - } - if ( strideX == strideY && strideX > 0 ) { - ix = 0; - if ( sflag < 0.0f ) { - sh11 = param[ 1 ]; - sh12 = param[ 3 ]; - sh21 = param[ 2 ]; - sh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ ix ]; - X[ ix ] = ( w * sh11 ) + ( z * sh12 ); - Y[ ix ] = ( w * sh21 ) + ( z * sh22 ); - ix += strideX; - } - return; - } - if ( sflag == 0.0f ) { - sh12 = param[ 3 ]; - sh21 = param[ 2 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ ix ]; - X[ ix ] = w + ( z * sh12 ); - Y[ ix ] = ( w * sh21 ) + z; - ix += strideX; - } - return; - } - sh11 = param[ 1 ]; - sh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ ix ]; - X[ ix ] = ( w * sh11 ) + z; - Y[ ix ] = -w + ( z * sh22 ); - ix += strideX; - } - return; - } - if ( strideX < 0 ) { - ix = ( 1 - N ) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = ( 1 - N ) * strideY; - } else { - iy = 0; - } - if ( sflag < 0.0f ) { - sh11 = param[ 1 ]; - sh12 = param[ 3 ]; - sh21 = param[ 2 ]; - sh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ iy ]; - X[ ix ] = ( w * sh11 ) + ( z * sh12 ); - Y[ iy ] = ( w * sh21 ) + ( z * sh22 ); - ix += strideX; - iy += strideY; - } - return; - } - if ( sflag == 0.0f ) { - sh12 = param[ 3 ]; - sh21 = param[ 2 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ iy ]; - X[ ix ] = w + ( z * sh12 ); - Y[ iy ] = ( w * sh21 ) + z; - ix += strideX; - iy += strideY; - } - return; - } - sh11 = param[ 1 ]; - sh22 = param[ 4 ]; - for ( i = 0; i < N; i++ ) { - w = X[ ix ]; - z = Y[ iy ]; - X[ ix ] = ( w * sh11 ) + z; - Y[ iy ] = -w + ( z * sh22 ); - ix += strideX; - iy += strideY; - } - return; + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(c_srotm_ndarray)( N, X, strideX, ox, Y, strideY, oy, param ); } diff --git a/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_cblas.c b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_cblas.c index d0afb1c0cbd..52cc0b688ce 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_cblas.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/srotm.h" #include "stdlib/blas/base/srotm_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_srotm)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float *param ) { API_SUFFIX(cblas_srotm)( 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_srotm_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float *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_srotm)( N, X, strideX, Y, strideY, param ); +} diff --git a/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_f.c b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_f.c index 00ab7376fd0..6dac6ee9f75 100644 --- a/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_f.c +++ b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_f.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/srotm.h" #include "stdlib/blas/base/srotm_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_srotm)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float *param ) { srotm( &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_srotm_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float *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 + srotm( &N, X, &strideX, Y, &strideY, param ); +} diff --git a/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_ndarray.c b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_ndarray.c new file mode 100644 index 00000000000..53306fbb946 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srotm/src/srotm_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/srotm.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a 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_srotm_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float *param ) { + CBLAS_INT ix; + CBLAS_INT iy; + float sflag; + CBLAS_INT i; + float sh11; + float sh12; + float sh21; + float sh22; + float w; + float z; + + sflag = param[ 0 ]; + if ( N <= 0 || sflag == -2.0f ) { + return; + } + ix = offsetX; + iy = offsetY; + if ( strideX == strideY && strideX > 0 ) { + if ( sflag < 0.0f ) { + sh11 = param[ 1 ]; + sh12 = param[ 3 ]; + sh21 = param[ 2 ]; + sh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ ix ]; + X[ ix ] = ( w * sh11 ) + ( z * sh12 ); + Y[ ix ] = ( w * sh21 ) + ( z * sh22 ); + ix += strideX; + } + return; + } + if ( sflag == 0.0f ) { + sh12 = param[ 3 ]; + sh21 = param[ 2 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ ix ]; + X[ ix ] = w + ( z * sh12 ); + Y[ ix ] = ( w * sh21 ) + z; + ix += strideX; + } + return; + } + sh11 = param[ 1 ]; + sh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ ix ]; + X[ ix ] = ( w * sh11 ) + z; + Y[ ix ] = -w + ( z * sh22 ); + ix += strideX; + } + return; + } + if ( sflag < 0.0f ) { + sh11 = param[ 1 ]; + sh12 = param[ 3 ]; + sh21 = param[ 2 ]; + sh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ iy ]; + X[ ix ] = ( w * sh11 ) + ( z * sh12 ); + Y[ iy ] = ( w * sh21 ) + ( z * sh22 ); + ix += strideX; + iy += strideY; + } + return; + } + if ( sflag == 0.0f ) { + sh12 = param[ 3 ]; + sh21 = param[ 2 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ iy ]; + X[ ix ] = w + ( z * sh12 ); + Y[ iy ] = ( w * sh21 ) + z; + ix += strideX; + iy += strideY; + } + return; + } + sh11 = param[ 1 ]; + sh22 = param[ 4 ]; + for ( i = 0; i < N; i++ ) { + w = X[ ix ]; + z = Y[ iy ]; + X[ ix ] = ( w * sh11 ) + z; + Y[ iy ] = -w + ( z * sh22 ); + ix += strideX; + iy += strideY; + } + return; +}