matlabmathmatrixqr-decomposition

Computing the Hessenberg matrix using Givens-rotations


I am making an implementation in matlab to compute the Hessenberg matrix of a given matrix A. I understand the math and i calculated it manualy but i keep comming to the same solution.

Matrix A =

-149.0000  -42.2037 -156.3165
 537.6783  152.5511  554.9272
        0   -0.0728    2.4489

My result =

-149.0000  -42.2037 -156.3165
 537.6783  152.5511  554.9272
        0   -0.0728    2.4489

Result of hess in matlab =

-149.0000   42.2037 -156.3165
-537.6783  152.5511 -554.9272
        0    0.0728    2.4489

The result i obtained is from using only one Given rotation

G{1}(3,4)

1.0000         0         0
     0    0.9987    0.0502
     0   -0.0502    0.9987

G{1}(3,4).transpose * A * G{1}(3,4) should get met the right solution.

As you can see the result i obtain has some minus signs where they don't belong. Is my implementation wrong or is the hess implementation wrong or are they both valid?

Many thanks in advance!


Solution

  • Both are valid. Note that:

    I would hazard a guess that Matlab uses Householder transformations rather than Givens rotations to reduce matrices to upper Hessenberg form. Householder transformations are reflections and thus have negative determinant. This can flip some off-diagonal signs.