The duplication matrix D n {\displaystyle D_{n}} is the unique n 2 × n ( n + 1 ) 2 {\displaystyle n^{2}\times {\frac {n(n+1)}{2}}} matrix which, for any n × n {\displaystyle n\times n} symmetric matrix A {\displaystyle A} , transforms v e c h ( A ) {\displaystyle \mathrm {vech} (A)} into v e c ( A ) {\displaystyle \mathrm {vec} (A)} :
For the 2 × 2 {\displaystyle 2\times 2} symmetric matrix A = [ a b b d ] {\displaystyle A=\left[{\begin{smallmatrix}a&b\\b&d\end{smallmatrix}}\right]} , this transformation reads
The explicit formula for calculating the duplication matrix for a n × n {\displaystyle n\times n} matrix is:
D n T = ∑ i ≥ j u i j ( v e c T i j ) T {\displaystyle D_{n}^{T}=\sum \limits _{i\geq j}u_{ij}(\mathrm {vec} T_{ij})^{T}}
Where:
Here is a C++ function using Armadillo (C++ library):
An elimination matrix L n {\displaystyle L_{n}} is a n ( n + 1 ) 2 × n 2 {\displaystyle {\frac {n(n+1)}{2}}\times n^{2}} matrix which, for any n × n {\displaystyle n\times n} matrix A {\displaystyle A} , transforms v e c ( A ) {\displaystyle \mathrm {vec} (A)} into v e c h ( A ) {\displaystyle \mathrm {vech} (A)} :
By the explicit (constructive) definition given by Magnus & Neudecker (1980), the 1 2 n ( n + 1 ) {\displaystyle {\frac {1}{2}}n(n+1)} by n 2 {\displaystyle n^{2}} elimination matrix L n {\displaystyle L_{n}} is given by
where e i {\displaystyle e_{i}} is a unit vector whose i {\displaystyle i} -th element is one and zeros elsewhere, and E i j = e i e j T {\displaystyle E_{ij}=e_{i}e_{j}^{T}} .
For the 2 × 2 {\displaystyle 2\times 2} matrix A = [ a b c d ] {\displaystyle A=\left[{\begin{smallmatrix}a&b\\c&d\end{smallmatrix}}\right]} , one choice for this transformation is given by
Magnus & Neudecker (1980), Definition 3.1 - Magnus, Jan R.; Neudecker, Heinz (1980), "The elimination matrix: some lemmas and applications", SIAM Journal on Algebraic and Discrete Methods, 1 (4): 422–449, doi:10.1137/0601049, ISSN 0196-5212 http://repository.uvt.nl/id/ir-uvt-nl:oai:wo.uvt.nl:153210 ↩