Learn R Programming

mcmcsae (version 0.7.8)

matrix-vector: 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)

Value

For %m*v% the vector \(Mv\) and for crossprod_mv the vector

\(M'v\) where \(M'\) denotes the transpose of \(M\).

Arguments

M

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

v

a numeric vector.

Examples

Run this code
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)

Run the code above in your browser using DataLab