power method e pagerank come funzioni esterne

This commit is contained in:
2014-12-10 13:00:02 +01:00
parent 8968dbd158
commit 60e284f24e
5 changed files with 216 additions and 0 deletions

24
functions/power_method.m Normal file
View File

@@ -0,0 +1,24 @@
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