21.06.2014 Views

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

0 20 40 60 80 100 120 140 160 180 200<br />

0<br />

Sparse matrix<br />

0<br />

Sparse matrix: L factor<br />

0<br />

Sparse matrix: U factor<br />

0<br />

Pattern of A<br />

0<br />

0<br />

Pattern of L<br />

0<br />

Pattern of U<br />

20<br />

20<br />

20<br />

2<br />

2<br />

2<br />

2<br />

40<br />

40<br />

40<br />

4<br />

4<br />

4<br />

4<br />

60<br />

60<br />

60<br />

80<br />

80<br />

80<br />

6<br />

6<br />

6<br />

6<br />

100<br />

100<br />

100<br />

8<br />

8<br />

8<br />

8<br />

120<br />

120<br />

120<br />

10<br />

10<br />

10<br />

10<br />

140<br />

160<br />

140<br />

160<br />

140<br />

160<br />

12<br />

12<br />

0 2 4 6 8 10 12 0 2 4 6 8 10 12<br />

nz = 31<br />

nz = 121<br />

Pattern of A −1 0 2 4 6 8 10 12<br />

12<br />

nz = 21<br />

12<br />

0 2 4 6 8 10 12<br />

nz = 21<br />

180<br />

180<br />

180<br />

200<br />

200<br />

0 20 40 60 80 100 120 140 160 180 200<br />

nz = 796<br />

nz = 10299<br />

200<br />

0 20 40 60 80 100 120 140 160 180 200<br />

nz = 10299<br />

✸<br />

!<br />

L, U sparse ≠⇒ A −1 sparse !<br />

A sparse ⇏ LU-factors sparse<br />

Besides stability issues, see Ex. 2.5.3, this is another reason why using x = inv(A)*y instead of<br />

y = A\b is usually a major blunder.<br />

Definition 2.6.3 (Fill-in).<br />

Let A = LU be an LU-factorization (→ Sect. 2.2) of A ∈ K n,n . If l ij ≠ 0 or u ij ≠ 0 though<br />

a ij = 0, then we encounter fill-in at position (i,j).<br />

Ôº½¿ ¾º<br />

✸<br />

Ôº½ ¾º<br />

Example 2.6.13 (Sparse LU-factors).<br />

Ex. 2.6.11 ➣ massive fill-in can occur for sparse matrices<br />

This example demonstrates that fill-in can be largely avoided, if the matrix has favorable structure. In<br />

this case a LSE with this particular system matrix A can be solved efficiently, that is, with a computational<br />

effort O(nnz(A)) by Gaussian elimination.<br />

Example 2.6.14 (“arrow matrix”).<br />

⎛<br />

α b T ⎞<br />

A =<br />

c D<br />

⎜<br />

⎟<br />

⎝<br />

⎠<br />

,<br />

α ∈ R ,<br />

b,c ∈ R n−1 ,<br />

D ∈ R n−1,n−1 regular diagonal matrix, → Def. 2.2.1<br />

A = [diag(1:10),ones(10,1);ones(1,10),2];<br />

[L,U] = lu(A); spy(A); spy(L); spy(U); spy(inv(A));<br />

A is called an “arrow matrix”, see the pattern of non-zero entries below.<br />

Recalling Rem. 2.2.7 it is easy to see that the LU-factors of A will be sparse and that their sparsity<br />

patterns will be as depicted below.<br />

Run algorithm 2.3.5 (Gaussian elimination<br />

without pivoting):<br />

factor matrices with O(n 2 ) non-zero<br />

entries.<br />

computational costs: O(n 3 )<br />

(2.6.1)<br />

Code 2.6.15: LU-factorization of arrow matrix<br />

1 n = 10; A = [ n+1 , ( n: −1:1) ;<br />

ones ( n , 1 ) , eye ( n , n ) ] ;<br />

2 [ L ,U,P] = lu (A) ; spy ( L ) ; spy (U) ;<br />

Ôº½ ¾º<br />

Ôº½ ¾º

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!