Open in the MATLAB editor: f08uf_example
function f08uf_example fprintf('f08uf example results\n\n'); % Sove Az = lambda Bz % A and B are the symmetric banded positive definite matrices: n = 4; % A has 2 off-diagionals ka = int64(2); a = [ 0.24, 0.39, 0.42, 0.00; 0.39, -0.11, 0.79, 0.63; 0.42, 0.79, -0.25, 0.48; 0.00, 0.63, 0.48, -0.03]; % B has 1 off-diagonal kb = int64(1); b = [ 2.07 0.95 0.00 0.00; 0.95 1.69 -0.29 0.00; 0.00 -0.29 0.65 -0.33; 0.00 0.00 -0.33 1.17]; % Convert to general banded format ... [~, ab, ifail] = f01zc( ... 'P', ka, ka, a, zeros(ka+ka+1,n)); [~, bb, ifail] = f01zc( ... 'P', kb, kb, b, zeros(kb+kb+1,n)); % ... and chop to give 'Upper' symmetric banded format ab = ab(1:ka+1,1:n); bb = bb(1:kb+1,1:n); % Factorize B uplo = 'Upper'; [ub, info] = f08uf( ... uplo, kb, bb); % Reduce problem to standard form Cy = lambda*y vect = 'N'; [cb, x, info] = f08ue( ... vect, uplo, ka, kb, ab, ub); % Find eigenvalues lambda jobz = 'No Vectors'; [~, w, ~, info] = f08ha( ... jobz, uplo, ka, cb); disp('Eigenvalues:'); disp(w');
f08uf example results Eigenvalues: -0.8305 -0.6401 0.0992 1.8525