[SciPy-User] qr decompostion gives negative q, r ?
Pauli Virtanen
pav@iki...
Thu Nov 22 07:51:11 CST 2012
Virgil Stokes <vs <at> it.uu.se> writes:
[clip]
> Now, if I use qr(A,0) in MATLAB:
>
> I get the following for R (3x3)
>
> 1001.24922, -4.99290, 0.00000
> 0.00000, 100.03307, -0.00056
> -0.00000, 0.00000, 0.00998
>
> This is obviously PD, as it should be, and gives the correct results.
> Note, it is the negative of the R obtained with numpy.
Case in point:
MATLAB R2011b, Linux x86_64
>> A=[707.106781, 0.000549702852, 1.66675481e-19;-35.3553391, 70.7104659,
1.66675481e-19;0.0, -3.97555166, 0.00707106781;-707.106781, -0.000648214647,
1.66675481e-19;35.3553391, -70.7104226, 1.66675481e-19;0.0, 3.97560687,
-0.00707106781;0.0, 0.0, 0.0;0.0, 0.0, 0.0;0.0, 0.0, 0.0]
>> [Q,R] = qr(A, 0);
>> R
R =
1.0e+03 *
-1.001249219464423 0.004992899186307 0.000000000000000
0 -0.100033070889029 0.000000562045938
0 0 -0.000009984192722
The statements
"MATLAB gives always positive definite R"
"MATLAB does post-processing in QR"
are both false. Indeed, any "normalization" of the result is
not mentioned in the documentation.
You simply cannot assume that the returned R is PD, because
what you actually get ultimately depends on the underlying
LAPACK library.
--
Pauli Virtanen
More information about the SciPy-User
mailing list