mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 21:23:13 +02:00
18 lines
402 B
Mathematica
18 lines
402 B
Mathematica
|
|
function [eigenvalues,iteration,Afinal] = eigenvalueQRnoshift(A)
|
||
|
|
%EIGENVALUEQRNOSHIFT calculates eigenvalues using the QR method with no
|
||
|
|
%shifts
|
||
|
|
% returns eigenvalues, the number of iterations and the transformed
|
||
|
|
% matrix A
|
||
|
|
iteration = 1;
|
||
|
|
while max(max(A-diag(diag(A)))) > 10^-6
|
||
|
|
[Q, R] = QRfactorize(A);
|
||
|
|
A = R * Q;
|
||
|
|
iteration = iteration+1;
|
||
|
|
end
|
||
|
|
|
||
|
|
eigenvalues = diag(A);
|
||
|
|
Afinal = A;
|
||
|
|
|
||
|
|
end
|
||
|
|
|