Coding my own Cholesky Decomposition Algorithm help?

17 次查看(过去 30 天)
I understand the idea of Cholesky Decomposition and can find it manually, but I am having a hard time creating my own MATLAB code to find a cholesky factor R, for a given positive definite matrix A.
So far my code is,
function[R] = getCholeskyFactor(A,n)
R=zeros(n,n);
for i=1:n
for j=1:n
R(i,i) = sqrt(A(i,i)-((R(j,i))^2))
for k = 1:n
R(i,j) = (A(i,j)-R(k,i)*R(k,j))/R(i,i)
end
end
end
But I realize I am missing different summations because r(i,i) = sqrt(A(i,i) - sum(R(k,i)^2,k=1:(i-1)) and r(i,j) = (A(i,j) - sum(R(k,i)*(R(k,j)),k=1:(i-1))/R(i,i).

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by