title: How to do complete lu factorization in matlab
body: <p>I am not able to do complete pivoting in matlab.  Say I have some matrix that is not sparse:</p>
  
  <pre><code>A = [0,1,1,1;0,1,0,0;1,1,1,1;0,0,0,-1]
  </code></pre>
  
  <p>When I try to use the <code>lu</code> command in matlab it does not like it because it is not sparse:</p>
  
  <pre><code>&gt;&gt; [L,U,P,Q] = lu(A) 
  Error using lu
  Too many output arguments.
  </code></pre>
  
  <p>Even the docs say that it must be sparse:  </p>
  
  <blockquote>
    <p>[L,U,P,Q] = lu(A) for sparse nonempty A, returns a unit lower
    triangular matrix L, an upper triangular matrix U, a row permutation
    matrix P, and a column reordering matrix Q, so that P<em>A</em>Q = L*U. If A
    is empty or not sparse, lu displays an error message. The statement
    lu(A,'matrix') returns identical output values.</p>
  </blockquote>
  
  <p>I have two questions about this:</p>
  
  <p>1)  Why must it be sparse?  In theory LU decomposition works for non-sparse matrices and so does complete pivoting.</p>
  
  <p>2)  What is the appropriate MATLAB method to call to do complete pivoting for non-sparse matrices?</p>