#11628: GF() arithmetic slower than IntegerModRing()
--------------------------------+-------------------------------------------
   Reporter:  zimmerma          |          Owner:  AlexGhitza
       Type:  defect            |         Status:  new       
   Priority:  major             |      Milestone:  sage-4.7.2
  Component:  basic arithmetic  |       Keywords:            
Work_issues:                    |       Upstream:  N/A       
   Reviewer:                    |         Author:            
     Merged:                    |   Dependencies:            
--------------------------------+-------------------------------------------
 Consider the following code:
 {{{
 # tries to find x^2+(y/2^delta)^2 + small = (2z+1)^2
 # (2^delta*x)^2 + y^2 + err = (2^delta*(2z+1))^2
 def table1_mod2(p,delta,err):
    l = [[0,0]]
    P = 1 # values in l are mod P
    q = 1
    twop = 2^p
    twodelta = 2^delta
    while P<twop:
       q = next_prime(q)
       R = IntegerModRing(P*q)
       newl = []
       for t in l:
          for hx in range(q):
             x = t[0]+hx*P
             if x>=twop:
                break
             u = R((twodelta*x)^2+err)
             for hz in range(q):
                z = t[1]+hz*P
                if z>=twop:
                   break
                y2 = R((twodelta*(2*z+1))^2)-u
                if y2.is_square():
                   newl.append([x,z])
       l = newl
       P = P * q
    return l, P
 }}}
 With Sage 4.7 I get:
 {{{
 sage: time l=table1_mod2(10,0,1)
 Time: CPU 2.61 s, Wall: 2.63 s
 sage: len(l[0])
 76940
 }}}
 If I change {{{R = IntegerModRing(P*q)}}} by {{{R=GF(q)}}}, which
 does not change the algorithm (we are lifting modulo 2*3*5*...),
 then strangely the program is slower:
 {{{
 sage: time l=table1_mod2(10,0,1)
 Time: CPU 19.28 s, Wall: 19.33 s
 sage: len(l[0])
 76940
 }}}
 Is that normal?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11628>
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