Last night I installed Python, PyDev, and NumPy. Numpy is a math library for Python. Revisited the timings I saw in R and Python was faster (no surprise). I got to thinking, what it you built Numpy against a BLAS/LAPACK library like MKL or ACML (AMD's version)? Quick searching found Mr. Gohlke's site, from which I re-installed Numpy and grabbed a few others.
Tonight I reran the tests.
import numpyHere is the output:
import time
def flops(ops, sec):
Gflops = op/sec/1000000000
outStr = "{0:6.2f} GFlops on {1:13.0f} operations in {2:3.2f} seconds.".format(Gflops, ops, sec)
print outStr
n = 4000
a = numpy.eye(n)
a = numpy.matrix(a)
time.clock()
s = time.clock()
b = a*a
e = time.clock()
op = (2*n**3 - n**2)
s = e-s
flops(op,s)
a = numpy.ones((n,n))*.9 + a*.1
s = time.clock()
b = numpy.linalg.cholesky(a)
e = time.clock()
flops((n**3)/3,(e-s))
print b[0:3,0:3]
17.09 GFlops on 127984000000 operations in 7.49 seconds.Beer Snorted.
67.83 GFlops on 21333333333 operations in 1.89 seconds.
[[ 1. 0. 0. ]
[ 0.9 0.43588989 0. ]
[ 0.9 0.20647416 0.38388595]]
No comments:
Post a Comment