I need a working algorithm of Cholesky LU decomposition

2 views (last 30 days)
function [L] = cholesky(~)
% Computes L in Choleski's decomposition A = LL'
% USAGE: L = choleski(A)
A = [4, -2, 2; -2, 2, -4; 2, -4, 11];
n = size(A);
for j = 1:n
temp = (A(j,j) - dot(A(j,1:j-1),A(j,1:j-1)));
if temp < 0.0
error('matrix A must be square');
end
A(j,j) = sqrt(temp);
for i = j+1:n
A(i,j) = (A(i,j) - dot(A(i,1:j-1), A(j,1:j-1)))/A(j,j);
end;
end
L = tril(A);

Answers (0)

Categories

Find more on Linear Algebra in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!