Open in the MATLAB editor: f08nj_example
function f08nj_example fprintf('f08nj example results\n\n'); n = int64(4); a = [ 5.14, 0.91, 0.00, -32.80; 0.91, 0.20, 0.00, 34.50; 1.90, 0.80, -0.40, -3.00; -0.33, 0.35, 0.00, 0.66]; % Balance a [a, ilo, ihi, scale, info] = f08nh( ... 'Both', a); % Reduce a to upper Hessenberg form [H, tau, info] = f08ne( ... ilo, ihi, a); % Form Q [Q, info] = f08nf( ... ilo, ihi, H, tau); % Calculate the eigenvalues and Schur factorisation of A [H, wr, wi, Z, info] = f08pe( ... 'Schur Form', 'Vectors', ilo, ihi, H, Q); w = wr + i*wi; disp('Eigenvalues:'); disp(w); % Calculate the eigenvectors of A [select, ~, VR, m, info] = ... f08qk( ... 'Right', 'Backtransform', false, H, zeros(1), Z, n); % Back scale to get eigenvectors of A [VR, info] = f08nj( ... 'Both', 'Right', ilo, ihi, scale, VR); % Normalize eigenvectors: largest element positive for j = 1:n [~,k] = max(abs(VR(:,j))); VR(:,j) =VR(:,j)/norm(VR(:,j)); if VR(k,j) < 0; VR(:,j) = -VR(:,j); end end disp('Eigenvectors:'); disp(VR);
f08nj example results Eigenvalues: -0.4000 -4.0208 3.0136 7.0072 Eigenvectors: 0 -0.4381 0.4654 0.9513 0 0.8923 0.7888 -0.1714 1.0000 -0.0481 0.3981 0.2494 0 -0.0976 0.0521 -0.0589