Graphics Programs Reference
In-Depth Information
LUdec5
The function LUdec3 decomposes a symmetric, pentadiagonal matrix A storedinthe
form A
f ]. The original vectors d , e and f are destroyed and replacedby
the vectors of the decomposedmatrix.
=
[ f
\
e
\
d
\
e
\
function [d,e,f] = LUdec5(d,e,f)
%LUdecompositionofpentadiagonalmatrixA=[f\e\d\e\f].
% USAGE: [d,e,f] = LUdec5(d,e,f)
n = length(d);
fork=1:n-2
lambda = e(k)/d(k);
d(k+1) = d(k+1) - lambda*e(k);
e(k+1) = e(k+1) - lambda*f(k);
e(k) = lambda;
lambda = f(k)/d(k);
d(k+2) = d(k+2) - lambda*f(k);
f(k) = lambda;
end
lambda = e(n-1)/d(n-1);
d(n) = d(n) - lambda*e(n-1);
e(n-1) = lambda;
LUsol5
LUsol5 is the function for the solutionphase.As in LUsol3 , the vector y over-
writes the constant vector b during forward substitution and x replaces y during back
substitution.
functionx=LUsol5(d,e,f,b)
%SolvesA*x=bwhereA=[f\e\d\e\f]istheLU
% decomposition of the original pentadiagonal A.
%USAGE:x=LUsol5(d,e,f,b)
n = length(d);
b(2) = b(2) - e(1)*b(1);
% Forward substitution
fork=3:n
b(k) = b(k) - e(k-1)*b(k-1) - f(k-2)*b(k-2);
end
Search WWH ::




Custom Search