# bug #55885: Wrong sparse LU permutation matrix with vector option

 Submitted by: CH Submitted on: Mon 11 Mar 2019 02:07:00 PM UTC Category: Octave Function Severity: 3 - Normal Priority: 5 - Normal Item Group: Incorrect Result Status: Works For Me Assigned to: None Originator Name: Open/Closed: Closed Release: 5.1.0 Operating System: Any

You are not logged in

## Discussion

Mon 11 Mar 2019 11:10:10 PM UTC, comment #3:

That's fine.  IF you can locate an example that does produce different results we can investigate further.

Rik <rik5>
Mon 11 Mar 2019 09:39:36 PM UTC, comment #2:

I see. I posted this "bug", as I have a involved code that works with the matrix option and vector option in Matlab, and with the matrix option in Octave, but not with vector option. I thought this could be a minimal example. Sorry, I will look into that more deeply.

CH <atcl>
Mon 11 Mar 2019 09:09:23 PM UTC, comment #1:

According to the documentation, when called with 4-outputs

[L, U, P, Q] = lu (S)

the resulting decomposition is

P*S*Q = L*U

When called with the "vector" argument, the resulting decomposition is

S(P,Q) = L*U

So to test, I should have

S(P,Q) - L*U = 0

octave:25> S = sprand (5,5,0.3);
octave:26> [L,U,P,Q] = lu (S, 'vector');
octave:27> S(P,Q) - L*U
ans =

Compressed Column Sparse (rows = 5, cols = 5, nnz = 0 [0%])

So this looks correct to me.

For the second point, it makes no difference for indexing whether the vectors are row or column vectors.

Rik <rik5>
Mon 11 Mar 2019 02:07:00 PM UTC, original submission:

Using the LU decomposition with four output values and the vector option seems to lead to incorrect results for the P (row permutation) matrix:

A = sprand(5,5,0.3);

[L,U,P,Q] = lu(A);

(mod(find(P),size(P,2)))' % zeros are 5s
(mod(find(Q),size(Q,1)))' % zeros are 5s

[l,u,p,q] = lu(A,'vector');

p'
q'

gives with Octave 5.1

ans =

1   4   2   3   0

ans =

0   1   4   3   2

ans =

1   3   4   2   5

ans =

5   1   4   3   2

It seems that the vector is created from P' (transposed) instead of P since

(mod(find(P'),size(P,2)))' % zeros are 5s

gives

ans =

1   3   4   2   0

I hope I did not misinterpret anything. Thank you for your help.

BTW: Matlab (2018a) returns row vectors for P and Q while Octave (5.1) returns column vectors.

CH <atcl>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by rik5 (Posted a comment)
• -email is unavailable- added by atcl (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.

## History

Date Changed by Updated Field Previous Value => Replaced by
2019-03-11 rik5 Open/ClosedOpen Closed
2019-03-11 rik5 StatusNone Works For Me