[Numpy-discussion] NumPy EIG much slower than MATLAB EIG

Aronne Merrelli aronne.merrelli@gmail....
Mon Apr 2 12:18:20 CDT 2012


On Sun, Apr 1, 2012 at 8:28 AM, Kamesh Krishnamurthy <kameshkk@gmail.com> wrote:
> Hello all,
>
> I profiled NumPy EIG and MATLAB EIG on the same Macbook pro, and both were
> linking to the Accelerate framework BLAS. NumPy turns out to be ~4x slower.
> I've posted details on Stackoverflow:
> http://stackoverflow.com/q/9955021/974568
>


If you just call eig() in MATLAB it only returns eigenvalues (not
vectors). I think there might be a "shortcut" algorithm if you only
want the eigenvalues - or maybe it is faster just due to the smaller
memory requirement. NumPy's eig always computes both. On my Mac OS X
machine I get this result, showing the two are basically equivalent
(this is EPD NumPy, so show_config() shows it is built on MKL):

MATLAB:
>> tic; eig(r); toc
Elapsed time is 10.594226 seconds.
>> tic; [V,D] = eig(r); toc
Elapsed time is 23.767467 seconds.

NumPy
In [4]: t0=datetime.now(); numpy.linalg.eig(r); print datetime.now()-t0
0:00:25.594435
In [6]: t0=datetime.now(); v,V = numpy.linalg.eig(r); print datetime.now()-t0
0:00:25.485411

If you change the MATLAB call, how does it compare?


More information about the NumPy-Discussion mailing list