import numpy as np
import scipy
import time
import scipy.sparse as sparse

t = [1]+[0]*4999
a = scipy.matrix(np.array(t*5000, dtype=float).reshape(5000, 5000))
start = time.time()
b = np.dot(a, a)
print(time.time() - start)

start = time.time()
aa = sparse.coo_matrix(a)
b = np.dot(aa, aa).todense()
print(time.time() - start)

Python稀疏矩阵运算

 

 

参考:

[1] https://zhuanlan.zhihu.com/p/52497385

相关文章:

  • 2022-12-23
  • 2021-06-11
  • 2022-01-14
猜你喜欢
  • 2022-01-03
  • 2022-01-03
  • 2022-12-23
  • 2022-01-12
  • 2021-08-11
相关资源
相似解决方案