comm.prod {fastmatrix} | R Documentation |
Matrix multiplication envolving the commutation matrix
Description
Given the row and column dimensions of a commutation matrix \bold{K}
of order
mn
and a conformable matrix \bold{x}
, performs one of the matrix-matrix
operations:
-
\bold{Y} = \bold{KX}
, ifside = "left"
andtransposed = FALSE
, or -
\bold{Y} = \bold{K}^T\bold{X}
, ifside = "left"
andtransposed = TRUE
, or -
\bold{Y} = \bold{XK}
, ifside = "right"
andtransposed = FALSE
, or -
\bold{Y} = \bold{XK}^T
, ifside = "right"
andtransposed = TRUE
.
The main aim of comm.prod
is to do this matrix multiplication without forming
the commutation matrix.
Usage
comm.prod(m = 1, n = m, x = NULL, transposed = FALSE, side = "left")
Arguments
m |
a positive integer row dimension. |
n |
a positive integer column dimension. |
x |
numeric matrix (or vector). |
transposed |
logical. Commutation matrix should be transposed? |
side |
a string selecting if commutation matrix is pre-multiplying |
Details
Underlying Fortran
code only uses information provided by comm.info
to performs the matrix multiplication. The commutation matrix is never created.
See Also
Examples
K42 <- commutation(m = 4, n = 2, matrix = TRUE)
x <- matrix(1:24, ncol = 3)
y <- K42 %*% x
z <- comm.prod(m = 4, n = 2, x) # K42 is not stored
all(z == y) # matrices y and z are equal!