On Wed, Jul 15, 2009 at 11:23 AM, Martin Albrecht<m...@informatik.uni-bremen.de> wrote: > >> That's not surprising given what power_mod does. Do power_mod?? to >> see. It's generic code that does the arithmetic in the parent ring, >> then calls mod after each multiply. so in the above first example, >> zmod_poly is never used. > > This reminds me: Why do we have power_mod() when pow() does the same thing > when given three arguments? Maybe this was discussed before and I just can't > recall it.
Hmm. Pow's third argument is often ignored: sage: K.<x> = ZZ["x"] sage: f = 2*x^2 + 3*x + 1 sage: timeit('power_mod(f,10,24)') 625 loops, best of 3: 162 µs per loop sage: timeit('pow(f,10,24)') 625 loops, best of 3: 11.9 µs per loop That seems fast, but : sage: pow(f,10,24) 1024*x^20 + 15360*x^19 + 108800*x^18 + 483840*x^17 + 1514880*x^16 + 3549312*x^15 + 6456480*x^14 + 9336960*x^13 + 10901460*x^12 + 10377180*x^11 + 8097453*x^10 + 5188590*x^9 + 2725365*x^8 + 1167120*x^7 + 403530*x^6 + 110916*x^5 + 23670*x^4 + 3780*x^3 + 425*x^2 + 30*x + 1 sage: power_mod(f,10,24) 16*x^20 + 8*x^18 + 12*x^12 + 12*x^11 + 21*x^10 + 6*x^9 + 21*x^8 + 18*x^6 + 12*x^5 + 6*x^4 + 12*x^3 + 17*x^2 + 6*x + 1 So, ouch. sage: P.<x> = PolynomialRing(Zmod(24)) sage: f = 2*x^2 + 3*x + 1 sage: timeit('f^10') 625 loops, best of 3: 27.6 µs per loop -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---