Implemented diag() function