I noticed some methods of BasicMatrix use a trick to create a zero matrix, 
then compiling its values and returning it, e.g.

        newmat = self.zeros(self.rows, self.cols + rhs.cols)

        newmat[:, :self.cols] = self

        newmat[:, self.cols:] = rhs

        return newmat

This works well for MutableMatrix, unfortunately self.zeros called on an 
instance of ImmutableMatrix returns and ImmutableMatrix of zeros which is 
immutable, raising an error on assignment.

A workaround would be to replace self.zeros( ... ) with 
MutableMatrix.zeros( ... ) and then replace return newmat with return 
type(self)(newmat).

Otherwise one could devise a way to allow __setitem__ to work on 
ImmutableMatrix as well, maybe returning a new matrix instead of modifying 
it.

Or maybe a better idea would be to use some .replace_somewhat( ... ) 
method, acting the same way as __setitem__, but returning a new matrix 
instead of modifying the current matrix.

What do you think?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to