24.03.2013 Views

Chapter 3 Solution of Linear Systems - Math/CS

Chapter 3 Solution of Linear Systems - Math/CS

Chapter 3 Solution of Linear Systems - Math/CS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

58 CHAPTER 3. SOLUTION OF LINEAR SYSTEMS<br />

! Gaussian elimination – row oriented<br />

for k = 1 to n − 1<br />

!. . . Exchange step<br />

!. . . Find p such that |ap,k| is the first <strong>of</strong> the<br />

!. . . largest values among {|aq,k|} n q=k<br />

p := k<br />

for i = k + 1 to n<br />

if |ai,k| > |ap,k| then p := i<br />

next i<br />

! exchange equations p and k if necessary<br />

if p > k then<br />

for j = k to n<br />

temp := ak,j; ak,j := ap,j; ap,j := temp<br />

next j<br />

temp := bk; bk := bp; bp := temp<br />

endif<br />

if ak,k == 0 then return (linear system is singular)<br />

!. . . elimination step - row oriented<br />

for i = k + 1 to n<br />

mi,k := ai,k/ak,k !. . . compute multiplier<br />

ai,k := 0 !. . . start <strong>of</strong> elimination<br />

for j = k + 1 to n<br />

ai,j := ai,j − mi,k ∗ ak,j<br />

next j<br />

bi := bi − mi,k ∗ bk<br />

next i<br />

next k<br />

if an,n == 0 then return (linear system is singular)<br />

! Backward substitution – row oriented<br />

for i = n downto 1 do<br />

for j = i + 1 to n<br />

bi := bi − ai,j ∗ xj<br />

next j<br />

xi := bi/ai,i<br />

next i<br />

Figure 3.9: Pseudocode row oriented GE and Backward Substitution

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

Saved successfully!

Ooh no, something went wrong!