On Mar 20, 10:11 pm, Minh Nguyen <[email protected]> wrote:
> On Sun, Mar 21, 2010 at 10:19 AM, Alasdair McAndrew <[email protected]> wrote:

> > def intr(z):
> >     C=z.polynomial().coeffs()
> >     fc=parent(z).characteristic()
> >     tmp=0
> >     for i in range(len(C),0,-1):
> >         tmp=fc*tmp+int(C[i-1])
> >     return tmp

That can be also written short, but working slightly slower as

sage: def intr1(z):
....:     return
ZZ(z.polynomial().coeffs(),parent(z).characteristic())

And using functional programming, which works slightly faster than
intr, as

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

Alec Mihailovs



-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
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