Routine Name: inversePowerIteration
Author: David Merkley
Language: Python
Description/Purpose: performs inverse power iteration
Input: a matrix and starting point
Output: the operation
Implementation/Code:
def inversePowerIteration(A, x0, tol=1e-7, maxiter=1e3):
l0 = float('inf')
x = x0
y = x
Aiv = x
for i in range(int(maxiter)):
y = JacobiIteration(A, x, y, tol/100, maxiter)
v = vectorScalarMultiply(y, 1/l2(y))
Aiv = JacobiIteration(A, v, Aiv, tol/100, maxiter)
l1 = vectorDotProduct(v, Aiv)
error = abs(l1 - l0)
if error < tol:
print(i, "iterations")
return 1/l1, v
else:
l0 = l1
x = v
print("Max Iter")