Thanks a lot for reporting! We *really* appreciate any feedback from using Sage in classes: on bugs, designs and feature requests.
This bug is now #23433. I'll push a patch momentarily. Best, Johan Rosenkilde Dima Pasechnik writes: > On Thursday, July 13, 2017 at 11:43:18 AM UTC+1, David Joyner wrote: >> >> On Thu, Jul 13, 2017 at 5:59 AM, 'B. L.' via sage-devel >> <sage-devel@googlegroups.com> wrote: >> > Dear Sage-Developers, >> > >> > I'd like to report two issues that I came across when working with the >> > coding theory classes of SAGE. >> > >> > The Sage Reference Manual: Coding Theory, Release 7.6 [1] explains on p. >> 31: >> > weight_enumerator [...] This is the bivariate, homogeneous polynomial in >> 𝑥 >> > and 𝑦 whose coefficient to x^iy^{n-i} is the number of codewords of >> > 𝑠𝑒𝑙𝑓 of Hamming weight 𝑖. Here, 𝑛 is the length of 𝑠𝑒𝑙𝑓. >> > Actually, Sage returns another polynomial, namely the polynomial in 𝑥 >> and >> > 𝑦 whose coefficient to x^{n-i}y^i is the number of codewords of >> 𝑠𝑒𝑙𝑓 of >> > Hamming weight 𝑖. (So the roles of x and y are interchanged). >> > This can be directly with C.weight_enumerator?? in the example below >> [2]. >> > >> > I suggest to either change the description in the reference or to alter >> the >> > code in Sage. >> > >> >> I'd propose just switching the x,y in the code: >> >> (1) On line 3503 of linear_code.py, change "return >> sum(spec[i]*x**(n-i)*y**i for i in range(n+1))" to "return >> sum(spec[i]*x**(i)*y**(n-i) for i in range(n+1))" >> >> (2) On line 3507, change "return sum(spec[i]*x**(n-i) for i in >> range(n+1))" to "return sum(spec[i]*x**(i) for i in range(n+1))" >> >> (3) Some of the examples may change accordingly. >> >> This mistake could be my fault, since I wrote the original version >> (long long ago). Unfortunately, I lack the git skills to submit a >> patch. >> >> A patch can be produced by > > git diff > stuff.patch > > It would be great if you opened a ticket and posted this diff as an > attachment... > > > >> >> > The function weight_enumerator(bivariate=False) returns the evaluation >> of >> > the the above polynomial for y=1. Should't it be (in the current >> version) >> > the evaluation with x=1? In other words: Wouldn't one expect a >> polynomial in >> > x (or y) whose coefficient to x^i (or y^i) is the number of codewords of >> > 𝑠𝑒𝑙𝑓 of Hamming weight 𝑖? >> > The example below [2] illustrates my point: The code has four codewords, >> one >> > of weight 0, two of weight 3, one of weiht 4. Sage gives x^5 + 2*x^2 + x >> as >> > the univariate weight enumerator. I would have expected either 1 + 2*x^3 >> + >> > x^4 or 1 + 2*y^3 + y^4. >> > >> > If you agree, I suggest to alter the code accordingly. >> > >> > Kind regards >> > Barbara >> > PS: I tested the code with Sage version 7.6 on an iMac. >> > >> > >> > [1] http://doc.sagemath.org/pdf/en/reference/coding/coding.pdf >> > >> > [2] Sage code for the SageMathCell >> > >> > C= LinearCode(Matrix(GF(2),2,5, [[1,1,0,1,0], [0,0,1,1,1]])) >> > print C.list() >> > print C.spectrum() >> > print C.weight_enumerator() >> > print C.weight_enumerator(bivariate=False) >> > C.weight_enumerator?? >> > >> > >> http://sagecell.sagemath.org/?z=eJxztlXwycxLTSxyzk9J1fBNLCnKrNBwd9Mw0tQx0jHVUYiONtQx1DEA4VggzwDMBMLYWE1NXq6Cosy8EgVnvZzM4hINJH5xQWpySVFpLrJYeWpmekZJfGpeaW5qUWJJfhF-yaTMssSizMSSVFu3xJziVKBaLKrs7QGIgD2K&lang=sage >> >> > >> > -- >> > 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. >> -- 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.