The power method finds the dominant eigenpair of a symmetric matrix using only matrix-vector products, and deflation removes a found eigenpair so the next run finds the following one. Implement three functions.
power_iteration(A, v0, n_iter) for a real symmetric A of shape (n, n):
n_iter times: .(lam, u) where u is the final and lam is the Rayleigh quotient as a Python float.u if needed so that its entry with the largest absolute value is positive (on ties, the first such index).deflate(A, lam, u): return for a unit vector u.
top_k_eigs(A, k, n_iter, v0): run power_iteration on A from v0, deflate with the result, and repeat on the deflated matrix (always starting from the same v0) until k eigenpairs are found. Return (vals, vecs): vals a 1-D array of length k in the order found, vecs an (n, k) array whose columns are the returned unit vectors.
The eigenvalues are assumed to be distinct in absolute value, so each run converges to the eigenvector whose eigenvalue has the largest in the current matrix (which may be negative). Do not call np.linalg.eig/eigh.