Graphics Programs Reference
In-Depth Information
The
relative size
of any element
A
i j
(i.e., relative to the largest element in the
i
th
row) is definedas the ratio
A
i j
s
i
r
i j
=
(2.32)
Suppose that the eliminationphase has reached the stage where the
k
th row has
become the pivot row. The augmented coefficient matrix atthis point is shown below.
⎡
⎣
⎤
⎦
A
11
A
12
A
13
A
14
···
A
1
n
b
1
0
A
22
A
23
A
24
···
A
2
n
b
2
00
A
33
A
34
···
A
3
n
b
3
.
.
.
.
.
.
···
←
0
···
0
A
kk
···
A
kn
b
k
.
.
.
.
.
···
···
0
···
0
A
nk
···
A
nn
b
n
We don't automaticallyaccept
A
kk
as the pivot element, but look in the
k
th column
below
A
kk
fora“better” pivot. The best choice is the element
A
pk
thathas the largest
relativesize; that is, we choose
p
such that
r
pk
=
max
j
r
jk
≥
k
If we find such an element, thenwe interchange the rows
k
and
p
, and proceedwith
the eliminationpass as usual. Note that the corresponding rowinterchange must also
becarried out in the scale factor array
s
. The algorithm that does all this is
fork=1:n-1
% Find element with largest relative size
% and the corresponding row number p
[Amax,p] = max(abs(A(k:n,k))./s(k:n));
p=p+k-1;
%Ifthiselementisverysmall,matrixissingular
if Amax < eps
error('Matrix is singular')
end
% Interchange rows k and p if needed
ifp˜=k
b = swapRows(b,k,p);
s = swapRows(s,k,p);
A = swapRows(A,k,p);
end
Search WWH ::
Custom Search