[M-5] Kmatrix() -- Commutation matrix
real matrix Kmatrix(real scalar m, real scalar n)
Kmatrix(m, n) returns the mn x mn commutation matrix K for which K*vec(X)
= vec(X'), where X is an m x n matrix.
Commutation matrices are frequently used in computing derivatives of
functions of matrices. Section 9.2 of Lütkepohl (1996) lists many useful
properties of commutation matrices.
m: 1 x 1
n: 1 x 1
result: mn x mn
Kmatrix(m, n) aborts with error if either m or n is less than 0 or is
missing. m and n are interpreted as trunc(m) and trunc(n).
Lütkepohl, H. 1996. Handbook of Matrices. New York: Wiley.