Method
Let
Use Squre Root Method, when
, we have:
Using these two function to realize Cholesky factorization.
function [L]=Cholesky(A) %平方根法
[N,N]=size(A);
X=zeros(N,1);
Y=zeros(N,1);
for i=1:N
A(i,i)=sqrt(A(i,i)-A(i,1:i-1)*A(i,1:i-1)'); if A(i,i)==0 'A is singular, no unique solution';
break;
end
for j=i+1:N
A(j,i)=(A(j,i)-A(j,1:i-1)*A(i,1:i-1)')/A(i,i); end end for x=1:N for y=1:N B(x,y)=A(x,y); %右上角元素归0 if x<y B(x,y)=0; break; end end end L=B