Method: NMatrix::BLAS.gemv
- Defined in:
- lib/nmatrix/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 :
-
++ ->
-
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/nmatrix/blas.rb', line 157 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 == :transpose ? a.shape[1] : a.shape[0] n ||= transpose_a == :transpose ? a.shape[0] : a.shape[1] raise(ArgumentError, "dimensions don't match") \ unless x.shape[0] == n && x.shape[1] == 1 if y raise(ArgumentError, "dimensions don't match") \ unless y.shape[0] == m && y.shape[1] == 1 else y = NMatrix.new([m,1], dtype: a.dtype) end lda ||= a.shape[1] incx ||= 1 incy ||= 1 ::NMatrix::BLAS.cblas_gemv(transpose_a, m, n, alpha, a, lda, x, incx, beta, y, incy) return y end |