scipy slow sparse matrix solver
问题 I can't seem to get a benefit out of scipy's CG and sparse matrix algorithms. When I try to solve this banded matrix equation import time import scipy.sparse.linalg as ssla import scipy.sparse as ss import numpy as np size = 3000 x = np.ones(size) A = ss.diags([1, -2, 1], [-1, 0, 1], shape=[size, size]).toarray() print 'cond. nr.:{}'.format(np.linalg.cond(A)) b = np.dot(A, x) start_time = time.clock() sol = np.linalg.solve(A, b) elapsed_time = time.clock() - start_time error = np.sum(np.abs