Skip to content

Instantly share code, notes, and snippets.

@mrfarhadir
Created November 30, 2018 11:43
Show Gist options
  • Save mrfarhadir/9ca5307111eeb80025fd1470b1c6e691 to your computer and use it in GitHub Desktop.
Save mrfarhadir/9ca5307111eeb80025fd1470b1c6e691 to your computer and use it in GitHub Desktop.
Cholesky matrix decompression in matlab
%Cholesky matrix decompression
function [retval] = Cholesky (A)
n = length( A );
L = zeros( n, n );
for i=1:n
L(i, i) = sqrt(A(i, i) - L(i, :)*L(i, :)');
for j=(i + 1):n
L(j, i) = (A(j, i) - L(i,:)*L(j ,:)')/L(i, i);
end
end
retval = L;
endfunction
A=[4 5 9;-2 6 0;1/2 6 10];
L=Cholesky(A)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment