Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#4899 closed defect (fixed)

[with patch, positive review] bug in sqrt(1) over GF(2^e) for e>15

Reported by: cremona Owned by: tbd
Priority: minor Milestone: sage-3.2.3
Component: algebra Keywords: finite fields
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

GitHub link to the corresponding issue

Description

sage: GF(2^15,'a')(1).sqrt()
1
sage: GF(2^16,'a')(1).sqrt()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/john/<ipython console> in <module>()

/home/john/sage-3.2.2.rc1/local/lib/python2.5/site-packages/sage/rings/finite_field_ntl_gf2e.so in sage.rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2eElement.sqrt (sage/rings/finite_field_ntl_gf2e.cpp:7072)()

AttributeError: 'sage.rings.finite_field_ntl_gf2e.FiniteField_ntl_g' object has no attribute '_one_element'

The point is that GF(2^16) (and higher) are of type 'sage.rings.finite_field_ntl_gf2e.FiniteField_ntl_gf2e' and the code (lines 826,827 in finite_field_ntl_gf2e.pyx)

        if self.is_one():
            return self._one_element

fails. It should be self.parent()._one_element (though I don't know why "return self" would not be ok too).

Patch up very soon.

Attachments (2)

trac_4899.patch (1.0 KB) - added by cremona 14 years ago.
trac_4899-referee.patch (703 bytes) - added by was 14 years ago.
apply this after trac_4899.patch

Download all attachments as: .zip

Change History (8)

Changed 14 years ago by cremona

Attachment: trac_4899.patch added

comment:1 Changed 14 years ago by cremona

Summary: bug in sqrt(1) over GF(2^e) for e>15[with patch, needs review (trivial!)] bug in sqrt(1) over GF(2^e) for e>15

Changed 14 years ago by was

Attachment: trac_4899-referee.patch added

apply this after trac_4899.patch

comment:2 Changed 14 years ago by was

Summary: [with patch, needs review (trivial!)] bug in sqrt(1) over GF(2^e) for e>15[with patch, positive review] bug in sqrt(1) over GF(2^e) for e>15

REFEREE REPORT:

Nice find. You remark "It should be self.parent()._one_element (though I don't know why "return self" would not be ok too).". In fact, I think returning self would be ok. I tried that and it is also over twice as fast. So I've posted a followup patch that does that instead.

comment:3 Changed 14 years ago by mabshoff

Shouldn't we add a doctest here?

Cheers,

Michael

comment:4 Changed 14 years ago by mabshoff

Milestone: sage-3.4sage-3.2.3

comment:5 Changed 14 years ago by mabshoff

Resolution: fixed
Status: newclosed

Merged both patches in Sage 3.2.3.final

comment:6 Changed 14 years ago by mabshoff

Never mind, John's patch contained a doctest as William just pointed out to me in IRC.

Cheers,

Michael

Note: See TracTickets for help on using tickets.