--- /dev/null
+function ipd = is_positive_definite(A)
+ % Returns true if A is positive-definite, and false otherwise. We
+ % perform a full Cholesky factorization, so this is not fast.
+
+ ipd = false;
+
+ [R,p] = chol(A);
+
+ if (p == 0)
+ % The error flag is not set.
+ ipd = true;
+ end
+end
--- /dev/null
+A = [1,0;0,1];
+unit_test_equals("The identity is positive definite", ...
+ true, ...
+ is_positive_definite(A));
+
+A = [1,1;1,1];
+unit_test_equals("All-ones matrix is not positive definite", ...
+ false, ...
+ is_positive_definite(A));
+
+A = [5,1,2;1,6,3;2,3,7];
+unit_test_equals("A diagonally-dominant matrix is positive definite", ...
+ true, ...
+ is_positive_definite(A));