Open in the MATLAB editor: f08qx_example
function f08qx_example fprintf('f08qx example results\n\n'); n = int64(4); a = [ 1.50 - 2.75i, 0 + 0i, 0 + 0i, 0 + 0i; -8.06 - 1.24i, -2.50 - 0.50i, 0 + 0i, -0.75 + 0.50i; -2.09 + 7.56i, 1.39 + 3.97i, -1.25 + 0.75i, -4.82 - 5.67i; 6.18 + 9.79i, -0.92 - 0.62i, 0 + 0i, -2.50 - 0.50i]; % Balance a [a, ilo, ihi, scale, info] = f08nv( ... 'Both', a); % Reduce a to upper Hessenberg form [H, tau, info] = f08ns( ... ilo, ihi, a); % Form Q explicitly, storing result in vr [Q, info] = f08nt( ... ilo, ihi, H, tau); % Calculate the eigenvalues and Schur factorisation of A [S, w, VR, info] = f08ps( ... 'Schur Form', 'Vectors', ilo, ihi, H, Q); disp('Eigenvalues of A:'); disp(w); % Calculate the eigenvectors of A select = [false]; vl = [complex(0)]; [T, ~, Z, m, info] = ... f08qx( ... 'Right', 'Backtransform', select, H, vl, VR, n); % Scale [V, info] = f08nw( ... 'Both', 'Right', ilo, ihi, scale, Z); % Normalize eigenvectors: largest element is real for i = 1:m [~,k] = max(abs(real(V(:,i)))+abs(imag(V(:,i)))); V(:,i) = V(:,i)*conj(V(k,i))/abs(V(k,i)); end disp('Right eigenvectors of A:'); disp(V);
f08qx example results Eigenvalues of A: -1.2500 + 0.7500i -1.5000 - 0.4975i -3.5000 - 0.5025i 1.5000 - 2.7500i Right eigenvectors of A: 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1778 - 0.0372i 0.0000 + 0.0000i 0.1902 - 0.0910i 0.1898 - 0.0908i 0.4382 - 0.1021i 1.0000 + 0.0000i 0.7492 + 0.0000i 0.7479 + 0.0000i 0.8449 + 0.0000i 0.0000 + 0.0000i -0.2314 - 0.0337i -0.2310 - 0.0336i 0.1950 - 0.3509i