import scipy.linalg as scilin
import scipy.sparse.linalg.eigen.arpack as scispr
# Benchmark the dense routine
start = time.perf_counter()
evals_large, evecs_large = scilin.eigh(X, eigvals=(N - k, N - 1))
elapsed = (time.perf_counter() - start)
print(evals_large)
print("eigh elapsed time: ", elapsed)
# Benchmark the sparse routine
start = time.perf_counter()
evals_large_sparse, evecs_large_sparse = scispr.eigsh(X, k, which='LM')
elapsed = (time.perf_counter() - start)
print(evals_large_sparse)
print("eigsh elapsed time: ", elapsed)
转载自 https://blog.csdn.net/itnerd/article/details/109774318?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160673712519195271656300%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=160673712519195271656300&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduend~default-4-109774318.first_rank_v2_pc_rank_v29&utm_term=python%E6%B1%82%E7%9F%A9%E9%98%B5%E6%9C%80%E5%A4%A7%E7%89%B9%E5%BE%81%E5%80%BC&spm=1018.2118.3001.4449
比用numpy.linalg.eig(N)求解特征值特征向量再Max取值快很多