Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-272

Lanczos Tridiagonal Step

Problem

Perform one Lanczos iteration step for symmetric A and unit vector v.

Compute alpha = v^T * A * v, the residual w = A*v - alpha*v, and beta = ||w||_2. Return [alpha, beta].

Hint

The alpha and beta values form the diagonal and off-diagonal of the tridiagonal Lanczos matrix.

Test cases

case 1
in: [[[2,0],[0,3]],[1,0]]
expected: [2,0]
case 2
in: [[[2,0],[0,3]],[0.7071067811865475,0.7071067811865475]]
expected: [2.5,0.5]
case 3
in: [[[2,1],[1,2]],[1,0]]
expected: [2,1]
case 4
in: [[[1,0,0],[0,2,0],[0,0,3]],[0.5773502691896258,0.5773502691896258,0.5773502691896258]]
expected: [2,0.816496580927726]
Starter codePython
def lanczos_step(A, v):
    # Your code here
    pass

4 test cases · run your code against them in the editor