> ABC@home is a project to find abc-triples: positive integers a,b,c
> such that a+b=c, a < b < c, a,b,c have no common divisors and c >
> rad(abc), the so-called radical of abc. See http://abcathome.com/ for
> further details.
>
> Now the project has found around 6 million abc-triples.
Cool.
> The
> abc_triples.bin file contains all triples found by the abc project so
> far in binary form in the following format: c_1b_1c_2b_2c_3b_3 .. such
> that each c_i b_i form an abc triple: (c_i-b_i,b_i,c_i). The sequence
> is ordered in such a way that the c_i form an increasing sequence and
> for equal c_i the b_i form an increasing sequence. The size of each
> c_i and b_i is a 64bit unsigned integer.
>
> The database can be found on http://www.abcathome.com/stuff/. Each day
> new abc-triples are added. The size of the file is around 60Mb.
>
> Question: How can I acces this file in SAGE? (I'm not familiar with
> reading 64bit unsigned integers, so please some lines of code please)
> Tnx in advance!
Numpy makes things really easy here:
sage: import numpy
sage: data = numpy.memmap("/path/to/abc_triples.bin", dtype=[('a',
'uint64'), ('b', 'uint64'), ('c', 'uint64')])
sage: data[0]
(2L, 6L, 8L)
> Suggestion: The ABC conjecture says that there are only finitely many
> a,b,c such that log(c)/log(rad(abc)) > h for any real h > 1. The ABC
> conjecture is currently one of the greatest open problems in
> mathematics. Therefor an idea to have the abc-triples permanently
> available in SAGE?
One would probably want to put them in a database as an spkg, or
write an interface to grab them of the web.
- Robert
Hi,
I've cc'd Hendrik Lenstra (who was my Ph.D. adviser) and Bart de Smit,
since they
are very invovled in abcathome. Regarding your request, I wrote a
small program
in the Sage notebook that uses Cython, and which parses the complete 57MB
binary ABC triples file in 1 second. It's given below. I also saved the
result to a compressed sobj:
http://sage.math.washington.edu/home/was/tmp/abc_triples.sobj
You can do
v = load('http://sage.math.washington.edu/home/was/tmp/abc_triples.sobj')
and Sage will download and load the file, giving the list of c1,b1,c2,b2, etc.
Untitled
system:sage
Click edit and paste this into a sage notebook. Assumes you're
on a 64-bit computer. Be sure to edit the open command to open
your decompressed copy of the abc data file.
{{{id=0|
r = open('/home/was/tmp/abc_triples.bin','rb').read()
///
}}}
{{{id=1|
%cython
def to_ints(r):
# This *assumes* a 64-bit Linux OS...
v = []
cdef char* c = r
cdef long* w = <long*> c
cdef Py_ssize_t i
assert sizeof(long) == 8
return [w[i] for i in range(len(r)//8)]
///
}}}
{{{id=2|
time v = to_ints(r)
///
CPU time: 1.63 s, Wall time: 1.63 s
}}}
{{{id=16|
c1,b1=v[-2],v[-1]
///
}}}
{{{id=3|
(c1 - b1, b1, c1)
///
(1, 999999999999999999, 1000000000000000000)
}}}
{{{id=5|
abc = (c1-b1)*b1*c1
///
}}}
{{{id=6|
prod(prime_divisors(abc))
///
370370370370370370
}}}
{{{id=7|
factor(abc)
///
2^18 * 3^4 * 5^18 * 7 * 11 * 13 * 19 * 37 * 52579 * 333667
}}}
{{{id=12|
time save(v,'/home/was/tmp/abc_triples.sobj')
///
}}}
{{{id=17|
///
}}}
sage: f=open('abc_triples.bin','rb')
opens the file for reading in binary format. But I don't know how to
parse the strange results of f.readline(). Someone else might be
able to help.
John
2008/8/7 Rolandb <rol...@planet.nl>:
Do what Robert Bradshaw suggested you do in this same thread.
His solution is better.
William
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
>
> Dear William,
>
> Sorry to bother you again, but also Robert's suggestion doesn't work
> either (at my computer):
>
> import numpy
> data = numpy.memmap("http://sage.math.washington.edu/home/was/tmp/
> abc_triples.bin", dtype=[('a','uint64'), ('b', 'uint64'), ('c',
> 'uint64')])
You have to download the file locally to use memmap.