This function returns the ((r c) x (r c)) commutation matrix P such that
$$P vec(Y) = vec(Y'),$$
where Y is a (r x c) matrix.
Usage
commat(r, c)
Arguments
r
Number of rows of Y.
c
Number of columns of Y.
Value
A sparse ((r c) x (r c)) matrix.
References
Magnus, J.R., Neudecker, H. (2019), Matrix Differential Calculus with Applications
in Statistics and Econometrics, third edition, New York, Wiley, pp. 54-55.