Hello,
While working on
http://trac.sagemath.org/ticket/18613 I ran into the following problem:
sage: matrix(2, 1).echelon_form().is_mutable()
False
sage: matrix(2, 0).echelon_form().is_mutable()
True
i.e. while usually echelon_form returns an immutable matrix this is not the case with trivial ones. The reason is in the beginning of its code:
if self._nrows == 0 or self._ncols == 0:
self.cache('pivots', ())
self.cache('rank', 0)
if transformation:
return self, self
return self
The question is how to fix it:
1) make here a copy of self, set it to be immutable, and return it
2) make self immutable and return self
3) always make matrices without elements immutable (not sure if this can be done in one place or in several implementations)
It seems that 3) is the most sensible, but what if some code checks for the ability to change a matrix a refuses to work with immutable ones? Any suggestions?
Thank you!
Andrey