Learn R Programming

MVT (version 0.3)

commutation: Commutation matrix for square matrices

Description

This function returns a commutation matrix of order n which transforms, for an n by n matrix x, vec(x) into vec(t(x)).

Usage

commutation(n = 2)

Arguments

n
a non-negative integer.

Value

Returns an square commutation matrix of order $n^2$ .

References

Magnus, J.R., and Neudecker, H. (1979). The commutation matrix: some properties and applications. The Annals of Statistics 7, 381-394.

Magnus, J.R., and Neudecker, H. (1999). Matrix Differential Calculus with Applications in Statistics and Econometrics, 2nd Edition. Wiley, New York.

Examples

Run this code
a <- matrix(1:9, ncol = 3)
kmat <- commutation(nrow(a))
vec <- as.vector(a)
## vectorization of t(a):
kmat %*% vec

Run the code above in your browser using DataLab