Method: NMatrix::BLAS.gemv
- Defined in:
- lib/nmatrix_gemv/blas.rb
.gemv(a, x, y = nil, alpha = 1.0, beta = 0.0, transpose_a = false, m = nil, n = nil, lda = nil, incx = nil, incy = nil) ⇒ Object
call-seq:
gemv(a, x) -> NMatrix
gemv(a, x, y) -> NMatrix
gemv(a, x, y, alpha, beta) -> NMatrix
Implements matrix-vector product via
y = (alpha * A * x) + (beta * y)
where alpha and beta are scalar values.
-
Arguments :
-
a-> Matrix A. -
x-> Vector x. -
y-> Vector y. -
alpha-> A scalar value that multiplies A * x. -
beta-> A scalar value that multiplies y. -
transpose_a-> -
m-> -
n-> -
lda-> -
incx-> -
incy->
-
-
Returns : -
-
Raises :
-
++ ->
-
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/nmatrix_gemv/blas.rb', line 60 def gemv(a, x, y = nil, alpha = 1.0, beta = 0.0, transpose_a = false, m = nil, n = nil, lda = nil, incx = nil, incy = nil) raise(ArgumentError, 'Expected dense NMatrices as first two arguments.') unless a.is_a?(NMatrix) and x.is_a?(NMatrix) and a.stype == :dense and x.stype == :dense raise(ArgumentError, 'Expected nil or dense NMatrix as third argument.') unless y.nil? or (y.is_a?(NMatrix) and y.stype == :dense) raise(ArgumentError, 'NMatrix dtype mismatch.') unless a.dtype == x.dtype and (y ? a.dtype == y.dtype : true) m ||= transpose_a ? a.shape[1] : a.shape[0] n ||= transpose_a ? a.shape[0] : a.shape[1] lda ||= a.shape[1] incx ||= 1 incy ||= 1 # NM_COMPLEX64 and NM_COMPLEX128 both require complex alpha and beta. if a.dtype == :complex64 or a.dtype == :complex128 alpha = Complex(1.0, 0.0) if alpha == 1.0 beta = Complex(0.0, 0.0) if beta == 0.0 end y ||= NMatrix.new([m, n], dtype: a.dtype) NMatrix::BLAS.cblas_gemv(transpose_a, m, n, alpha, a, lda, x, incx, beta, y, incy) return y end |