Check whether a matrix is a diagonal matrix or not