Mercurial > repos > public > sbplib
diff minors.m @ 129:0a881a3dc9a9
Cleaned up the code for minors.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 03 Feb 2016 17:41:46 +0100 |
parents | minorsSym.m@967152d7d58b |
children | eaf557023fbe |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/minors.m Wed Feb 03 17:41:46 2016 +0100 @@ -0,0 +1,31 @@ +function [minor, sub] = minors(A) + [n, m] = size(A); + + if n ~= m + error('A must be square'); + end + + sub = {}; + ks = {}; + + ind = 1:n; + for k = 1:n + C = nchoosek(ind,k); + for i = 1:size(C,1) + ks{end + 1} = k; + sub{end + 1} = A(C(i,:),C(i,:)); + end + end + + for i = 1:length(sub) + fprintf('%d:\n', ks{i}); + disp(sub{i}) + + minor(i) = det(sub{i}); + end +end + + +% A is positive semidefinite if all minors are non-negative +% A is negative semidefinite if all odd minors are non-positive and all even minors are non-negative +