Added diag() for extracting a diagonal (or off-diagonal) of a matrix, or for generating a square matrix out of a vector with the specified (off-)diagonal.

Same functionality as MATLAB's diag() function. Supports all three backends.