Skip to content

Commit 6e19980

Browse files
committed
docs: update readme for c implementation
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 227276a commit 6e19980

1 file changed

Lines changed: 108 additions & 7 deletions

File tree

  • lib/node_modules/@stdlib/blas/base/cgemv

lib/node_modules/@stdlib/blas/base/cgemv/README.md

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,82 @@ logEach( '%s', x );
242242
### Usage
243243

244244
```c
245-
TODO
245+
#include "stdlib/blas/base/cgemv.h"
246246
```
247247

248-
#### TODO
248+
#### c_cgemv( layout, trans, M, N, alpha, \*A, LDA, \*X, strideX, beta, \*Y, strideY )
249249

250-
TODO.
250+
Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` or `y = α*A^H*x + β*y` where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.
251251

252252
```c
253-
TODO
253+
#include "stdlib/blas/base/shared.h"
254+
#include "stdlib/complex/float32/ctor.h"
255+
256+
const float A[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 7.0f, 7.0f, 8.0f, 8.0f };
257+
const float x[] = { 1.0f, 1.0f, 2.0f, 2.0f };
258+
float y[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f };
259+
const stdlib_complex64_t alpha = stdlib_complex64( 0.5f, 0.5f );
260+
const stdlib_complex64_t beta = stdlib_complex64( 0.5f, -0.5f );
261+
262+
c_cgemv( CblasColMajor, CblasNoTrans, 4, 2, alpha, (void *)A, 4, (void *)x, 1, beta, (void *)y, 1 );
254263
```
255264
256-
TODO
265+
The function accepts the following arguments:
266+
267+
- **layout**: `[in] CBLAS_LAYOUT` storage layout.
268+
- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed.
269+
- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`.
270+
- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`.
271+
- **alpha**: `[in] stdlib_complex64_t` scalar constant.
272+
- **A**: `[in] void*` input matrix.
273+
- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
274+
- **X**: `[in] void*` first input vector.
275+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
276+
- **beta**: `[in] stdlib_complex64_t` scalar constant.
277+
- **Y**: `[inout] void*` second input vector.
278+
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
257279
258280
```c
259-
TODO
281+
void c_cgemv( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t alpha, const void *A, const CBLAS_INT LDA, const void *X, const CBLAS_INT strideX, const stdlib_complex64_t beta, void *Y, const CBLAS_INT strideY )
282+
```
283+
284+
#### c_cgemv_ndarray( trans, M, N, alpha, \*A, sa1, sa2, oa, \*X, sx, ox, beta, \*Y, sy, oy )
285+
286+
Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` or `y = α*A^H*x + β*y`, using indexing alternative semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.
287+
288+
```c
289+
#include "stdlib/blas/base/shared.h"
290+
#include "stdlib/complex/float32/ctor.h"
291+
292+
const float A[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 7.0f, 7.0f, 8.0f, 8.0f };
293+
const float x[] = { 1.0f, 1.0f, 2.0f, 2.0f };
294+
float y[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f };
295+
const stdlib_complex64_t alpha = stdlib_complex64( 0.5f, 0.5f );
296+
const stdlib_complex64_t beta = stdlib_complex64( 0.5f, -0.5f );
297+
298+
c_cgemv( CblasNoTrans, 4, 2, alpha, (void *)A, 4, (void *)x, 1, 0, beta, (void *)y, 1, 0 );
299+
```
300+
301+
The function accepts the following arguments:
302+
303+
- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed.
304+
- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`.
305+
- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`.
306+
- **alpha**: `[in] stdlib_complex64_t` scalar constant.
307+
- **A**: `[in] void*` input matrix.
308+
- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`.
309+
- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`.
310+
- **oa**: `[in] CBLAS_INT` starting index for `A`.
311+
- **X**: `[in] void*` first input vector.
312+
- **sx**: `[in] CBLAS_INT` stride length for `X`.
313+
- **ox**: `[in] CBLAS_INT` starting index for `X`.
314+
- **beta**: `[in] stdlib_complex64_t` scalar constant.
315+
- **Y**: `[inout] void*` second input vector.
316+
- **sy**: `[in] CBLAS_INT` stride length for `Y`.
317+
- **oy**: `[in] CBLAS_INT` starting index for `Y`.
318+
319+
```c
320+
void c_cgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t alpha, const void *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const stdlib_complex64_t beta, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY )
260321
```
261322

262323
</section>
@@ -278,7 +339,47 @@ TODO
278339
### Examples
279340

280341
```c
281-
TODO
342+
#include "stdlib/blas/base/cgemv.h"
343+
#include "stdlib/blas/base/shared.h"
344+
#include "stdlib/complex/float32/ctor.h"
345+
#include <stdio.h>
346+
347+
int main( void ) {
348+
// Define a 3x3 matrix stored in row-major order:
349+
const float A[ 3*3*2 ] = {
350+
1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f,
351+
4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f,
352+
7.0f, 7.0f, 8.0f, 8.0f, 9.0f, 9.0f
353+
};
354+
355+
// Define `x` and `y` vectors:
356+
const float x[ 3*2 ] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f };
357+
float y[ 3*2 ] = { 3.0f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f };
358+
359+
// Create complex scalars:
360+
const stdlib_complex64_t alpha = stdlib_complex64( 0.5f, 0.5f );
361+
const stdlib_complex64_t beta = stdlib_complex64( 0.5f, -0.5f );
362+
363+
// Specify the number of elements along each dimension of `A`:
364+
const int M = 3;
365+
const int N = 3;
366+
367+
// Perform the matrix-vector operation `y = α*A*x + β*y`:
368+
c_cgemv( CblasRowMajor, CblasNoTrans, M, N, alpha, (void *)A, M, (void *)x, 1, beta, (void *)y, 1 );
369+
370+
// Print the result:
371+
for ( int i = 0; i < N; i++ ) {
372+
printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
373+
}
374+
375+
// Perform the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics:
376+
c_cgemv_ndarray( CblasNoTrans, M, N, alpha, (void *)A, N, 1, 0, (void *)x, 1, 0, beta, (void *)y, 1, 0 );
377+
378+
// Print the result:
379+
for ( int i = 0; i < N; i++ ) {
380+
printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
381+
}
382+
}
282383
```
283384
284385
</section>

0 commit comments

Comments
 (0)