Hi Florent,
No. And this is indeed a problem. The only current workaround is to
replace the product with
p = a * b
p.set_immutable()
Note that this is more flexible than having some immutability by default
for the product. Though, as in your example it is a barrier for being
used in any generic code.
Having immutability by default would be particuarly annoying in the
following case
sage: a = identity_matrix(ZZ, 3)
sage: b = a + a # immutable
sage: b[0,1] = 2 # niet
Best,
Vincent
On 17/02/16 12:55, Florent Hivert wrote:
Hi there,
Is there a way to convince sage that the product of two mutable matrices are
immutable ?
I need to consider matrix over a finite ring as a monoid and to take the
monoid algebra (like a group algebra) of it. It works when defined but I can't
compute any product in It because group algebra are stored using
dict(element:coeff) and the product of the monoid returns unhashable matrices.
sage: M = MatrixSpace(QQ, 3)
sage: A = M.algebra(QQ, category=Monoids())
sage: A.one()^2
[...]
TypeError: mutable matrices are unhashable
Cheers,
Florent
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.