Open in the MATLAB editor: f08nw_example
function f08nw_example fprintf('f08nw example results\n\n'); n = int64(4); a = [ 1.50 - 2.75i, 0.00 + 0.00i, 0.00 + 0.00i, 0.00 + 0.00i; -8.06 - 1.24i, -2.50 - 0.50i, 0.00 + 0.00i, -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.00 + 0.00i, -2.50 - 0.50i]; % Balance A job = 'Both'; [a, ilo, ihi, scale, info] = f08nv(job, a); % Reduce a to upper Hessenberg form [H, tau, info] = f08ns(ilo, ihi, a); % Form Q [Q, info] = f08nt(ilo, ihi, H, tau); % Calculate the eigenvalues and Schur factorisation of A [H, w, Z, info] = f08ps( ... 'Schur Form', 'Vectors', ilo, ihi, H, Q); disp('Eigenvalues:'); disp(w); % Calculate the eigenvectors of A [select, ~, VR, m, info] = ... f08qx( ... 'Right', 'Backtransform', false, H, complex(zeros(1)), Z, n); % Rescale [VR, info] = f08nw( ... 'Both', 'Right', ilo, ihi, scale, VR); % Normalize: largest elements are real for i = 1:n [~,k] = max(abs(real(VR(:,i)))+abs(imag(VR(:,i)))); VR(:,i) = VR(:,i)*conj(VR(k,i))/abs(VR(k,i))/norm(VR(:,i)); end disp('Eigenvectors:'); disp(VR);
f08nw example results Eigenvalues: -1.2500 + 0.7500i -1.5000 - 0.4975i -3.5000 - 0.5025i 1.5000 - 2.7500i Eigenvectors: 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1418 - 0.0407i 0.0000 + 0.0000i -0.1015 + 0.0009i 0.1756 - 0.4131i -0.2711 - 0.1812i 1.0000 + 0.0000i 0.9884 + 0.0000i 0.7420 + 0.0000i 0.8213 + 0.0000i 0.0000 + 0.0000i 0.0941 + 0.0619i 0.4170 - 0.2722i 0.1110 + 0.4303i