In MATLAB, it is possible to use a hack to force the builtin LU decomposition algorithm to not use a permutation matrix (i.e., force P=I
), as shown here.
Is there a similar hack in python?
Namely, is there any way to force scipy.linalg.lu
(or any other popular LU algorithm) to not use a permutation matrix?
They don't have such option for the numpy arrays, but you can achieve this by the following workaround:
from scipy.sparse.linalg import splu
A = np.array([-3,4,0,1,-3,2,-6,7,1]).reshape(3,3)
slu = splu(A, permc_spec = "NATURAL", diag_pivot_thresh=0, options={"SymmetricMode":True})
print(slu.L.toarray())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With