function y = logdet(A) try U = chol(A); y = 2*sum(log(diag(U))) ; catch y = 0; warning('logdet:postdef', 'Matrix is not positive definite'); end end 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.