Fast extraction of matrix diagonal
qdiag(x)
The matrix to extract the diagonal from
A vector with the diagonal elements
Note this function can only be used for extraction