about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/logdet.m
diff options
context:
space:
mode:
Diffstat (limited to 'sourcecodes/bnt-master/KPMtools/logdet.m')
-rw-r--r--sourcecodes/bnt-master/KPMtools/logdet.m8
1 files changed, 8 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMtools/logdet.m b/sourcecodes/bnt-master/KPMtools/logdet.m
new file mode 100644
index 00000000..cfff98d2
--- /dev/null
+++ b/sourcecodes/bnt-master/KPMtools/logdet.m
@@ -0,0 +1,8 @@
+function y = logdet(A)
+% log(det(A)) where A is positive-definite.
+% This is faster and more stable than using log(det(A)).
+
+%  From Tom Minka's lightspeed toolbox
+
+U = chol(A);
+y = 2*sum(log(diag(U)));