On Mar 21, 5:34 pm, Alec Mihailovs <alec.mihail...@gmail.com> wrote:
> So both of them should be corrected by dealing with 0 separately and
> converting python int to Sage integers in int4.

Here are the corrected versions of int4 and poly_repr,

sage: def int4(z):
....:     C=reversed(map(int,z.polynomial().coeffs()))
....:     fc=parent(z).characteristic()
....:     return reduce(lambda x,y:fc*x+y,C,0)

def poly_repr(n,f):
    C=reversed(n.digits(f.characteristic()))
    return reduce(lambda x,y:f.gen()*x+y,C,f.zero())

sage: type(int4(F.one()))

        <type 'sage.rings.integer.Integer'>

sage: poly_repr(0,F)

0

sage: type(_)

<class
'sage.rings.finite_field_element.FiniteField_ext_pariElement'>

sage: int4(F.zero())

0

sage: type(_)

        <type 'sage.rings.integer.Integer'>

Alec Mihailovs






-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-devel+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to