small fixes to the code and the tex

This commit is contained in:
Luca Lombardo
2022-12-07 18:13:40 +01:00
parent d91c796b57
commit 2df71072a6
5 changed files with 83 additions and 25 deletions
+3 -2
View File
@@ -145,6 +145,8 @@
"\n",
" # reshape y to be a column vector\n",
" y = y.reshape(y.shape[0],1)\n",
"\n",
" # update x \n",
" x += V[:,0:y.shape[0]] @ y\n",
"\n",
" # compute the residual vector\n",
@@ -160,7 +162,7 @@
" A_tmp = sp.sparse.hstack([H, z]) # stack H and z, as in the paper, to solve the linear system (?)\n",
" A_tmp = A_tmp.tocsc() # Convert A to CSC format for sparse solver\n",
"\n",
" # What should I put here? What does it mean in the paper the 14 of the pseudocode?\n",
" # What should I put here? What does it mean in the paper the line 14 of the pseudocode?\n",
" result = sp.sparse.linalg.spsolve(A_tmp, np.zeros(A_tmp.shape[0])) # if I solve this, I get a vector of zeros.\n",
" print(result)\n",
" \n",
@@ -189,7 +191,6 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"n = 100\n",
"m = 110\n",
"maxit = 100\n",
+14
View File
@@ -233,6 +233,20 @@ class Algorithms:
# TO DO
pass
class runners:
def ShiftedPowerMethod(tau):
dataset = Utilities.load_data()
max_mv = 100
G, n = Utilities.create_graph(dataset)
P = Utilities.create_matrix(G)
d = Utilities.dangling_nodes(P,n)
v = Utilities.probability_vector(n)
Pt = Utilities.transition_matrix(P, v, d)
a = Utilities.alpha()
mv, x, r, total_time = Algorithms.algo1(Pt, v, tau, max_mv, a)
print("total time = ", total_time)