#9524: Nasty bug with polynomial arithmetic and NTL contexts
------------------------------------+--------------------------
       Reporter:  craigcitro        |        Owner:  AlexGhitza
           Type:  defect            |       Status:  new
       Priority:  major             |    Milestone:  sage-6.2
      Component:  basic arithmetic  |   Resolution:
       Keywords:                    |    Merged in:
        Authors:                    |    Reviewers:
Report Upstream:  N/A               |  Work issues:
         Branch:                    |       Commit:
   Dependencies:                    |     Stopgaps:
------------------------------------+--------------------------

Old description:

> I just ran into the following nasty bug:
>
> {{{
> sage: polygen(GF(49, 'a')) ; polygen(GF(9, 'a'))
> x
> x
> sage: x = polygen(GF(49, 'a'))
> sage: -x
> 2*x
> sage: x + 0
> x
> sage: -x
> 6*x
> }}}
>
> This is still present in sage-4.5.
>
> I think I know what the problem is, but I haven't had time to sit down
> and fix it. It's an issue with the NTL context being correctly restored
> when switching from 7 to 3 and back. There's a very nice note (by David
> Roe, I think) in most of the `_p` files in NTL that describes a pattern
> one must avoid to get context restoration right; unfortunately, the code
> generated by `sage.rings.polynomial.polynomial_zz_pex.pyx` (via
> `polynomial_template.pxi`) exactly conforms to this anti-pattern.

New description:

 I just ran into the following nasty bug:

 {{{
 sage: polygen(GF(49, 'a')) ; polygen(GF(9, 'a'))
 x
 x
 sage: x = polygen(GF(49, 'a'))
 sage: -x
 2*x
 sage: x + 0
 x
 sage: -x
 6*x
 }}}

 This is still present in sage-4.5.

 We have to ensure two things before playing with NTL finite field
 elements:
 * restore the ZZ_p context (characteristic);
 * restore the ZZ_pE context (defining polynomial).
 Restoring the latter does not automatically restore the former.

--

Comment (by jpflori):

 The problem is actually different from what was stated in the original
 description.

 In fact, calling PY_NEw or whatever before restoring context was not the
 (only) rpoblem.
 The main problem is that restoring the ZZ_pE context does not restore the
 "current" prime from the ZZ_p context.

--
Ticket URL: <http://trac.sagemath.org/ticket/9524#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to