Segmentation fault

125 views
Skip to first unread message

Jan Medina

unread,
Apr 20, 2014, 11:36:24 PM4/20/14
to sage-s...@googlegroups.com
I have this error when i runnig this algorithm

def Trujillo_Gomez(p,h):
    if is_prime(p):
        F.<x>=GF(p^(h-1),name='x')
        g=random_primitive(p,h-1);
        s=p^(h-1)
        for i in range(p):
            a1=discrete_log(g+i,g)
            a2=a1-i
            a3=s*a1+i
            A2=A2+[ZZ(mod(a1,(p*(s-1))))]        
        aP=Permutations(A2).random_element()
        return aP
    else:
        print 'P debe ser primo'

for p=409 y h=17.

Is it a bug?

William Stein

unread,
Apr 20, 2014, 11:39:14 PM4/20/14
to sage-support
I get the error


NameError: global name 'random_primitive' is not defined

What is random_primitive? Is that defined elsewhere in your code? If
not, exactly what version of Sage are you using, and on exactly which
operating system, etc.? Did you install a binary (which, exactly?) or
build from source?

Thanks,

William


>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.



--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Jan Medina

unread,
Apr 20, 2014, 11:46:55 PM4/20/14
to sage-s...@googlegroups.com

Oh sorry, this is random_primitive
def random_primitive(p,h):
    F.<x>=GF(p^h)
    s=p^h-1
    r=F.random_element()
    j=0
    if r!=0:
        for t in prime_factors(s):
            if r^(s/t)==1:
                j=j+1
        if j==0:
            return r           
        else:
            return random_primitive(p,h)
    else:
        return random_primitive(p,h)

Im using SAGE 5.11 in VirtualBox, my SO is Windows 7.

William Stein

unread,
Apr 20, 2014, 11:47:35 PM4/20/14
to sage-support
I just realized this is from another thread. Anyway, I tried running
it, but killed it after it had used 22GB of RAM.

5848 8399046 39 19 21.6g 20g 208 R 100 52.4 1:42.91 python

So you're doing something that exhausts all your RAM, which can lead
to a segfault.

William

Jan Medina

unread,
Apr 20, 2014, 11:58:55 PM4/20/14
to sage-s...@googlegroups.com
well i use this algorithm Bose_Chowla with the same parameters, this algorithm used 2 hours and a half to find this set. So what is the problem whit the other algorithm?
def Bose_Chowla(p,h):
    if is_prime(p):
        F.<x>=GF(p^h,name='x')
        g=random_primitive(p,h);
        a=[discrete_log(g+i,g) for i in range(p)];
        aP=Permutations(a).random_element();

        return aP
    else:
        print 'P debe ser primo'

John Cremona

unread,
Apr 21, 2014, 5:11:55 AM4/21/14
to SAGE support
If I read your code correctly, when you have a primitive element g
then you call discrete_log p times on g+i for i mod p. Surely to
compute a complete table of discrete logs you should go the other way
and set the g^k 'th element of the array to k-g mod p (or something
like that)?

John

Jan Medina

unread,
Apr 21, 2014, 11:47:55 PM4/21/14
to sage-s...@googlegroups.com
If i use p=409 y h=18, the algorithm works. Why if i use h=17 i have this error?
Reply all
Reply to author
Forward
0 new messages