Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-133

LU Partial Pivot Step

Problem

Perform one step of LU decomposition with partial pivoting on matrix A.

Find the entry of largest magnitude in the first column, swap that row to the top, then store the multipliers that eliminate the first column below the pivot in column 0. Return the updated matrix, or None if the first column is entirely zero (within 1e-12).

Hint

After swapping, the multipliers replace column 0 below the pivot.

Test cases

case 1
in: [[[2,1],[1,3]]]
expected: [[2,1],[0.5,2.5]]
case 2
in: [[[1,3],[2,1]]]
expected: [[2,1],[0.5,2.5]]
case 3
in: [[[4,3],[2,1]]]
expected: [[4,3],[0.5,-0.5]]
case 4
in: [[[0,1],[0,2]]]
expected: null
Starter codePython
def lu_pivot_step(A):
    # Your code here
    pass

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