[Cado-nfs-discuss] calling CADO-NFS from Sage

paul zimmermann Paul.Zimmermann at inria.fr
Thu Jun 4 13:23:18 CEST 2015


       Hi,

the Sage code below might be useful to some of you. It enables to call
CADO-NFS from within Sage. I guess it is trivial to extend to DLP.
It was tested with CADO-NFS 1.1, 2.1.1 and the current git version.
 
Paul

PS: thanks to Jean-Luc Garambois

import subprocess, os
def my_exec_factor(nbr):
    cmd = ['/tmp/cado-nfs-1.1/factor.sh', str(nbr)]
    # cmd = ['/tmp/cado-nfs-2.1.1/factor.sh', str(nbr)]
    my_env = os.environ
    if my_env.has_key("PYTHONHOME"):
       my_env.pop("PYTHONHOME")
    if my_env.has_key("PYTHONPATH"):
       my_env.pop("PYTHONPATH")
    if my_env.has_key("PATH"):
       my_env.pop("PATH")
    if my_env.has_key("CADO_DEBUG"):
       my_env.pop("CADO_DEBUG")
    process = subprocess.Popen(cmd, stderr=subprocess.STDOUT, \
                                    stdout=subprocess.PIPE, env=my_env)
    output, unused_err = process.communicate()
    retcode = process.poll()
    if retcode:
        print "Output :"
        print output
        raise subprocess.CalledProcessError(retcode, cmd)
    return output

res=my_exec_factor(90377629292003121684002147101760858109247336549001090677693)

r=[]
# the factors are in line -6 for CADO-NFS 1.1, line -2 for 2.1.1
for i in res.splitlines()[-6].split(' ') + res.splitlines()[-2].split(' '):
    try:
       r.append(Integer(i))
    except TypeError:
       pass
print r


More information about the Cado-nfs-discuss mailing list