From a4d32e795e6406b6e95075bd4f7ef81576e8ed76 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 12 Sep 2024 15:45:25 +0530 Subject: [PATCH 01/10] refactor: add C implementation for ndarray --- .../@stdlib/blas/base/srot/README.md | 49 ++++++++++++--- .../base/srot/benchmark/c/benchmark.length.c | 44 ++++++++++++- .../blas/base/srot/examples/c/example.c | 14 ++++- .../base/srot/include/stdlib/blas/base/srot.h | 5 ++ .../blas/base/srot/lib/ndarray.native.js | 15 +---- .../@stdlib/blas/base/srot/manifest.json | 63 +++++++++++-------- .../@stdlib/blas/base/srot/src/addon.c | 24 ++++++- .../@stdlib/blas/base/srot/src/srot.c | 43 +++++++------ .../@stdlib/blas/base/srot/src/srot_cblas.c | 20 ++++++ .../@stdlib/blas/base/srot/src/srot_f.c | 20 ++++++ 10 files changed, 226 insertions(+), 71 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srot/README.md b/lib/node_modules/@stdlib/blas/base/srot/README.md index ec8a73a35a3e..815231af6ddf 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/README.md +++ b/lib/node_modules/@stdlib/blas/base/srot/README.md @@ -213,7 +213,7 @@ Applies a plane rotation. float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; float y[] = { 6.0f, 7.0f, 8.0f, 9.0f, 10.0f }; -c_drot( 5, x, 1, y, 1, 0.8f, 0.6f ); +c_srot( 5, x, 1, y, 1, 0.8f, 0.6f ); ``` The function accepts the following arguments: @@ -227,7 +227,34 @@ The function accepts the following arguments: - **s**: `[in] float` sine of the angle of rotation. ```c -void c_drot( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s ); +void c_srot( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s ); +``` + +#### c_srot_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY, c, s ) + +Applies a 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 }; + +c_srot_ndarray( 5, x, 1, 0, y, 1, 0, 0.8f, 0.6f ); +``` + +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`. +- **c**: `[in] float` cosine of the angle of rotation. +- **s**: `[in] float` sine of the angle of rotation. + +```c +void c_srot_ndarray( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const float c, const float s ); ``` @@ -249,7 +276,7 @@ void c_drot( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, con ### Examples ```c -#include "stdlib/blas/base/drot.h" +#include "stdlib/blas/base/srot.h" #include int main( void ) { @@ -258,18 +285,26 @@ int main( void ) { float y[] = { 6.0f, 7.0f, 8.0f, 9.0f, 10.0f }; // Specify the number of elements: - const int N = 5; + const int N = 3; // Specify stride lengths: - const int strideX = 1; - const int strideY = 1; + const int strideX = 2; + const int strideY = -2; // Specify angle of rotation: const float c = 0.8f; const float s = 0.6f; // Apply plane rotation: - c_drot( N, x, strideX, y, strideY, c, s ); + c_srot( N, x, strideX, y, strideY, c, s ); + + // Print the result: + 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_srot_ndarray( N, x, strideX, 0, y, strideY, 4, c, s ); // Print the result: for ( int i = 0; i < 5; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/base/srot/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/srot/benchmark/c/benchmark.length.c index a22d74200361..38eb59e16c59 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/srot/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 ]; @@ -120,6 +120,39 @@ 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; + + 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_srot_ndarray( len, x, 1, 0, y, 1, 0, 0.8f, 0.6f ); + 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. */ @@ -142,7 +175,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/srot/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/srot/examples/c/example.c index c96100acbfae..83ae4d432206 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/srot/examples/c/example.c @@ -25,11 +25,11 @@ int main( void ) { float y[] = { 6.0f, 7.0f, 8.0f, 9.0f, 10.0f }; // Specify the number of elements: - const int N = 5; + const int N = 3; // Specify stride lengths: - const int strideX = 1; - const int strideY = 1; + const int strideX = 2; + const int strideY = -2; // Specify angle of rotation: const float c = 0.8f; @@ -42,4 +42,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_srot_ndarray( N, x, strideX, 0, y, strideY, 4, c, s ); + + // 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/srot/include/stdlib/blas/base/srot.h b/lib/node_modules/@stdlib/blas/base/srot/include/stdlib/blas/base/srot.h index af4bd0bbd97f..4206771149a6 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/include/stdlib/blas/base/srot.h +++ b/lib/node_modules/@stdlib/blas/base/srot/include/stdlib/blas/base/srot.h @@ -36,6 +36,11 @@ extern "C" { */ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s ); +/** +* Applies a plane rotation using alternative indexing semantics. +*/ +void API_SUFFIX(c_srot_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 c, const float s ); + #ifdef __cplusplus } #endif diff --git a/lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js index def0c29f9aea..2d4e349e75a4 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/srot/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( './srot.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -52,16 +50,7 @@ var addon = require( './srot.native.js' ); * // y => [ 6.0, 4.4, ~4.6, ~4.8, 5.0 ] */ function srot( N, x, strideX, offsetX, y, strideY, offsetY, c, s ) { - 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, c, s ); + addon.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, c, s ); return y; } diff --git a/lib/node_modules/@stdlib/blas/base/srot/manifest.json b/lib/node_modules/@stdlib/blas/base/srot/manifest.json index 508401f8d125..3de61059fe52 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/srot/manifest.json @@ -44,11 +44,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-strided-float32array" ] }, { @@ -65,7 +66,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -82,7 +84,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -104,11 +107,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-strided-float32array" ] }, { @@ -128,7 +132,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -148,7 +152,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -168,11 +172,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-strided-float32array" ] }, { @@ -189,7 +194,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -206,7 +212,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -227,11 +234,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-strided-float32array" ] }, { @@ -250,7 +258,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -269,7 +277,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -291,11 +299,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-strided-float32array" ] }, { @@ -315,7 +324,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -335,7 +344,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -354,11 +363,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-float" + "@stdlib/napi/argv-strided-float32array" ] }, { @@ -375,7 +385,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -392,7 +403,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -410,7 +422,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/srot/src/addon.c b/lib/node_modules/@stdlib/blas/base/srot/src/addon.c index 47241243e2fe..2498efd93603 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/addon.c @@ -45,4 +45,26 @@ 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, 9 ); + 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_FLOAT( env, c, argv, 7 ); + STDLIB_NAPI_ARGV_FLOAT( env, s, argv, 8 ); + 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_srot_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY, c, s ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot.c index 33378e215f87..4bee3ff9e4fa 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/srot.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" /** * Applies a plane rotation. @@ -31,6 +32,26 @@ * @param s sine of the angle of rotation */ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(c_srot_ndarray)( N, X, strideX, ox, Y, strideY, oy, c, s ); + return; +} + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for `X` +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for `Y` +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_srot_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 c, const float s ) { float tmp; CBLAS_INT ix; CBLAS_INT iy; @@ -39,26 +60,8 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, f if ( N <= 0 ) { return; } - // If both strides are equal to `1`... - if ( strideX == 1 && strideY == 1 ) { - for ( i = 0; i < N; i++ ) { - tmp = ( c * X[ i ] ) + ( s * Y[ i ] ); - Y[ i ] = ( c * Y[ i ] ) - ( s * X[ i ] ); - X[ i ] = tmp; - } - return; - } - // If both strides are not equal to `1`... - if ( strideX < 0 ) { - ix = ( 1 - N ) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = ( 1 - N ) * strideY; - } else { - iy = 0; - } + ix = offsetX; + iy = offsetY; for ( i = 0; i < N; i++ ) { tmp = ( c * X[ ix ] ) + ( s * Y[ iy ] ); Y[ iy ] = ( c * Y[ iy ] ) - ( s * X[ ix ] ); diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c index 5f0a65902536..58287693de5b 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/srot.h" #include "stdlib/blas/base/srot_cblas.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" /** * Applies a plane rotation. @@ -34,3 +35,22 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s ) { API_SUFFIX(cblas_srot)( N, X, strideX, Y, strideY, c, s ); } + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_srot_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float c, const float s ) { + 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_srot)( N, alpha, X, strideX, Y, strideY ); +} diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c index 3e70a4e3b74a..edb8ea1ca10e 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/srot.h" #include "stdlib/blas/base/srot_fortran.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" /** * Applies a plane rotation. @@ -34,3 +35,22 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY, const float c, const float s ) { srot( &N, X, &strideX, Y, &strideY, &c, &s ); } + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_srot_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const float c, const float s ) { + 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 + srot( &N, X, &strideX, Y, &strideY, &c, &s ); +} From 30469d556f16db1fb1365d0a0346983b764383f1 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 12 Sep 2024 16:25:22 +0530 Subject: [PATCH 02/10] refactor: add C implementation for ndarray --- .../base/drot/benchmark/c/benchmark.length.c | 44 ++++++++++++- .../blas/base/drot/examples/c/example.c | 14 ++++- .../base/drot/include/stdlib/blas/base/drot.h | 5 ++ .../blas/base/drot/lib/ndarray.native.js | 15 +---- .../@stdlib/blas/base/drot/manifest.json | 63 +++++++++++-------- .../@stdlib/blas/base/drot/src/addon.c | 24 ++++++- .../@stdlib/blas/base/drot/src/drot.c | 43 +++++++------ .../@stdlib/blas/base/drot/src/drot_cblas.c | 20 ++++++ .../@stdlib/blas/base/drot/src/drot_f.c | 20 ++++++ 9 files changed, 184 insertions(+), 64 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drot/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/drot/benchmark/c/benchmark.length.c index b522fce1d706..8bb1d80688ff 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/drot/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 ]; @@ -120,6 +120,39 @@ 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; + + 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_drot_ndarray( len, x, 1, 0, y, 1, 0, 0.8, 0.6 ); + 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. */ @@ -142,7 +175,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/drot/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/drot/examples/c/example.c index 86c9fd5c41be..ff492f3f55ca 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/drot/examples/c/example.c @@ -25,11 +25,11 @@ int main( void ) { double y[] = { 6.0, 7.0, 8.0, 9.0, 10.0 }; // Specify the number of elements: - const int N = 5; + const int N = 3; // Specify stride lengths: - const int strideX = 1; - const int strideY = 1; + const int strideX = 2; + const int strideY = -2; // Specify angle of rotation: const double c = 0.8; @@ -42,4 +42,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_drot_ndarray( N, x, strideX, 0, y, strideY, 4, c, s ); + + // 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/drot/include/stdlib/blas/base/drot.h b/lib/node_modules/@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h index 5042ea4cb30a..9e4e74a5e8ea 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h +++ b/lib/node_modules/@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h @@ -36,6 +36,11 @@ extern "C" { */ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double c, const double s ); +/** +* Applies a plane rotation using alternative indexing semantics. +*/ +void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ); + #ifdef __cplusplus } #endif diff --git a/lib/node_modules/@stdlib/blas/base/drot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/drot/lib/ndarray.native.js index fd2d583bb322..f101e40b2157 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/drot/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( './drot.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -52,16 +50,7 @@ var addon = require( './drot.native.js' ); * // y => [ 6.0, 4.4, ~4.6, ~4.8, 5.0 ] */ function drot( N, x, strideX, offsetX, y, strideY, offsetY, c, s ) { - 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, c, s ); + addon.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, c, s ); return y; } diff --git a/lib/node_modules/@stdlib/blas/base/drot/manifest.json b/lib/node_modules/@stdlib/blas/base/drot/manifest.json index fa3bb61162c9..bcbf6a4eb9e1 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/drot/manifest.json @@ -44,11 +44,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array" ] }, { @@ -65,7 +66,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -82,7 +84,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -104,11 +107,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array" ] }, { @@ -128,7 +132,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -148,7 +152,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -168,11 +172,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array" ] }, { @@ -189,7 +194,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -206,7 +212,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -227,11 +234,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array" ] }, { @@ -250,7 +258,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -269,7 +277,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -291,11 +299,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array" ] }, { @@ -315,7 +324,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -335,7 +344,7 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -354,11 +363,12 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array" ] }, { @@ -375,7 +385,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -392,7 +403,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -410,7 +422,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/drot/src/addon.c b/lib/node_modules/@stdlib/blas/base/drot/src/addon.c index c98a80dbd013..43f51971ce94 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/addon.c @@ -45,4 +45,26 @@ 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, 9 ); + 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_DOUBLE( env, c, argv, 7 ); + STDLIB_NAPI_ARGV_DOUBLE( env, s, argv, 8 ); + 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_drot_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY, c, s ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot.c index 14c5e8ea644e..099e5d4ceb9c 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/drot.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/drot.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" /** * Applies a plane rotation. @@ -31,6 +32,26 @@ * @param s sine of the angle of rotation */ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double c, const double s ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(c_drot_ndarray)( N, X, strideX, ox, Y, strideY, oy, c, s ); + return; +} + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ) { double tmp; CBLAS_INT ix; CBLAS_INT iy; @@ -39,26 +60,8 @@ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, if ( N <= 0 ) { return; } - // If both strides are equal to `1`... - if ( strideX == 1 && strideY == 1 ) { - for ( i = 0; i < N; i++ ) { - tmp = ( c * X[ i ] ) + ( s * Y[ i ] ); - Y[ i ] = ( c * Y[ i ] ) - ( s * X[ i ] ); - X[ i ] = tmp; - } - return; - } - // If both strides are not equal to `1`... - if ( strideX < 0 ) { - ix = ( 1 - N ) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = ( 1 - N ) * strideY; - } else { - iy = 0; - } + ix = offsetX; + iy = offsetY; for ( i = 0; i < N; i++ ) { tmp = ( c * X[ ix ] ) + ( s * Y[ iy ] ); Y[ iy ] = ( c * Y[ iy ] ) - ( s * X[ ix ] ); diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c index 7c557e79df02..d3e30c452d2e 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/drot.h" #include "stdlib/blas/base/drot_cblas.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" /** * Applies a plane rotation. @@ -34,3 +35,22 @@ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double c, const double s ) { API_SUFFIX(cblas_drot)( N, X, strideX, Y, strideY, c, s ); } + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const double c, const double s ) { + 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_drot)( N, alpha, X, strideX, Y, strideY ); +} diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c index 3546a5203635..848258d5f35a 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c @@ -19,6 +19,7 @@ #include "stdlib/blas/base/drot.h" #include "stdlib/blas/base/drot_fortran.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" /** * Applies a plane rotation. @@ -34,3 +35,22 @@ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double c, const double s ) { drot( &N, X, &strideX, Y, &strideY, &c, &s ); } + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ) { + 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 + drot( &N, X, &strideX, Y, &strideY, &c, &s ); +} From 7b1e54d8e3427c07d9ecd17829abb914aedf6fba Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 12 Sep 2024 16:40:40 +0530 Subject: [PATCH 03/10] docs: update README for drot --- .../@stdlib/blas/base/drot/README.md | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drot/README.md b/lib/node_modules/@stdlib/blas/base/drot/README.md index e06b96eee247..910e54fade31 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/README.md +++ b/lib/node_modules/@stdlib/blas/base/drot/README.md @@ -230,6 +230,33 @@ The function accepts the following arguments: void c_drot( const CBLAS_INT N, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, const double c, const double s ); ``` +#### c_drot_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY, c, s ) + +Applies a 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 }; + +c_drot_ndarray( 5, x, 1, 0, y, 1, 0, 0.8, 0.6 ); +``` + +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`. +- **c**: `[in] double` cosine of the angle of rotation. +- **s**: `[in] double` sine of the angle of rotation. + +```c +void c_drot_ndarray( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ); +``` + @@ -258,11 +285,11 @@ int main( void ) { double y[] = { 6.0, 7.0, 8.0, 9.0, 10.0 }; // Specify the number of elements: - const int N = 5; + const int N = 3; // Specify stride lengths: - const int strideX = 1; - const int strideY = 1; + const int strideX = 2; + const int strideY = -2; // Specify angle of rotation: const double c = 0.8; @@ -275,6 +302,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_drot_ndarray( N, x, strideX, 0, y, strideY, 4, c, s ); + + // Print the result: + for ( int i = 0; i < 5; i++ ) { + printf( "x[ %i ] = %lf, y[ %i ] = %lf\n", i, x[ i ], i, y[ i ] ); + } } ``` From 4a12fef2b03907804770c36b22a567495a565f00 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 13 Sep 2024 11:46:55 +0530 Subject: [PATCH 04/10] refactor: move ndarray API to seperate source --- .../@stdlib/blas/base/drot/manifest.json | 24 ++++++--- .../@stdlib/blas/base/drot/src/drot.c | 34 ------------ .../@stdlib/blas/base/drot/src/drot_ndarray.c | 54 +++++++++++++++++++ .../@stdlib/blas/base/srot/manifest.json | 24 ++++++--- .../@stdlib/blas/base/srot/src/srot.c | 34 ------------ .../@stdlib/blas/base/srot/src/srot_ndarray.c | 54 +++++++++++++++++++ 6 files changed, 140 insertions(+), 84 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c create mode 100644 lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c diff --git a/lib/node_modules/@stdlib/blas/base/drot/manifest.json b/lib/node_modules/@stdlib/blas/base/drot/manifest.json index bcbf6a4eb9e1..8b6d446e3272 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/drot/manifest.json @@ -58,7 +58,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" @@ -76,7 +77,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" @@ -186,7 +188,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" @@ -204,7 +207,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" @@ -354,7 +358,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" @@ -377,7 +382,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" @@ -395,7 +401,8 @@ "blas": "", "wasm": false, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" @@ -414,7 +421,8 @@ "blas": "", "wasm": true, "src": [ - "./src/drot.c" + "./src/drot.c", + "./src/drot_ndarray.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot.c index 099e5d4ceb9c..0a617c2a4012 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/drot.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot.c @@ -37,37 +37,3 @@ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, API_SUFFIX(c_drot_ndarray)( N, X, strideX, ox, Y, strideY, oy, c, s ); return; } - -/** -* Applies a plane rotation using alternative indexing semantics. -* -* @param N number of indexed elements -* @param X input array -* @param strideX X stride length -* @param offsetX starting index for X -* @param Y output array -* @param strideY Y stride length -* @param offsetY starting index for Y -* @param c cosine of the angle of rotation -* @param s sine of the angle of rotation -*/ -void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ) { - double tmp; - CBLAS_INT ix; - CBLAS_INT iy; - CBLAS_INT i; - - if ( N <= 0 ) { - return; - } - ix = offsetX; - iy = offsetY; - for ( i = 0; i < N; i++ ) { - tmp = ( c * X[ ix ] ) + ( s * Y[ iy ] ); - Y[ iy ] = ( c * Y[ iy ] ) - ( s * X[ ix ] ); - X[ ix ] = tmp; - ix += strideX; - iy += strideY; - } - return; -} diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c new file mode 100644 index 000000000000..168178ef9a61 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c @@ -0,0 +1,54 @@ +/** +* @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/drot.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ) { + double tmp; + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT i; + + if ( N <= 0 ) { + return; + } + ix = offsetX; + iy = offsetY; + for ( i = 0; i < N; i++ ) { + tmp = ( c * X[ ix ] ) + ( s * Y[ iy ] ); + Y[ iy ] = ( c * Y[ iy ] ) - ( s * X[ ix ] ); + X[ ix ] = tmp; + ix += strideX; + iy += strideY; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/srot/manifest.json b/lib/node_modules/@stdlib/blas/base/srot/manifest.json index 3de61059fe52..0b3b5db05400 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/srot/manifest.json @@ -58,7 +58,8 @@ "blas": "", "wasm": false, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" @@ -76,7 +77,8 @@ "blas": "", "wasm": false, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" @@ -186,7 +188,8 @@ "blas": "", "wasm": false, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" @@ -204,7 +207,8 @@ "blas": "", "wasm": false, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" @@ -354,7 +358,8 @@ "blas": "", "wasm": false, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" @@ -377,7 +382,8 @@ "blas": "", "wasm": false, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" @@ -395,7 +401,8 @@ "blas": "", "wasm": false, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" @@ -414,7 +421,8 @@ "blas": "", "wasm": true, "src": [ - "./src/srot.c" + "./src/srot.c", + "./src/srot_ndarray.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot.c index 4bee3ff9e4fa..b7c120628ffa 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot.c @@ -37,37 +37,3 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, f API_SUFFIX(c_srot_ndarray)( N, X, strideX, ox, Y, strideY, oy, c, s ); return; } - -/** -* Applies a plane rotation using alternative indexing semantics. -* -* @param N number of indexed elements -* @param X input array -* @param strideX X stride length -* @param offsetX starting index for `X` -* @param Y output array -* @param strideY Y stride length -* @param offsetY starting index for `Y` -* @param c cosine of the angle of rotation -* @param s sine of the angle of rotation -*/ -void API_SUFFIX(c_srot_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 c, const float s ) { - float tmp; - CBLAS_INT ix; - CBLAS_INT iy; - CBLAS_INT i; - - if ( N <= 0 ) { - return; - } - ix = offsetX; - iy = offsetY; - for ( i = 0; i < N; i++ ) { - tmp = ( c * X[ ix ] ) + ( s * Y[ iy ] ); - Y[ iy ] = ( c * Y[ iy ] ) - ( s * X[ ix ] ); - X[ ix ] = tmp; - ix += strideX; - iy += strideY; - } - return; -} diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c new file mode 100644 index 000000000000..74eb93dd8fdc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c @@ -0,0 +1,54 @@ +/** +* @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/srot.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for `X` +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for `Y` +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_srot_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 c, const float s ) { + float tmp; + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT i; + + if ( N <= 0 ) { + return; + } + ix = offsetX; + iy = offsetY; + for ( i = 0; i < N; i++ ) { + tmp = ( c * X[ ix ] ) + ( s * Y[ iy ] ); + Y[ iy ] = ( c * Y[ iy ] ) - ( s * X[ ix ] ); + X[ ix ] = tmp; + ix += strideX; + iy += strideY; + } + return; +} From a1c71e51f5b1ca3ea0c6d811eadbe558d2117ad9 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 19 Sep 2024 07:38:27 +0530 Subject: [PATCH 05/10] chore: resolve manifest error --- lib/node_modules/@stdlib/blas/base/drot/manifest.json | 6 ++++++ lib/node_modules/@stdlib/blas/base/srot/manifest.json | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/drot/manifest.json b/lib/node_modules/@stdlib/blas/base/drot/manifest.json index 8b6d446e3272..83614c2f4939 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/drot/manifest.json @@ -134,6 +134,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -154,6 +155,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -262,6 +264,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -281,6 +284,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -328,6 +332,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -348,6 +353,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, diff --git a/lib/node_modules/@stdlib/blas/base/srot/manifest.json b/lib/node_modules/@stdlib/blas/base/srot/manifest.json index 0b3b5db05400..dd508f67a177 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/srot/manifest.json @@ -134,6 +134,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -154,6 +155,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -262,6 +264,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -281,6 +284,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -328,6 +332,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, @@ -348,6 +353,7 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/strided/base/min-view-buffer-index" ] }, From 3e32b8529ec4ca5773f2d4f79d4b0f5ebed00fc6 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 19 Sep 2024 00:49:13 -0700 Subject: [PATCH 06/10] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h | 2 +- lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c | 2 +- lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c | 2 +- lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h b/lib/node_modules/@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h index 9e4e74a5e8ea..2d62297f1fdc 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h +++ b/lib/node_modules/@stdlib/blas/base/drot/include/stdlib/blas/base/drot.h @@ -39,7 +39,7 @@ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, /** * Applies a plane rotation using alternative indexing semantics. */ -void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ); +void API_SUFFIX(c_drot_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 c, const double s ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c index d3e30c452d2e..d58272128d59 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot_cblas.c @@ -49,7 +49,7 @@ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const double c, const double s ) { +void API_SUFFIX(c_drot_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 c, const double s ) { 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_drot)( N, alpha, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c index 848258d5f35a..99e15935655a 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot_f.c @@ -49,7 +49,7 @@ void API_SUFFIX(c_drot)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ) { +void API_SUFFIX(c_drot_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 c, const double s ) { 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 drot( &N, X, &strideX, Y, &strideY, &c, &s ); diff --git a/lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c b/lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c index 168178ef9a61..716b441e37dc 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/drot/src/drot_ndarray.c @@ -32,7 +32,7 @@ * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_drot_ndarray)( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ) { +void API_SUFFIX(c_drot_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 c, const double s ) { double tmp; CBLAS_INT ix; CBLAS_INT iy; From 4bfcc5fb4a333e7d623608e4db0c26dc4a6e229a Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 19 Sep 2024 00:55:50 -0700 Subject: [PATCH 07/10] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/drot/README.md | 2 +- lib/node_modules/@stdlib/blas/base/srot/README.md | 2 +- lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c | 2 +- lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drot/README.md b/lib/node_modules/@stdlib/blas/base/drot/README.md index 910e54fade31..f12f5efce11c 100644 --- a/lib/node_modules/@stdlib/blas/base/drot/README.md +++ b/lib/node_modules/@stdlib/blas/base/drot/README.md @@ -254,7 +254,7 @@ The function accepts the following arguments: - **s**: `[in] double` sine of the angle of rotation. ```c -void c_drot_ndarray( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const double c, const double s ); +void c_drot_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 c, const double s ); ``` diff --git a/lib/node_modules/@stdlib/blas/base/srot/README.md b/lib/node_modules/@stdlib/blas/base/srot/README.md index 815231af6ddf..0db8477dbc3c 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/README.md +++ b/lib/node_modules/@stdlib/blas/base/srot/README.md @@ -254,7 +254,7 @@ The function accepts the following arguments: - **s**: `[in] float` sine of the angle of rotation. ```c -void c_srot_ndarray( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const float c, const float s ); +void c_srot_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 c, const float s ); ``` diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c index 58287693de5b..d135dd0a654a 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c @@ -49,7 +49,7 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, f * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_srot_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, const float c, const float s ) { +void API_SUFFIX(c_srot_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 c, const float s ) { 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_srot)( N, alpha, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c index edb8ea1ca10e..d6e41d7840e9 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c @@ -49,7 +49,7 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, f * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_srot_ndarray)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, CBLAS_INT offsetY, const float c, const float s ) { +void API_SUFFIX(c_srot_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 c, const float s ) { 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 srot( &N, X, &strideX, Y, &strideY, &c, &s ); From 2d29b74eaf8a487b5c1d83b23f785aa7c4067f04 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 19 Sep 2024 18:15:30 +0530 Subject: [PATCH 08/10] chore: apply review changes --- lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js | 4 ++-- lib/node_modules/@stdlib/blas/base/srot/lib/srot.native.js | 4 ++-- lib/node_modules/@stdlib/blas/base/srot/src/srot.c | 4 ++-- lib/node_modules/@stdlib/blas/base/srot/src/srot.f | 4 ++-- lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c | 4 ++-- lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c | 4 ++-- lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js index 2d4e349e75a4..f9994f4469b1 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/srot/lib/ndarray.native.js @@ -29,10 +29,10 @@ var addon = require( './../src/addon.node' ); * Applies a plane rotation. * * @param {PositiveInteger} N - number of indexed elements -* @param {Float32Array} x - input array +* @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting `x` index -* @param {Float32Array} y - output array +* @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting `y` index * @param {number} c - cosine of the angle of rotation diff --git a/lib/node_modules/@stdlib/blas/base/srot/lib/srot.native.js b/lib/node_modules/@stdlib/blas/base/srot/lib/srot.native.js index 3d8390311986..25273afce4bb 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/lib/srot.native.js +++ b/lib/node_modules/@stdlib/blas/base/srot/lib/srot.native.js @@ -29,9 +29,9 @@ var addon = require( './../src/addon.node' ); * Applies a plane rotation. * * @param {PositiveInteger} N - number of indexed elements -* @param {Float32Array} x - input array +* @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length -* @param {Float32Array} y - output array +* @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @param {number} c - cosine of the angle of rotation * @param {number} s - sine of the angle of rotation diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot.c index b7c120628ffa..cf5dc70c6d5f 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot.c @@ -24,9 +24,9 @@ * Applies a plane rotation. * * @param N number of indexed elements -* @param X input array +* @param X first input array * @param strideX X stride length -* @param Y output array +* @param Y second input array * @param strideY Y stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot.f b/lib/node_modules/@stdlib/blas/base/srot/src/srot.f index 9c52b0becf8a..77d006369f63 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot.f +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot.f @@ -48,9 +48,9 @@ ! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. ! ! @param {integer} N - number of indexed elements -! @param {Array} sx - input array +! @param {Array} sx - first input array ! @param {integer} strideX - `sx` stride length -! @param {Array} sy - output array +! @param {Array} sy - second input array ! @param {integer} strideY - `sy` stride length ! @param {real} c - cosine of the angle of rotation ! @param {real} s - sine of the angle of rotation diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c index d135dd0a654a..7fa8b00752e8 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c @@ -25,9 +25,9 @@ * Applies a plane rotation. * * @param N number of indexed elements -* @param X input array +* @param X first input array * @param strideX X stride length -* @param Y output array +* @param Y second input array * @param strideY Y stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c index d6e41d7840e9..4b4635ad6adc 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c @@ -25,9 +25,9 @@ * Applies a plane rotation. * * @param N number of indexed elements -* @param X input array +* @param X first input array * @param strideX X stride length -* @param Y output array +* @param Y second input array * @param strideY Y stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c index 74eb93dd8fdc..aa98cbe5b620 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_ndarray.c @@ -23,10 +23,10 @@ * Applies a plane rotation using alternative indexing semantics. * * @param N number of indexed elements -* @param X input array +* @param X first input array * @param strideX X stride length * @param offsetX starting index for `X` -* @param Y output array +* @param Y second input array * @param strideY Y stride length * @param offsetY starting index for `Y` * @param c cosine of the angle of rotation From 9bb4fe6211aecd0fd6c314871f4a9db304fbbca8 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 20 Sep 2024 17:49:15 -0700 Subject: [PATCH 09/10] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c index 7fa8b00752e8..3260ba84a1be 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_cblas.c @@ -40,10 +40,10 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, f * Applies a plane rotation using alternative indexing semantics. * * @param N number of indexed elements -* @param X input array +* @param X first input array * @param strideX X stride length * @param offsetX starting index for X -* @param Y output array +* @param Y second input array * @param strideY Y stride length * @param offsetY starting index for Y * @param c cosine of the angle of rotation From fa170ffd2e15bb307b19b28527a6dd7cfb7c12ea Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 20 Sep 2024 17:50:07 -0700 Subject: [PATCH 10/10] Apply suggestions from code review Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c index 4b4635ad6adc..50519f152bac 100644 --- a/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c +++ b/lib/node_modules/@stdlib/blas/base/srot/src/srot_f.c @@ -40,10 +40,10 @@ void API_SUFFIX(c_srot)( const CBLAS_INT N, float *X, const CBLAS_INT strideX, f * Applies a plane rotation using alternative indexing semantics. * * @param N number of indexed elements -* @param X input array +* @param X first input array * @param strideX X stride length * @param offsetX starting index for X -* @param Y output array +* @param Y second input array * @param strideY Y stride length * @param offsetY starting index for Y * @param c cosine of the angle of rotation