Files
unisa_analisi_numerica_2014…/functions/power_method.m

25 lines
230 B
Matlab

function [v,a] = power_method (U,toll)
[x,~] = size(U);
for i=1:x
v(i)=1;
end
v=v';
err = inf;
while err > toll
v1=U*v;
v1=v1./norm(v1,inf);
err = norm(v1-v,inf);
a = v1./v;
v=v1;
end
end