**[M-5] Dmatrix()** -- Duplication matrix

__Syntax__

*real matrix* **Dmatrix(***real scalar n***)**

__Description__

**Dmatrix(***n***)** returns the *n*^2 *x* *n*(*n*+1)/2 duplication matrix **D** for which
**D*****vech(***X***)** **=** **vec(***X***)**, where *X* is an arbitrary *n x n* symmetric matrix.

__Remarks__

Duplication matrices are frequently used in computing derivatives of
functions of symmetric matrices. Section 9.5 of Lütkepohl (1996) lists
many useful properties of duplication matrices.

__Conformability__

**Dmatrix(***n***)**:
*n*: 1 *x* 1
*result*: *n*^2 *x n*(*n* + 1)/2

__Diagnostics__

**Dmatrix(***n***)** aborts with error if *n* is less than 0 or is missing. *n* is
interpreted as **trunc(***n***)**.

__Source code__

dmatrix.mata

__Reference__

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