How do I deduce replacement algorithms forwards and backwards in the solution phase of the Cholesky method?
How do I compare the function choleskiSol?
Here’s my code for choleskisol
function x = choleskiSol(L,b)
% Solves [L][L’]{x} = {b}
% USAGE: x = choleskiSol(L,b)
n = length(b);
if size(b,2) > 1
b = b’;
end % {b} must be column vector
for k = 1:n % Solution of [L]{y} = {b}
b(k) = (b(k) - dot(L(k,1:k-1),b(1:k-1)’))/L(k,k);
end
for k = n:-1:1 % Solution of {L}’{x} = {y}
b(k) = (b(k) - dot(L(k+1:n,k),b(k+1:n)))/L(k,k);
end
x = b;
The standard Cholesky decomposition (chol(A)) in matlab decomposes a symmetric (positive-definite) matrix, A, into upper-triangular form. To solve a linear system of equations, you must simply take the upper-triangular form, and solve it via backward substitution. This will yield the variable values for the system.
To complete the solution in matlab w/ parameter matrix A and output vector B: