Graphics Programs Reference
In-Depth Information
Note that the originalcontents of c were destroyed and replacedbythe multipliers
during the decomposition. The solutionalgorithm for y by forward substitutionis
y(1) = b(1)
fork=2:n
y(k) = b(k) - c(k-1)*y(k-1);
end
The augmented coefficient matrix representing Ux
=
y is
d 1
e 1
0
···
0
0
y 1
0
d 2
e 2
···
0
0
y 2
U
y
00 d 3
···
0
0
y 3
=
.
.
.
.
.
.
000
···
d n 1
e n 1
y n 1
000
···
0
d n
y n
Note again that the contents of d were altered from the original values during the
decompositionphase (but e was unchanged). The solution for x isobtainedbyback
substitutionusing the algorithm
x(n) = y(n)/d(n);
fork=n-1:-1:1
x(k) = (y(k) - e(k)*x(k+1))/d(k);
end
LUdec3
The function LUdec3 contains the codefor the decompositionphase. The original
vectors c and d are destroyed and replacedbythe vectorsofthedecomposedmatrix.
function [c,d,e] = LUdec3(c,d,e)
%LUdecompositionoftridiagonalmatrixA=[c\d\e].
% USAGE: [c,d,e] = LUdec3(c,d,e)
n = length(d);
fork=2:n
lambda = c(k-1)/d(k-1);
d(k) = d(k) - lambda*e(k-1);
c(k-1) = lambda;
end
Search WWH ::




Custom Search