Skip to content

Instantly share code, notes, and snippets.

@jskDr
Created October 18, 2015 22:52
Show Gist options
  • Save jskDr/505de18bb5896524529e to your computer and use it in GitHub Desktop.
Save jskDr/505de18bb5896524529e to your computer and use it in GitHub Desktop.
Powermethod in Julia
tolerence = 1e-10
M = rand(2, 2)
#w0 = [1., 1]
#w = copy( w0)
w_org = [1, 1] / norm( [1, 1])
w_full = rand(2, 1)
w = w_full / norm( w_full)
ii = 0
while norm(w_org - w) > tolerence
w_org = w
w_new = M*w
w = w_new / norm( w)
println( "$(ii): $(w') --> $(norm(w_org - w))")
ii += 1
if ii > 100
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment