All problems
Incomplete LU Step
Problem
Compute the diagonal of U in the ILU(0) factorization of a tridiagonal matrix A.
Set u[0] = A[0][0], then for each i > 0 use multiplier l = A[i][i-1] / u[i-1] and u[i] = A[i][i] - l * A[i-1][i]. Return the list of u values.
Hint
ILU(0) keeps the sparsity pattern of A while producing approximate factors.
Test cases
case 1
in: [[[4,1,0],[1,4,1],[0,1,4]]]
expected: [4,3.75,3.7333333333333334]
case 2
in: [[[2,0],[0,2]]]
expected: [2,2]
case 3
in: [[[1,1],[1,2]]]
expected: [1,1]
case 4
in: [[[4,2],[2,5]]]
expected: [4,4]
Starter codePython
def ilu0_tridiagonal(A):
# Your code here
pass4 test cases · run your code against them in the editor