Duplication and elimination matrices

From HandWiki

In mathematics, especially in linear algebra and matrix theory, the duplication matrix and the elimination matrix are linear transformations used for transforming half-vectorizations of matrices into vectorizations or (respectively) vice versa.

Duplication matrix

The duplication matrix Dn is the unique n2×n(n+1)2 matrix which, for any n×n symmetric matrix A, transforms vech(A) into vec(A):

Dnvech(A)=vec(A).

For the 2×2 symmetric matrix A=[abbd], this transformation reads

Dnvech(A)=vec(A)[100010010001][abd]=[abbd]


The explicit formula for calculating the duplication matrix for a n×n matrix is:

DnT=ijuij(vecTij)T

Where:

  • uij is a unit vector of order 12n(n+1) having the value 1 in the position (j1)n+i12j(j1) and 0 elsewhere;
  • Tij is a n×n matrix with 1 in position (i,j) and (j,i) and zero elsewhere

Here is a C++ function using Armadillo (C++ library):

arma::mat duplication_matrix(const int &n) {
    arma::mat out((n*(n+1))/2, n*n, arma::fill::zeros);
    for (int j = 0; j < n; ++j) {
        for (int i = j; i < n; ++i) {
            arma::vec u((n*(n+1))/2, arma::fill::zeros);
            u(j*n+i-((j+1)*j)/2) = 1.0;
            arma::mat T(n,n, arma::fill::zeros);
            T(i,j) = 1.0;
            T(j,i) = 1.0;
            out += u * arma::trans(arma::vectorise(T));
        }
    }
    return out.t();
}

Elimination matrix

An elimination matrix Ln is a n(n+1)2×n2 matrix which, for any n×n matrix A, transforms vec(A) into vech(A):

Lnvec(A)=vech(A)[1]

By the explicit (constructive) definition given by (Magnus Neudecker), the 12n(n+1) by n2 elimination matrix Ln is given by

Ln=ijuijvec(Eij)T=ij(uijejTeiT),

where ei is a unit vector whose i-th element is one and zeros elsewhere, and Eij=eiejT.

Here is a C++ function using Armadillo (C++ library):

arma::mat elimination_matrix(const int &n) {
    arma::mat out((n*(n+1))/2, n*n, arma::fill::zeros);
    for (int j = 0; j < n; ++j) {
        arma::rowvec e_j(n, arma::fill::zeros);
        e_j(j) = 1.0;
        for (int i = j; i < n; ++i) {
            arma::vec u((n*(n+1))/2, arma::fill::zeros);
            u(j*n+i-((j+1)*j)/2) = 1.0;
            arma::rowvec e_i(n, arma::fill::zeros);
            e_i(i) = 1.0;
            out += arma::kron(u, arma::kron(e_j, e_i));
        }
    }
    return out;
}

For the 2×2 matrix A=[abcd], one choice for this transformation is given by

Lnvec(A)=vech(A)[100001000001][acbd]=[acd].

Notes

  1. (Magnus Neudecker), Definition 3.1

References

de:Eliminationsmatrix