All problems
Power Iteration Deflation Step
Problem
Deflate the known eigenpair (lam, v) from matrix A, where v is a unit eigenvector:
A' = A - lam * v*v^T
The largest eigenvalue of A' is then the second eigenvalue of A. Return the deflated matrix.
Hint
Subtract the rank-1 spectral component lam*v*v^T.
Test cases
case 1
in: [[[2,0],[0,3]],2,[1,0]]
expected: [[0,0],[0,3]]
case 2
in: [[[2,1],[1,2]],3,[0.7071067811865475,0.7071067811865475]]
expected: [[0.5,-0.5],[-0.5,0.5]]
case 3
in: [[[4,1],[2,3]],5,[0.7071067811865475,0.7071067811865475]]
expected: [[1.5,-1.5],[-0.5,0.5]]
case 4
in: [[[1,0],[0,1]],1,[1,0]]
expected: [[0,0],[0,1]]
Starter codePython
def deflation_step(A, lam, v):
# Your code here
pass4 test cases · run your code against them in the editor