scipy.sparse.linalg.
factorized#
- scipy.sparse.linalg.factorized(A)[source]#
返回一個函數,用於求解稀疏線性系統,其中 A 已預先分解。
- 參數:
- A(N, N) array_like
輸入。 CSC 格式的 A 最有效率。 CSR 格式的矩陣在因式分解前會被轉換為 CSC。
- 返回:
- solvecallable
為了求解在 A 中給出的線性方程組,solve callable 應傳遞形狀為 (N,) 的 ndarray。
範例
>>> import numpy as np >>> from scipy.sparse.linalg import factorized >>> from scipy.sparse import csc_array >>> A = np.array([[ 3. , 2. , -1. ], ... [ 2. , -2. , 4. ], ... [-1. , 0.5, -1. ]]) >>> solve = factorized(csc_array(A)) # Makes LU decomposition. >>> rhs1 = np.array([1, -2, 0]) >>> solve(rhs1) # Uses the LU factors. array([ 1., -2., -2.])