#427: linalg.lu returns a transposed permutation matrix
--------------------------+-------------------------------------------------
Reporter: hazelnusse | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone:
Component: scipy.linalg | Version: 0.5.2
Severity: normal | Keywords: lu, linalg, scipy, factorization
--------------------------+-------------------------------------------------
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).
--
Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/427>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.