The power method is one of the simplest methods to find the maximum eigenpair of an operator. We simply compute \(x_{k+1}=\frac{Ax_k}{\left\lVert Ax_k \right\rVert}\) until the corresponding Rayleigh quotient \(\frac{x^TAx}{x^Tx}\) stops changing.
This simple algorithm requires only the action of the operator. We start at iteration \(k=0\) using a random initial vector \(x_0\). Then, until some maximum number of iteration steps, we compute \(Ax\) and the current Rayleigh quotient. We then normalize \(x\). If the change from the previous Rayleigh quotient is sufficiently small, we break out of the loop. At the end of the iterations, our vector \(x\) should contain the maximum eigenvector. We return the corresponding maximum eigenvalue.
Implementation
Using linalgcpp, we implement the above steps.
Distributed Environment
A very similar function will work for distributed operators. The vector dot products should be replaced with parallel versions.