<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/250632</link>
    <title>MATLAB Central Newsreader - in [Q, R, E] = qr(A), how E is determined ?</title>
    <description>Feed for thread: in [Q, R, E] = qr(A), how E is determined ?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 05 May 2009 17:51:10 -0400</pubDate>
      <title>in [Q, R, E] = qr(A), how E is determined ?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/250632#647563</link>
      <author>Marco Pappalepore</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;I'm trying to implement qr factorization, as it works in matlab, in another programming language. I've found an algorithm to do the qr factorization (but without ordering abs(diag(R)). That's the part I'm missing. On qr's help page, it is said:&lt;br&gt;
&lt;br&gt;
&quot;[Q,R,E] = qr(A) for full matrix A, produces a permutation matrix E, an upper triangular matrix R with decreasing diagonal elements, and a unitary matrix Q so that A*E = Q*R. The column permutation E is chosen so that abs(diag(R)) is decreasing.&quot;&lt;br&gt;
&lt;br&gt;
I've looked also at the fortran implementation of qr in netlib at this address :&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.netlib.org/lapack/double/dgeqp3.f&quot;&gt;http://www.netlib.org/lapack/double/dgeqp3.f&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
there I can get the permutation (=pivot) matrix is received as an input parameter:&lt;br&gt;
&lt;br&gt;
(...)&lt;br&gt;
*  JPVT    (input/output) INTEGER array, dimension (N)&lt;br&gt;
*          On entry, if JPVT(J).ne.0, the J-th column of A is permuted&lt;br&gt;
*          to the front of A*P (a leading column); if JPVT(J)=0,&lt;br&gt;
*          the J-th column of A is a free column.&lt;br&gt;
*          On exit, if JPVT(J)=K, then the J-th column of A*P was the&lt;br&gt;
*          the K-th column of A.&lt;br&gt;
(...)&lt;br&gt;
&lt;br&gt;
it seems that the pivot strategy is determined outside of the fortran routine, somewhere in matlab internals. Now I'm able to find the correct permutation matrix by searching it with a brute-force approach, i.e. simply exploring all the permutations until I find one good, that makes abs(diag(R)) decreasing; but that could bring the elaboration time to exponential or even factorial dimensions. I'm guessing if, given a not ordered Q-R factorization, is there some transformation or formula (like the gauss algorithm for finding linear independent columns) that &quot;understands&quot; rapidly how the permutation matrix E must be. So, how is E determined in the qr routine ?&lt;br&gt;
&lt;br&gt;
many thanks, Marco</description>
    </item>
    <item>
      <pubDate>Tue, 05 May 2009 18:12:01 -0400</pubDate>
      <title>Re: in [Q, R, E] = qr(A), how E is determined ?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/250632#647572</link>
      <author>Bruno Luong</author>
      <description>QR is essentially a Gram-Smidth orthogonalization procedure. During the iteration #k, it is easy to show that if we pick among the set of remaining vectors (i.e., not yet included in the span) the vector that has the *largest* orthogonal component to the current subspace (generated by k first vectors), then the diagonal of R must decrease. Essentially, this can be easily prove using triangular inequality (norm of the projection &amp;lt;= norm of the vector). This procedure provides a permutation E and warranty the expected property without any extra cost in QR decomposition (certainly not exponential or factorial complexity).&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
  </channel>
</rss>

