I am working on an implementation of power method to calculate the dominant eigen vector and eigen value of a given matrix. I have not posted the complete code, I rather have a specific question that I cannot understand.
In the following loop, I am updating x0 by assigning the calculated x of each step to it. This works fine, however, I need to calculate the difference between x and x0 in each step and save them in a variable called epsilon.
As the x0 assignment comes in the line after epsilon calculation, I expected this to work, but what I get as epsilon after the first round of loop is 0 and the reason is that x0 and x are identical in each step.
I have been thinking about this but I would appreciate some hint on what I am doing wrong.
for k in range(10):
y = matprod.matvec(m, x0)
normy = normvec.normvec(y)
for i in range(len(y)):
x[i] = y[i] / normy
epsilon[i] = x[i] - x0[i]
x0 = x
print k, x, x0, normy, epsilon