Skip to content

linalg.lu returns a transposed permutation matrix (Trac #427) #954

@scipy-gitbot

Description

@scipy-gitbot

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Migrated from TracdefectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.linalg

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions