![]() ![]() In ubuntu, this has to first be installed as sudo apt-get install libsuitesparse-dev.įurthermore, the aforementioned python solvers are tested in: This solver is apparently available (only?) under Linux, since it make use of the libsuitesparse. Scipy (Python), UMFPACK solver: spsolve(A, b) using from scikits.umfpack import spsolve. Scipy (Python), pcg solver: sp.linalg.cg(A, b, x0=None, tol=1e-05) Scipy (Python), direct solver: linalg.spsolve(A, b) where A is previously formatted in csr_matrix format. Matlab and Octave, pcg solver: The preconditioned conjugated gradient, pcg solver pcg(A,b,1e-5,size(b,1)) (not preconditioner is used). Matlab and Octave, direct solver: The canonical x=A\b. Still, the banded structure is preserved after a "spy" matrix command in both Matlab and Python.įor comparison, I have used the following solvers: Observe that there are some values in V, which are nearly zero, are left on purpose. the first two columns are the indices for the rows and columns, respectively, and the third column are the values corresponding to such indices. The matrices are stored in triplets I,J,V, i.e. If one is interested in replicating my results, I have uploaded the matrices A and the vectors b in the following link (it will expire en 30 days) Get systems used here. ![]() This results in dimensions of a matrix A=N^2xN^2 and a vector b=N^2x1, i.e., the largest NxN is a million. To generate a proper sparse matrix, with a banded structure, a Poisson's problem is solved using finite elements with squared grids of N=250, N=500 and N=1000. I have chosen both direct and iterative approaches, I will explain this more in detail below. I have been trying different sparse solvers available in Python 3 and comparing the performance between them and also against Octave and Matlab. ![]()
0 Comments
Leave a Reply. |