Open in the MATLAB editor: f08px_example
function f08px_example fprintf('f08px example results\n\n'); % Complex matrix A a = [ -3.97 - 5.04i, -4.11 + 3.70i, -0.34 + 1.01i, 1.29 - 0.86i; 0.34 - 1.50i, 1.52 - 0.43i, 1.88 - 5.38i, 3.36 + 0.65i; 3.31 - 3.85i, 2.50 + 3.45i, 0.88 - 1.08i, 0.64 - 1.48i; -1.10 + 0.82i, 1.81 - 1.59i, 3.25 + 1.33i, 1.57 - 3.44i]; % Reduce (all of) A to upper Hessenberg Form n = int64(4); ilo = int64(1); ihi = n; [H, tau, info] = f08ns(ilo, ihi, a); % Form Q [Q, info] = f08nt(ilo, ihi, H, tau); % Schur factorize H = Y*T*Y^H job = 'Schur form'; compz = 'Vectors'; [~, w, ~, info] = f08ps( ... job, compz, ilo, ihi, H, Q); disp('Eigenvalues of A'); disp(w); % Calculate eigenvectors of H for negative real part eigenvalues select = (real(w) < 0); job = 'Right'; eigsrc = 'QR'; initv = 'No initial vectors'; vl = []; vr = complex(zeros(n,n)); [~, ~, VR, m, ifaill, ifailr, info] = ... f08px( ... job, eigsrc, initv, select, H, w, vl, vr, n); % Eigenvectors of A = Q*VR side = 'Left'; trans = 'No transpose'; [z, info] = f08nu( ... side, trans, ilo, ihi, H, tau, VR); % Normalize eigenvectors: largest elements are real for i = 1:m [~,k] = max(abs(real(z(:,i)))+abs(imag(z(:,i)))); z(:,i) = z(:,i)*conj(z(k,i))/abs(z(k,i)); end disp('Eigenvectors corresponding to eigenvalues with negative real part'); % Normalize eigenvectors before printing disp(z/diag(z(1,:)));
f08px example results Eigenvalues of A -6.0004 - 6.9998i -5.0000 + 2.0060i 7.9982 - 0.9964i 3.0023 - 3.9998i Eigenvectors corresponding to eigenvalues with negative real part 1.0000 + 0.0000i 1.0000 + 0.0000i -0.0210 + 0.3590i 1.1997 - 0.6339i 0.1035 + 0.3683i -1.3192 - 0.5912i -0.0664 - 0.3436i -0.1319 + 0.7904i