Re: [sage-devel] Product of immutable matrices are mutable...

2016-02-17 Thread Anne Schilling
Hi Florent, I usually define def prod_m(x,y): z=x*y z.set_immutable() return z and then pass this new product to the monoid/semigroup I am using! Best, Anne -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubs

Re: [sage-devel] Product of immutable matrices are mutable...

2016-02-17 Thread Florent Hivert
Hi Vincent, > 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 Not that much sage: a = identity_matrix(ZZ, 3) sage: b = copy(a + a) sage: b[0,1] = 2 # da F

Re: [sage-devel] Product of immutable matrices are mutable...

2016-02-17 Thread Vincent Delecroix
True. I was thinking about sage: M = MatrixSpace(ZZ,3) sage: a = M.one() sage: a.is_mutable() False On 17/02/16 13:16, Nathann Cohen wrote: 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

Re: [sage-devel] Product of immutable matrices are mutable...

2016-02-17 Thread Nathann Cohen
> 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 Why would identity_matrix return an immutable matrix ? Or did I miss something ? All that we need is that the sum/p

Re: [sage-devel] Product of immutable matrices are mutable...

2016-02-17 Thread Vincent Delecroix
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 gen

[sage-devel] Product of immutable matrices are mutable...

2016-02-17 Thread Florent Hivert
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