How to perform Vector-Matrix Multiplication with BLAS ? -
How to perform Vector-Matrix Multiplication with BLAS ? -
blas defines gemv (matrix-vector multiplication) level-2 operation. how utilize blas library perform vector-matrix multiplication ?
it's obvious, don't see how utilize blas operation multiplication. have expected gevm operation.
the matrix-vector multiplication of (m x n) matrix (n x 1) vector result (m x 1) vector. in short a*a(mxn)*x(nx1) + b*y(mx1) -> y(mx1)
. of course of study can utilize incx
, incy
when vector included in matrix.
in order define vector-matrix multiplication vector should transposed. i.e. a*x(1xm)*a(mxn) + b*y(1xn) -> y(1xn)
. not have vector single row matrix.
starting point there 2 possibilities.
either utilize level-3 "gemm"
?gemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
using
?gemm('n', 'n', 1, n, m, a, x, 1, a, m, b, y, 1)
or more math. considering (x*a)^t = a^t * x^t
row matrix x
converted vector x^t(mx1). y
transpose vector y^t(nx1)
. of course of study memory-wise both x
, x^t
store same way, sequentially. means can utilize 1 time again gemv
using transpose matrix a
?gemv('t', m, n, a, a, m, x, 1, b, y, 1)
matrix matrix-multiplication blas
Comments
Post a Comment