Limits on Complex Sparse Linear Algebra in Python
<p>I am prototyping numerical algorithms for linear programming and matrix manipulation with very large (100,000 x 100,000) very sparse (0.01% fill) complex (a+b*i) matrices with symmetric structure and asymmetric values. I have been happily using MATLAB for seven years, but have been receiving suggestions to switch to Python since it is open source.</p>

<p>I understand that there are many different Python numeric packages available, but does Python have any limits for handling these types of matrices and solving linear optimization problems in real time at high speed? Does Python have a sparse complex matrix solver comparable in speed to MATLAB's backslash A\b operator? (I have written Gaussian and LU codes, but A\B is always at least 5 times faster than anything else that I have tried and scales linearly with matrix size.)</p>

<p>Probably your sparse solvers were slower than <code>A\b</code> at least in part due to the interpreter overhead of MATLAB scripts. Internally MATLAB uses UMFPACK's multifrontal solver for <code>LU()</code> function and <code>A\b</code> operator (see <a href="http://faculty.cse.tamu.edu/davis/suitesparse.html" rel="nofollow">UMFPACK manual</a>).</p>

<p>You should try <a href="http://docs.scipy.org/doc/scipy/reference/sparse.html" rel="nofollow"><code>scipy.sparse</code></a> package with <a href="http://docs.scipy.org/doc/scipy/reference/sparse.linalg.html" rel="nofollow"><code>scipy.sparse.linalg</code></a> for the assortment of solvers available. In particular, <code>spsolve()</code> function has an option to call UMFPACK routine instead of the builtin SuperLU solver.</p>

<blockquote>
  <p>... solving linear optimization problems in real time at high speed?</p>
</blockquote>

<p>Since you have time constraints you might want to consider iterative solvers instead of direct ones.</p>

<p>You can get an idea of the performance of SuperLU implementation in spsolve and iterative solvers available in SciPy from <a href="http://stackoverflow.com/a/18258362/1328439">another post</a> on this site.</p>

python matlab matrix linear-programming