from petsc4py import PETSc import numerical_algebra.linear_solvers as nals import scipy.sparse as sps import scipy.sparse.linalg as spslin import numpy as np import time n = 4000 print("") print(" First step: matrix creation") matrix = sps.random(n, n, format='csr') + 10 * sps.eye(n) + \ 0.1j * sps.random(n, n, format='csr') exact_solution = 0.2 * np.arange(n) + 0.01j * np.arange(n) print(" Done...") rhs = matrix * exact_solution print(" Second step: solving the system of linear equations") t0 = time.time() x_sol = spslin.spsolve(matrix, rhs) print(" DONE for", time.time()-t0)