## Projection matrix

Let $\mathcal{H}$ be a $D$-dimensional Hilbert space, and $L(\mathcal{H},\mathcal{H})$ be the $D\times D$ space of operators from $\mathcal{H}\rightarrow\mathcal{H}$. The projection matrix $P\in L(\mathcal{H},\mathcal{H})$ is defined as the square diagonal matrix with elements

\begin{align} P_{ij} = \delta_{ij}p_{j}, \hspace{1cm} p_{j}\in\text{{0,1}} \end{align}

where $\delta_{ij}$ is the Kronecker delta and $p_{j}$ is the $j$th diagonal element of $P$. Alternatively,

\begin{align} P = \text{diag}\left(p\right) \end{align}

where $p = (p_{1},…,p_{D})$ is the $D$-element vector defining the diagonal elements of $P$. The complement projection matrix $P^{c}$ is then defined by

\begin{align} P^{c} = \mathbb{I} - P \end{align}

where $\mathbb{I}$ is the $D\times D$ identity, such $P^{c}$ is also diagonal, with opposite-valued diagonal elements as $P$. Taking the trace of both sides yields the relation $D = \text{Tr}\left(P\right)+\text{Tr}\left(P^{c}\right)$, illustrating how the dimensions of $\mathcal{H}$ are partitioned under $P$ and $P^{c}$.