2

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?

Oren Milman
  • 454
  • 4
  • 17

1 Answers1

2

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())
Nik
  • 315
  • 4
  • 9