[Numpy-discussion] Confused with qr decomposition function

Virgil Stokes vs at it.uu.se
Tue Nov 20 13:03:17 EST 2012

On 2012-11-20 18:09, Pauli Virtanen wrote:
> 20.11.2012 15:24, Virgil Stokes kirjoitti:
> [clip]
>> I am aware that they are both correct; but, if you are doing covariance
>> QR decomposition then you almost surely are interested in the positive
>> results (which is the default for MATLAB and most papers/books on this
>> subject).
> I get exactly identical results from MATLAB (R2011b), Octave, Numpy, and
> Scipy. Can you give an example matrix which behaves differently?
> Note that Numpy and Scipy return exactly what LAPACK's *GEQRF routines
> give, and Octave seems also to do this.
Here are two that had opposite signs compared to MATLAB:

array([[  7.07106781e+02,  -2.32273270e+04,  -2.46173719e+04],
        [ -3.53553391e+01,  -2.31566171e+04,  -2.46173719e+04],
        [  2.32273276e+04,  -3.97555166e+00,  -1.39003725e+03],
        [  2.25202208e+04,  -6.48214647e-04,  -1.39004432e+03],
        [  2.46527272e+04,   1.31933390e+03,   1.66675481e-19],
        [  2.46173719e+04,   1.39401993e+03,  -7.07106781e-03],
        [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
        [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00],
        [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00]])

array([[  3.66711160e+04,   3.36224799e+04,   7.60569110e+02, 
        [  3.24652853e+03,   0.00000000e+00,  -2.32192233e+04, 
        [ -1.71055253e+04,   0.00000000e+00,   0.00000000e+00, 
        [  1.15905933e+04,  -3.36224799e+04,  -7.60569110e+02, 
        [ -1.72015604e+04,   0.00000000e+00,   2.32192233e+04, 
        [ -1.72015604e+04,   0.00000000e+00,   0.00000000e+00, 
        [  3.00000000e+01,   0.00000000e+00,   0.00000000e+00, 

More information about the NumPy-Discussion mailing list