

function [l,l1,l2]=symm_invdet(E,y);

n=size(E,1);

try
    Ec=chol(E)';
    a(1)=y(1)/Ec(1,1);
    for i=2:n;
        a(i)=(y(i)-Ec(i,1:(i-1))*a(1:(i-1))')/Ec(i,i);
    end
    l1=0.5*a*a';
    e=diag(sqrt(2*pi)*Ec).^2;
    %if LP2==0;
    %    l2=0;
    %else
        l2=0.5*sum(log(e));
    %end
    l=l1+l2;
catch
    l=+inf;
    l1=+inf;
    l2=+inf;
end

