[SciPy-User] qr decompostion gives negative q, r ?

Daπid davidmenhur@gmail....
Wed Nov 21 04:31:17 CST 2012


On Wed, Nov 21, 2012 at 9:34 AM, Virgil Stokes <vs@it.uu.se> wrote:

> When I perform step 5. with MATLAB, I *always* get a [image: $T_{22}$]that has diagonal elements > 0 for my application (which is satisfying).
> When I perform step 5. with numpy, for the same matrix on the RHS of (27) I
> *do not always* get diagonal elements > 0  for [image: $T_{22}$] ---
> herein lies the problem that I have been trying to explain.
>

http://www.mathworks.es/es/help/matlab/ref/qr.html

There is no reference to the positiveness of r, nor it is required by the
definition of QR decomposition, therefore it is wrong to assume it is true.
It may be in your current examples, but you don't have guaranteed that you
will find another A matrix where this will not be true. Also, the
portability of your code is tricky, as another person, with a different
version of MATLAB could have different results, even if it is not
documented (because the change would not affect the API).

The same holds true for Mathematica.

http://reference.wolfram.com/mathematica/ref/QRDecomposition.html

And even, in one of the examples, the matrix r is negative.

If you want to make sure, just use a qr function that checks for the sign
and reverts it, if necesary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20121121/21ef6063/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 721 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20121121/21ef6063/attachment.png 


More information about the SciPy-User mailing list