Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force python to perform an LU decomposition without a permutation

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?

like image 907
Oren Milman Avatar asked Oct 15 '25 04:10

Oren Milman


1 Answers

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())
like image 147
Nik Avatar answered Oct 17 '25 17:10

Nik