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.

Two arrays:<br />

double * val size P ,<br />

unsigned int * dptr size n<br />

P := n +<br />

n∑<br />

m i (A) .<br />

i=1<br />

(2.6.6)<br />

⎛<br />

⎞<br />

∗ 0 ∗ 0 0 ∗ 0 ∗ 0<br />

A = ⎜ ∗ ∗ 0 0 ⎝<br />

0 0 ∗<br />

⎟<br />

⎠<br />

∗ ∗ 0 0 ∗ ∗ 0<br />

0 0 ∗ ∗ 0 0 ∗<br />

Indexing rule:<br />

dptr[j] = k<br />

⇕<br />

val[k] = a jj<br />

Another example:Reflection at cross diagonal ➤ reduction of # env(A)<br />

⎛<br />

⎞<br />

⎛<br />

⎞<br />

∗ 0 ∗ ∗ ∗<br />

∗ 0 ⎜ 0 ∗ 0 0 0<br />

⎟<br />

⎝<br />

⎠ −→ ⎜ ∗ ∗ ∗ 0 ∗<br />

⎟<br />

⎝<br />

∗ 0 ⎠<br />

0 0 0 ∗ 0<br />

∗ 0 0 ∗ ∗ ∗<br />

∗ ∗ ∗ 0 0 ∗<br />

i ← N + 1 − i<br />

# env(A) = 30 # env(A) = 22<br />

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17<br />

val a 11 a 22 a 31 a 32 a 33 a 44 a 52 a 53 a 54 a 55 a 65 a 66 a 73 a 74 a 75 a 76 a 77<br />

dptr 0 1 2 5 6 10 12 17<br />

✸<br />

Example 2.6.30 (Reducing fill-in by reordering).<br />

✸<br />

Minimizing bandwidth:<br />

Goal: Minimize m i (A),A = (a ij ) ∈ R N,N , by permuting rows/columns of A<br />

Example 2.6.29 (Reducing bandwidth by row/column permutations).<br />

Ôº½¿ ¾º<br />

Ôº½ ¾º<br />

Recall: cyclic permutation of rows/columns of arrow matrix → Ex. 2.6.14<br />

envelope arrow matrix<br />

envelope arrow matrix<br />

0<br />

0<br />

2<br />

2<br />

4<br />

4<br />

M: 114×114 symmetric matrix (from computational<br />

PDEs)<br />

Code 2.6.31: preordering in MATLAB<br />

1 spy (M) ;<br />

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

3 r = symrcm(M) ;<br />

4 [ L ,U] = lu (M( r , r ) ) ; spy (U) ;<br />

5 m = symamd(M) ;<br />

6 [ L ,U] = lu (M(m,m) ) ; spy (U) ;<br />

0<br />

20<br />

40<br />

60<br />

80<br />

6<br />

6<br />

Pattern of M<br />

➥<br />

100<br />

8<br />

8<br />

(Here: no row swaps from pivoting !) 0 20 40 60 80 100<br />

nz = 728<br />

10<br />

10<br />

Examine patterns of LU-factors (→ Sect. 2.2) after reordering:<br />

12<br />

0 2 4 6 8 10 12<br />

nz = 31<br />

12<br />

0 2 4 6 8 10 12<br />

nz = 31<br />

Ôº½ ¾º<br />

Ôº½ ¾º

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

Saved successfully!

Ooh no, something went wrong!