Octave's default LU factorization function error

New to this forum.

I'm trying to run octave's LU decomposition function with complete pivoting as such:

[L, U, p, q] = lu(A)

for a matrix A I have and I keep getting this error:

"element number 4 undefined in return list"

Element 4 is the matrix of column permutations Q. What's going on? Why doesn't it show? Thanks in advance

1 answer

  • answered 2020-01-14 02:31 TroyHaskin

    If the matrix A is full, the lu function does not perform column exchanges in Octave (emphasis mine):

    When called with two or three output arguments and a spare[sic] input matrix, lu does not attempt to perform sparsity preserving column permutations. Called with a fourth output argument, the sparsity preserving column transformation Q is returned, such that P * A * Q = L * U.

    So full pivoting is only performed for sparse matrices to maximize sparsity if the fourth output argument is provided for a sparse matrix. The quote above uses "A", but per the function signature provided at the top of the linked Octave documentation section, I believe they meant to write "S": "[L, U, P, Q] = lu (S)".

    There does not appear to be a full pivoting option for full matrices by-default.

    I'll note that MATLAB has the same behavior for the fourth output of its lu:

    Column permutation ... . Use this output to reduce the fill-in (number of nonzeros) in the factors of a sparse matrix.