基于MATLAB的Cholesky分解法


Method


Let L=l11l21ln10l22ln2   00lnn L = [ l 11 0 ⋯   0 l 21 l 22 ⋯   0 ⋮ ⋮ ⋱ ⋮ l n 1 l n 2 ⋯   l n n ]
Use Squre Root Method, when A=LLT A = L L T , we have:

uii=aiik=1i1u2ki,i=1,,n u i i = a i i − ∑ k = 1 i − 1 u k i 2 , i = 1 , … , n

uij=aiji1k=1uikujkuii,j=i+1,,n u i j = a i j − ∑ k = 1 i − 1 u i k u j k u i i , j = i + 1 , … , n

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

你可能感兴趣的:(矩阵论)