In Lapack (zhseqr) and matlab, the eigenvalues of a complex matrix are computed successfully. I notice that QR iteration or algorithm is involved with that process. QR iteration repeats to call QR decomposition of R*Q from the previous step.

Here is my question: QR decomposition in Lapack (zgeqrf) produces real diagonal entries. QR iteration should make the complex diagonal entries of the upper triangular matrix as a result. For example,

>> A = [0 2; 1 3*i];

This non-symmetric A is known to have eigenvalues of i and 2i. Since the magnitudes of eigenvalues are distinct, the QR iteration probably converges well without any special shift. So, we have the upper triangular matrix from schur decomposition or QR iteration in Lapack:

>> schur(A)
ans =
       0 +          1i          -3 + 0.00066061i
       0 +          0i  1.4366e-18 +          2i

Now I tried to implement QR iteration to see how the algorithm works:

num_iter = 200;
[Q,R] = qr (A);
for ii=1:num_iter,
    [Q,R] = qr (R*Q);

But the result R has

R =
      -2 +          0i  2.4535e-13 -          3i
       0 +          0i           1 +          0i

My code converged to absolute values of eigenvalues, not to complex eigenvalues.

What is wrong with my code?



Your QR iteration is correct, but your result is not: it's not R that converges to the Schur form of A, but R*Q. The usual formulation of the QR iteration reflects this:

for i=1:num_iter
    [Q,R] = qr(A);
    A = R*Q;

Then you get the desired result:

>> A

A =

   0.0000 + 2.0000i  -3.0000 - 0.0000i
  -0.0000 + 0.0000i  -0.0000 + 1.0000i
| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.