I am trying to solve a large linear system of equations in Python, Ax=b type problem. A is square, not symmetric, 250.000x250.000, with 2e7 nonzero elements.
I solved it first in Matlab 2022a, with A\b or mldivide function. It takes approx 25 secs in my laptop. I then try to solve the same system of equations in python, with spsolve(K,f), and it takes 110 secs on the same laptop. K and f are csc matrices from scipy, as imported from matlab.
from scipy.io import loadmat
from scipy.io import loadmat
from scipy.io import loadmat
from scipy.sparse.linalg import spsolve
import time
data = loadmat('solverData.mat')
K=data['K']
f=data['f']
t = time.time()
x = spsolve(K, f)
t1=time.time()-t
Could you help me get similar performance to Matlab (or better :-) ) within pyhton?
Thanks!