#11685: Pari finite field extension: element created by list not recognised as 
zero
----------------------------------------+-----------------------------------
   Reporter:  johanbosman               |          Owner:  AlexGhitza           
       
       Type:  defect                    |         Status:  needs_work           
       
   Priority:  major                     |      Milestone:  sage-4.7.2           
       
  Component:  algebra                   |       Keywords:  finite fields, pari  
       
Work_issues:                            |       Upstream:  N/A                  
       
   Reviewer:  Simon King, Johan Bosman  |         Author:  Johan Bosman, Jeroen 
Demeyer
     Merged:                            |   Dependencies:                       
       
----------------------------------------+-----------------------------------

Comment(by SimonKing):

 Replying to [comment:22 jdemeyer]:
 > I think that the fact that your example works for the first patch is an
 unintentional side-effect and not really an intended feature.

 Intended or not doesn't matter. It is a feature, I think.

 > I believe that I am fixing much more than what the ticket requires, ...

 Indeed it does, namely:
 {{{
 sage: k.<x> = GF(3^11)
 sage: k([ k(0),k(1) ])
 x
 sage: k([0,1/2])
 2
 sage: R.<y> = PolynomialRing(k)
 sage: k([ R(0),R(1) ])
 x
 }}}

 It a strength of your patch that the examples above work (they wouldn't,
 with the other patch).

 Do you see a way to make ''both'' work?

 I wouldn't say that your patch is simpler, because you first convert into
 a list of prime field elements and then convert into pari; a double
 conversion, so it seems to me, tends to be fragile.

 I mean, the only problem with
 `k([k([0])._FiniteField_ext_pariElement__value])` in your patch is the
 fact that the pari value (which, after all, is zero) can not be converted
 into the zero of a finite field. There could be a work around, such as
 {{{
 value = [GFp(c) for c in value if c else GFp.zero_element()]
 }}}

 Concerning speed, one should test whether `k([])` is the only case in
 which your patch is slower. Since you have a special case for `k([])`
 anyway, it would be perfectly fine to have a short-cut, such as
 {{{
 if not value:  # or value==[], if that's faster
     self.__value = (pari(0) *
 parent._pari_one()).Mod(parent._pari_modulus())
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11685#comment:23>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to