[Numpy-discussion] NumPy EIG much slower than MATLAB EIG
Mon Apr 2 13:05:40 CDT 2012
On Mon, Apr 2, 2012 at 6:18 PM, Aronne Merrelli
> On Sun, Apr 1, 2012 at 8:28 AM, Kamesh Krishnamurthy <email@example.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:
> 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):
>>> tic; eig(r); toc
> Elapsed time is 10.594226 seconds.
>>> tic; [V,D] = eig(r); toc
> Elapsed time is 23.767467 seconds.
> In : t0=datetime.now(); numpy.linalg.eig(r); print datetime.now()-t0
> In : t0=datetime.now(); v,V = numpy.linalg.eig(r); print datetime.now()-t0
> If you change the MATLAB call, how does it compare?
Or you could alternatively change the numpy call to
np.linalg.eigvals(r), if you're only interested in the eigenvalues.
More information about the NumPy-Discussion