Teach diagonal() to deal with sparse matrices