Hi,

I wonder why this (simple) example is still slow?

%cython
from sage.all import QQ

def ctel2(int diep):
    R = QQ['A, B']
    (A, B) = R._first_ngens(2)
    cdef long tel=0
    cdef int i,k0,k1,k2,k3,k4,k5
    para=[1,A,B,A**2,A*B,B**2]
    ABC=A*B*(A+B)
    for k0 in xrange(-diep,diep+1):
        for k1 in xrange(-diep,diep+1):
            for k2 in xrange(-diep,diep+1):
                for k3 in xrange(-diep,diep+1):
                    for k4 in xrange(-diep,diep+1):
                        for k5 in xrange(-diep,diep+1):
                            k=[k0,k1,k2,k3,k4,k5]
                            if not all([k[i]<=0 for i in xrange(6)]):
                                pol=0
                                for i in xrange(6): pol+=k[i]*para[i]
                                if pol.gcd(ABC)==1: tel+=1
    return tel

time ctel2(2)
14629
Time: CPU 0.48 s, Wall: 1.51 s

The non-Cython version yields CPU time: 1.90 s,  Wall time: 1.96 s.

I tried to modify the last few lines of code, but that didn't help
much. It seems that
    R = QQ['A, B']
    (A, B) = R._first_ngens(2)
is the cause of the problem?

Any suggestions? Thanks in advance!

Roland

-- 
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-support
URL: http://www.sagemath.org

Reply via email to