?gemv
Compute the product of a vector and a matrix.
,
or 
For the Fortran interface:
,
, or 
alpha and beta are multiplication coefficients, x and y are vectors, and A is a general m x n matrix.
Interface Definition
C interface:
void cblas_sgemv(const enum CBLAS_ORDER order, const enum CBLAS_TRANSPOSE trans, const BLASINT m, const BLASINT n, const float alpha, const float *a, const BLASINT lda, const float *x, const BLASINT incx, const float beta, float *y, const BLASINT incy);
void cblas_dgemv(const enum CBLAS_ORDER order, const enum CBLAS_TRANSPOSE trans, const BLASINT m, const BLASINT n, const double alpha, const double *a, const BLASINT lda, const double *x, const BLASINT incx, const double beta, double *y, const BLASINT incy);
void cblas_cgemv(const enum CBLAS_ORDER order, const enum CBLAS_TRANSPOSE trans, const BLASINT m, const BLASINT n, const void *alpha, const void *a, const BLASINT lda, const void *x, const BLASINT incx, const void *beta, void *y, const BLASINT incy);
void cblas_zgemv(const enum CBLAS_ORDER order, const enum CBLAS_TRANSPOSE trans, const BLASINT m, const BLASINT n, const void *alpha, const void *a, const BLASINT lda, const void *x, const BLASINT incx, const void *beta, void *y, const BLASINT incy);
Fortran interface:
CALL SGEMV(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CALL DGEMV(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CALL CGEMV(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CALL ZGEMV(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
order |
Enumeration type CBLAS_ORDER |
Indicates whether the matrix is in row- or column-major order. |
Input |
trans |
Enumeration type CBLAS_TRANSPOSE |
Operation of matrix A.
For the Fortran interface: |
Input |
m |
Integer |
Number of rows in matrix A. The value of m must be greater than or equal to 0. |
Input |
n |
Integer |
Number of columns of matrix A. The value of n must be greater than or equal to 0. |
Input |
alpha |
|
Multiplication coefficient |
Input |
a |
|
Matrix. The matrix size is lda*n. |
Input |
lda |
Integer |
Length of the primary dimension in matrix A. If A is a column-store matrix, lda must be greater than or equal to max(1, m). Otherwise, lda must be greater than or equal to max(1, n). |
Input |
x |
|
Vector x, If trans = CblasNoTrans, the vector size is at least (1+(n-1)*abs(incx)). Otherwise, the vector size is at least (1+(m-1)*abs(incy)). |
Input |
incx |
Integer |
Increment for elements in X. The value cannot be 0. |
Input |
beta |
|
Multiplication coefficient |
Input |
y |
|
Vector y. If trans = CblasNoTrans, the vector size is at least (1+(m-1)*abs(incy)). Otherwise, the vector size is at least (1+(n-1)*abs(incy)). |
Input/Output |
incy |
Integer |
Increment for elements in y. The value cannot be 0. |
Input |
Dependencies
#include "kblas.h"
Examples
C interface:
int m = 3, n = 3, lda = 3, incx = 1, incy = 1;
float alpha = 1.0, beta = 2.0;
/**
* A:
* 0.340188, 0.298440, -0.164777
* -0.105617, 0.411647, 0.268230
* 0.283099, -0.302449, -0.222225
* X:
* 0.053970, -0.022603, 0.128871
* Y:
* -0.135216, 0.013401, 0.452230
*/
float a[9] = {0.340188, 0.298440, -0.164777,
-0.105617, 0.411647, 0.268230,
0.283099, -0.302449, -0.222225};
float x[3] = {0.053970, -0.022603, 0.128871};
float y[3] = {-0.135216, 0.013401, 0.452230};
cblas_sgemv(CblasColMajor,CblasNoTrans, m, n, alpha, a, lda, x, incx, beta, y, incy);
/**
* Output Y: -0.213202, -0.005373, 0.860866
*
*/
Fortran interface:
INTEGER :: M=3
INTEGER :: N=3
INTEGER :: LDA=3
INTEGER :: INCX=1
INTEGER :: INCY=1
REAL(4) :: ALPHA=1.0
REAL(4) :: BETA=2.0
REAL(4) :: A(3, 3)
DATA A/0.340188, 0.298440, -0.164777,
$ -0.105617, 0.411647, 0.268230,
$ 0.283099, -0.302449, -0.222225/
REAL(4) :: X(3)
DATA X/0.053970, -0.022603, 0.128871/
REAL(4) :: Y(3)
DATA Y/-0.135216, 0.013401, 0.452230/
EXTERNAL SGEMV
CALL SGEMV('N', M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
* Output Y: -0.213201538, -5.37255174E-03, 0.860865831





