On Monday, May 12, 2014 11:12:19 PM UTC+8, Gerli Viikmaa wrote:
>
> Hi,
>
> Consider the following code (the field is arbitrary in this case)
> sage: code = codes.HammingCode(2, GF(4,'a'))
>
> The codewords (vectors) cannot be changed (note the absence of an error):
> sage: code[0]
> (0, 0, 0, 0, 0)
> sage: code[0][0] = 1
> sage: code[0]
> (0, 0, 0, 0, 0)
>
>
There is no error because code[0] regenerates the codeword every time you
call it. The reason for doing so is in http://trac.sagemath.org/ticket/13694
The vector is indeed being changed when you write code[0][0]=1. If you want
to create a set of immutable vectors, I suggest you simply run over the
list of codewords and set them to be immutable, as shown below. Beware that
this is good only for small codes. Running something like this over a
larger code means you will quickly run out of memory.
sage: C = codes.HammingCode(3, GF(2))
sage: codevectors = C.list()
sage: for c in codevectors: c.set_immutable()
sage:
sage: D = {c: c.hamming_weight() for c in codevectors}
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.