[Numpy-discussion] performance solving system of equations in numpy and MATLAB

Edward Richards edwardlrichards at gmail.com
Wed Dec 16 12:34:03 EST 2015


I recently did a conceptual experiment to estimate the computational 
time required to solve an exact expression in contrast to an approximate 
solution (Helmholtz vs. Helmholtz-Kirchhoff integrals). The exact 
solution requires a matrix inversion, and in my case the matrix would 
contain ~15000 rows.


On my machine MATLAB seems to perform this matrix inversion with random 
matrices about 9x faster (20 sec vs 3 mins). I thought the performance 
would be roughly the same because I presume both rely on the same LAPACK 
solvers.


I will not actually need to solve this problem (even at 20 sec it is 
prohibitive for broadband simulation), but if I needed to I would 
reluctantly choose MATLAB . I am simply wondering why there is this 
performance gap, and if there is a better way to solve this problem in 
numpy?


Thank you,

Ned


#Python version

import numpy as np

testA = np.random.randn(15000, 15000)

testb = np.random.randn(15000)

%time testx = np.linalg.solve(testA, testb)


%MATLAB version

testA = randn(15000);

testb = randn(15000, 1);

tic(); testx = testA \ testb; toc();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20151216/303285ec/attachment.html>


More information about the NumPy-Discussion mailing list