<br><br><div class="gmail_quote">On Mon, Nov 19, 2012 at 4:17 PM, Virgil Stokes <span dir="ltr"><<a href="mailto:vs@it.uu.se" target="_blank">vs@it.uu.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am using the latest versions of numpy (from<br>
numpy-1.7.0b2-win32-superpack-python2.7.exe) and scipy (from<br>
scipy-0.11.0-win32-superpack-python2.7.exe ) on a windows 7 (32-bit)<br>
platform.<br>
<br>
I have used<br>
<br>
import numpy as np<br>
q,r = np.linalg.qr(A)<br>
<br>
and compared the results obtained  from MATLAB (R2010B)<br>
<br>
[q,r] = qr(A)<br>
<br>
The q,r returned from numpy are both the negative of theq,r returned<br>
from MATLAB for the same matrix A. I believe that the q,r returned from<br>
MATLAB are correct. Why am I getting their negative from numpy?<br>
<br>
Note, I have tried this on several different matrices ---  numpy always<br>
gives the negative of MATLAB's q,r values.<br>
[I mistakenly have already sent a similar email to the scipy list ---<br>
please excuse this mistake.]<br></blockquote><div><br>They are both correct, the decomposition isn't unique. In particular, if both algorithms use Housholder reflections there are two possible reflection planes at each step, one of which is more numerically stable than the other, and the two choices lead to different signs at each step. That said, MATLAB may be normalizing the result in some way or using some other algorithm.<br>
<br>Chuck<br></div><br></div>