HP MLIB User's Guide Vol. 1 7th Ed.
236 HP MLIB User’s Guide
SGEMV/DGEMV/CGEMV/ZGEMV Matrix-vector multiply
Example 1 Form the REAL*4 matrix-vector product y = Ax, where A is a 9-by-6 real
matrix stored in an array A whose dimensions are 10-by-10, x is a real vector 6
elements long stored in an array X of dimension 10, and y is a real vector 9
elements long stored in an array Y, also of dimension 10.
CHARACTER*1 TRANS
INTEGER*4 M,N,LDA,INCX,INCY
REAL*4 ALPHA,BETA,A(10,10),X(10),Y(10)
TRANS = ’N’
M = 9
N = 6
ALPHA = 1.0
BETA = 0.0
LDA = 10
INCX = 1
INCY = 1
CALL SGEMV (TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
Example 2 Form the REAL*8 matrix-vector product , where ρ is a real
scalar, A is a 6-by-9 real matrix stored in an array A whose dimensions are
10-by-10, x is a real vector 6 elements long stored in an array X of dimension 10,
and y is a real vector 9 elements long stored in an array Y, also of dimension 10.
INTEGER*4 M,N,LDA
REAL*8 RHO,A(10,10),X(10),Y(10)
M = 9
N = 6
LDA = 10
CALL DGEMV (’TRANSPOSE’,M,N,-RHO,A,LDA,X,1,0.5D0,Y,1)
y
1
2
---
y ρA
T
x–=