Mercurial > hg > ishara
view general/numerical/matrix/logabsdet.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | db7f4afd27c5 |
children |
line wrap: on
line source
function y = logabsdet(A) % logabsdet - logabsdet(X)=log(abs(det(X))) % % logabsdet :: [[N,N]] -> nonneg. % % This is faster and more stable than using log(det(A)). % (Except when A is not positive definite, in which case % we fall back to computing det(A) the usual way.) % From Tom Minka's lightspeed toolbox % Samer: added clause incase A not pos def. % this only works for HERMITIAN POS DEF matrix. % y = 2*sum(log(diag(chol(A)))); [R,p]=chol(A*A'); if p>0, fprintf('*** logabsdet warning: matrix is singular'); y=-inf; else y = sum(log(full(diag(R)))); end