Checks if a matrix is invertible.