我要评分
获取效率
正确性
完整性
易理解

?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.

  • If trans = CblasNoTrans, then .
  • If trans = CblasTrans, then .
  • If trans = CblasConjTrans, then .

For the Fortran interface:

  • If TransA = R,

    .

  • If TransA = S,

    .

  • If TransA = D,

    .

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

  • For sgemv, alpha is of single-precision floating-point type.
  • For dgemv, alpha is of double-precision floating-point type.
  • For cgemv, alpha is of single-precision complex number type.
  • For zgemv, alpha is of double-precision complex number type.

Multiplication coefficient

Input

a

  • For sgemv, a is of single-precision floating-point type.
  • For dgemv, a is of double-precision floating-point type.
  • For cgemv, a is of single-precision complex number type.
  • For zgemv, a is of double-precision complex number type.

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

  • For sgemv, x is of single-precision floating-point type.
  • For dgemv, x is of double-precision floating-point type.
  • For cgemv, x is of single-precision complex number type.
  • For zgemv, x is of double-precision complex number type.

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

  • For sgemv, beta is of single-precision floating-point type.
  • For dgemv, beta is of double-precision floating-point type.
  • For cgemv, beta is of single-precision complex number type.
  • For zgemv, beta is of double-precision complex number type.

Multiplication coefficient

Input

y

  • For sgemv, y is of single-precision floating-point type.
  • For dgemv, y is of double-precision floating-point type.
  • For cgemv, y is of single-precision complex number type.
  • For zgemv, y is of double-precision complex number type.

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