Hi there,

I have a slightly stupid question ! First of all consider the following
behavior (sage 4.3.2):

sage: A = MatrixSpace(ZZ, 3)
sage: A.one()
[1 0 0]
[0 1 0]
[0 0 1]
sage: A.one()[1,2] = 1
sage: A.one()
[1 0 0]
[0 1 1]
[0 0 1]

This is definitely bad. It happens because one is generically computed by
coercion from 1 and then cached without making it immutable. I see at least
three solutions:

 1. - Don't cache at all
 2. - Return a cached immutable
 3. - Return a mutable copy of a cached

To have an idea of the usage I went trough the code:

 - MatrixSpace.identity_matrix implement 1.
 - MatrixSpace.zero_matrix implement 3.

Of course, my opinion is to make those three methods implements 2. :-)

Any arguments in favor one or one other ?

Cheers,

Florent

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to