CS3220 Gaussian Elimination and LU Steve Marschner Spring 2010
one step of the elimination phase for k = 1 to n–1 k j for i = k+1 to n r = a ik /a kk for j = k+1 to n a ij += –r a kj b i = b i – r b k b k k a kk a kj a ik = 0 b i for k = n to 1 a ij i a ik s = b k for j = (k+1) to n s += –a kj x j A b x x k = s / a kk
one step of the solution phase for k = 1 to n–1 k j for i = k+1 to n r = a ik /a kk for j = k+1 to n a ij += –r a kj b i = b i – r b k k b k a kk a kj x k a ik = 0 for k = n to 1 s = b k x j for j = (k+1) to n s += –a kj x j A b x x k = s / a kk
one step of the elimination phase: vector k j for k = 1 to n–1 for i = k+1 to n r = a ik /a kk a i,k+1:n += –r a k,k+1:n b k k a kk b i = b i – r b k a ik = 0 i a ik for k = n to 1 s = b k – a k,k+1:n • x k+1:n x k = s / a kk A b x
one step of the solution phase: vector k j for k = 1 to n–1 for i = k+1 to n r = a ik /a kk a i,k+1:n += –r a k,k+1:n k b k a kk x k b i = b i – r b k a ik = 0 b i for k = n to 1 s = b k – a k,k+1:n • x k+1:n x k = s / a kk A b x
one step of the elimination phase: matrix k j for k = 1 to n–1 B = a k+1:n,k • a k,k+1:n a k+1:n,k+1:n –= B / a kk b k+1:n += –a k+1:n,k / a kk b k k a kk a k+1:n,k = 0 for k = n to 1 i s = b k – a k,k+1:n • x k+1:n x k = s / a kk A b x
elimination step as matrix multiplication k k k k M k M k − 1 · · · M 1 A M k · · · M 1 A
inverting elimination matrices k k k i − m ik m ik M − 1 I M k k
multiplying the multipliers k k k M − 1 M − 1 k − 1 k
matrix full of multipliers 1 1 ... | | L = 1 m 1 m 2 | | | 1 1 m n − 2 m n − 1
pivoting multipliers will be 10, 100, 1000, 10000—not good! k b k k .01 .1 1 10 100 M k − 1 · · · M 1 A M k − 1 · · · M 1 b x
pivoting multipliers will be 10, 100, 1000, 10000—not good! k b k k .01 .1 solution: 1 swap these rows 10 100 M k − 1 · · · M 1 A M k − 1 · · · M 1 b x
pivot vector don’t actually swap rows—just renumber them. k p = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8] p = [1 , 2 , 3 , 8 , 5 , 6 , 7 , 4] b k k .01 p = [1 , 2 , 3 , 8 , 7 , 4 , 5 , 6] .1 1 10 100 M k − 1 · · · M 1 A M k − 1 · · · M 1 b x
pivot vector don’t actually swap rows—just renumber them. k p = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8] p = [1 , 2 , 3 , 8 , 5 , 6 , 7 , 4] b k k p = [1 , 2 , 3 , 8 , 7 , 4 , 5 , 6] 100 M k − 1 · · · M 1 A M k − 1 · · · M 1 b x
pivot vector don’t actually swap rows—just renumber them. k p = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8] p = [1 , 2 , 3 , 8 , 5 , 6 , 7 , 4] b k k p = [1 , 2 , 3 , 8 , 7 , 4 , 5 , 6] M k − 1 · · · M 1 A M k − 1 · · · M 1 b x
Recommend
More recommend