-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
Original ticket http://projects.scipy.org/scipy/ticket/427 on 2007-05-29 by @hazelnusse, assigned to unknown.
For the scipy.linalg.lu() function, the permutation matrix being returned is the transpose of the correct matrix.
Additionally, the code on the NumPy for Matlab users page has incorrect usage of the lu factorization. This is what is on the website [http://www.scipy.org/NumPy_for_Matlab_Users] :
Matlab Usage:
[L,U,P]=lu(a)
numpy.array usage:
(L,U)=Sci.linalg.lu(a) or
(LU,P)=Sci.linalg.lu_factor(a)
numpy.matrix usage:
mat(...)
If you use Sci.linalg.lu without the 'permute_l' argument, it defaults to permute_l=0, and thus returns three objects, and will give an ValueError if you try to use the code on the above mentioned website. Instead it should read:
(P,L,U)=Sci.linalg.lu(A)
Attached is a script that will illustrate and reproduce this error, and demonstrate that what fixes the problem (namely transposing the returned permutation matrix before matrix multiplying with l and u).