Scipy sparse memory explosion with simple matrix multiplication
问题 I noted that Scipy must be storing some intermediate arrays when doing matrix multiplication. I assume this can be helpful in some cases, but it is a pain sometimes. Consider the following example: from scipy.sparse import coo_matrix n = 100000000000 row = np.array([0, 0]) col = np.array([0, n-1]) data = np.array([1, 1]) A = coo_matrix((data, (row, col)), shape=(2, n)) Yes, this is a very large matrix. However it has only two nonzero values. The result of B = A.dot(A.T) can be evaluated by