diff --git a/lib/node_modules/@stdlib/blas/base/zaxpy/README.md b/lib/node_modules/@stdlib/blas/base/zaxpy/README.md index 12e11b4a6dd3..220a72046d2f 100644 --- a/lib/node_modules/@stdlib/blas/base/zaxpy/README.md +++ b/lib/node_modules/@stdlib/blas/base/zaxpy/README.md @@ -51,9 +51,9 @@ The function has the following parameters: - **N**: number of indexed elements. - **alpha**: scalar [`Complex128`][@stdlib/complex/float64/ctor] constant. - **x**: first input [`Complex128Array`][@stdlib/array/complex128]. -- **strideX**: index increment for `x`. +- **strideX**: stride length for `x`. - **y**: second input [`Complex128Array`][@stdlib/array/complex128]. -- **strideY**: index increment for `y`. +- **strideY**: stride length for `y`. The `N` and stride parameters determine how values from `x` are scaled by `alpha` and added to `y`. For example, to scale every other value in `x` by `alpha` and add the result to every other value of `y`, @@ -137,6 +137,7 @@ zaxpy.ndarray( 3, alpha, x, 1, 1, y, 1, 1 ); ## Notes - If `N <= 0`, both functions return `y` unchanged. +- If `alpha === 0`, both functions return `y` unchanged. - `zaxpy()` corresponds to the [BLAS][blas] level 1 function [`zaxpy`][zaxpy]. @@ -171,6 +172,14 @@ var alpha = new Complex128( 2.0, 2.0 ); // Scale values from `x` by `alpha` and add the result to `y`: zaxpy( x.length, alpha, x, 1, y, 1 ); +// Print the results: +logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y ); + +yc = zcopy( y.length, y, 1, zeros( y.length, 'complex128' ), 1 ); + +// Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics: +zaxpy.ndarray( x.length, alpha, x, 1, 0, y, 1, 0 ); + // Print the results: logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y ); ``` @@ -179,6 +188,152 @@ logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/zaxpy.h" +``` + +#### c_zaxpy( N, alpha, \*X, strideX, \*Y, strideY ) + +Scales values from `X` by `alpha` and adds the result to `Y`. + +```c +#include "stdlib/complex/float32/ctor.h" + +float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; +float y[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 }; +const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 ); + +c_zaxpy( 4, alpha, (void *)x, 1, (void *)y, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **alpha**: `[in] stdlib_complex128_t` scalar constant. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **Y**: `[inout] void*` output array. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. + +```c +void c_zaxpy( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *x, const CBLAS_INT strideX, void *y, const CBLAS_INT strideY ); +``` + +#### c_zaxpy_ndarray( N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY ) + +Scales values from `X` by `alpha` and adds the result to `Y` using alternative indexing semantics. + +```c +#include "stdlib/complex/float32/ctor.h" + +float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; +float y[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 }; +const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 ); + +c_zaxpy_ndarray( 4, alpha, (void *)x, 1, 0, (void *)y, 1, 0 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **alpha**: `[in] stdlib_complex128_t` scalar constant. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[inout] void*` output array. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. + +```c +void c_zaxpy_ndarray( const CBLAS_INT N, const stdlib_complex128_t alpha, const void *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/zaxpy.h" +#include "stdlib/complex/float32/ctor.h" +#include + +int main( void ) { + // Create strided arrays: + double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double y[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; + + // Create a complex scalar: + const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 ); + + // Specify the number of elements: + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = 1; + + // Scale values from `x` by `alpha` and add the result to `y`: + c_zaxpy( N, alpha, (void *)x, strideX, (void *)y, strideY ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] ); + } + + // Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics: + c_zaxpy_ndarray( N, alpha, (void *)x, strideX, 0, (void *)y, strideY, 0 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] ); + } +} +``` + +
+ + + +
+ + +