matrix-vector: Fast matrix-vector multiplications

matrix-vectorR Documentation

Fast matrix-vector multiplications

Description

Functions for matrix-vector multiplies like %*% and crossprod, but often faster for the matrix types supported. The return value is always a numeric vector.

Usage

M %m*v% v

crossprod_mv(M, v)

Arguments

M

a matrix of class 'matrix', 'dgCMatrix', 'dsCMatrix', 'tabMatrix', or 'ddiMatrix'.

v

a numeric vector.

Value

For %m*v% the vector Mv and for crossprod_mv the vector M'v where M' denotes the transpose of M.

Examples

M <- matrix(rnorm(10*10), 10, 10)
x <- rnorm(10)
M %m*v% x
crossprod_mv(M, x)
M <- Matrix::rsparsematrix(100, 100, nnz=100)
x <- rnorm(100)
M %m*v% x
crossprod_mv(M, x)


mcmcsae documentation built on Oct. 11, 2023, 1:06 a.m.