This is a bug. The `diagonalize` code assumes that the matrix it is working with is mutable. It should be fixed.