**[M-5] Kmatrix()** -- Commutation matrix

__Syntax__

*real matrix* **Kmatrix(***real scalar m***,** *real scalar n***)**

__Description__

**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.

__Remarks__

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.

__Conformability__

**Kmatrix(***m***,** *n***)**:
*m*: 1 *x* 1
*n*: 1 *x* 1
*result*: *mn* *x mn*

__Diagnostics__

**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***)**.

__Source code__

kmatrix.mata

__Reference__

Lütkepohl, H. 1996. *Handbook of Matrices*. New York: Wiley.