use_solver#
- scipy.sparse.linalg.use_solver(**kwargs)[source]#
選擇要使用的預設稀疏直接求解器。
- 參數:
說明
當 UMFPACK 可用時(已安裝
scikits.umfpack
),預設的稀疏求解器為 UMFPACK。 可以透過傳遞 useUmfpack = False 來更改此設定,這會導致始終存在的基於 SuperLU 的求解器被使用。UMFPACK 要求 CSR/CSC 矩陣具有排序後的欄/列索引。 如果確定矩陣滿足此條件,請傳遞
assumeSortedIndices=True
以獲得一些速度提升。參考文獻
[1]T. A. Davis, Algorithm 832: UMFPACK - an unsymmetric-pattern multifrontal method with a column pre-ordering strategy, ACM Trans. on Mathematical Software, 30(2), 2004, pp. 196–199. https://dl.acm.org/doi/abs/10.1145/992200.992206
[2]T. A. Davis, A column pre-ordering strategy for the unsymmetric-pattern multifrontal method, ACM Trans. on Mathematical Software, 30(2), 2004, pp. 165–195. https://dl.acm.org/doi/abs/10.1145/992200.992205
[3]T. A. Davis and I. S. Duff, A combined unifrontal/multifrontal method for unsymmetric sparse matrices, ACM Trans. on Mathematical Software, 25(1), 1999, pp. 1–19. https://doi.org/10.1145/305658.287640
[4]T. A. Davis and I. S. Duff, An unsymmetric-pattern multifrontal method for sparse LU factorization, SIAM J. Matrix Analysis and Computations, 18(1), 1997, pp. 140–158. https://doi.org/10.1137/S0895479894246905T.
範例
>>> import numpy as np >>> from scipy.sparse.linalg import use_solver, spsolve >>> from scipy.sparse import csc_array >>> R = np.random.randn(5, 5) >>> A = csc_array(R) >>> b = np.random.randn(5) >>> use_solver(useUmfpack=False) # enforce superLU over UMFPACK >>> x = spsolve(A, b) >>> np.allclose(A.dot(x), b) True >>> use_solver(useUmfpack=True) # reset umfPack usage to default