|
16 | 16 | * limitations under the License. |
17 | 17 | */ |
18 | 18 |
|
19 | | -/** |
20 | | -* Header file containing function declarations for the C interface to the CBLAS Level 2 routine `cblas_dgemv`. |
21 | | -*/ |
22 | | -#ifndef DGEMV_CBLAS_H |
23 | | -#define DGEMV_CBLAS_H |
24 | | - |
| 19 | +#include "stdlib/blas/base/dgemv.h" |
| 20 | +#include "stdlib/blas/base/dgemv_cblas.h" |
25 | 21 | #include "stdlib/blas/base/shared.h" |
| 22 | +#include "stdlib/strided/base/min_view_buffer_index.h" |
| 23 | +#include "stdlib/ndarray/base/min_view_buffer_index.h" |
26 | 24 |
|
27 | | -/* |
28 | | -* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. |
| 25 | +/** |
| 26 | +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. |
| 27 | +* |
| 28 | +* @param order storage layout |
| 29 | +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed |
| 30 | +* @param M number of rows in the matrix `A` |
| 31 | +* @param N number of columns in the matrix `A` |
| 32 | +* @param alpha scalar constant |
| 33 | +* @param A input matrix |
| 34 | +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) |
| 35 | +* @param x first input vector |
| 36 | +* @param strideX `x` stride length |
| 37 | +* @param beta scalar constant |
| 38 | +* @param y second input vector |
| 39 | +* @param strideY `y` stride length |
| 40 | +* @return output value |
29 | 41 | */ |
30 | | -#ifdef __cplusplus |
31 | | -extern "C" { |
32 | | -#endif |
| 42 | +double API_SUFFIX(c_dgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT LDA, const double *x, const CBLAS_INT strideX, const double beta, const double *y, const CBLAS_INT strideY ) { |
| 43 | + CBLAS_INT sx = strideX; |
| 44 | + CBLAS_INT sy = strideY; |
| 45 | + if ( sx < 0 ) { |
| 46 | + sx = -sx; |
| 47 | + } |
| 48 | + if ( sy < 0 ) { |
| 49 | + sy = -sy; |
| 50 | + } |
| 51 | + return API_SUFFIX(cblas_dgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy ); |
| 52 | +} |
33 | 53 |
|
34 | 54 | /** |
35 | | -* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. |
| 55 | +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. |
| 56 | +* |
| 57 | +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed |
| 58 | +* @param M number of rows in the matrix `A` |
| 59 | +* @param N number of columns in the matrix `A` |
| 60 | +* @param alpha scalar constant |
| 61 | +* @param A input matrix |
| 62 | +* @param strideA1 stride of the first dimension of `A` |
| 63 | +* @param strideA1 stride of the second dimension of `A` |
| 64 | +* @param offsetA starting index for `A` |
| 65 | +* @param x first input vector |
| 66 | +* @param strideX `x` stride length |
| 67 | +* @param offsetX starting index for `x` |
| 68 | +* @param beta scalar constant |
| 69 | +* @param y second input vector |
| 70 | +* @param strideY `y` stride length |
| 71 | +* @param offsetY starting index for `Y` |
| 72 | +* @return output value |
36 | 73 | */ |
37 | | -void API_SUFFIX(cblas_dgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, const double beta, double *Y, const CBLAS_INT strideY ); |
38 | | - |
39 | | -#ifdef __cplusplus |
| 74 | +double API_SUFFIX(c_dgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double beta, const double *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { |
| 75 | + CBLAS_INT sx = strideX; |
| 76 | + CBLAS_INT sy = strideY; |
| 77 | + if ( sx < 0 ) { |
| 78 | + sx = -sx; |
| 79 | + } |
| 80 | + if ( sy < 0 ) { |
| 81 | + sy = -sy; |
| 82 | + } |
| 83 | + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer |
| 84 | + y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer |
| 85 | + const int64_t shape[] = { M, N }; |
| 86 | + const int64_t strides[] = { strideA1, strideA2 }; |
| 87 | + A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer |
| 88 | + return API_SUFFIX(cblas_dgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy ); |
40 | 89 | } |
41 | | -#endif |
42 | | - |
43 | | -#endif // !DGEMV_CBLAS_H |
|
0 commit comments