Mercurial > repos > public > sbplib
comparison minors.m @ 167:15baeb35f74e feature/grids
Merge in changes from default.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 23 Feb 2016 13:25:43 +0100 |
parents | 0a881a3dc9a9 |
children | eaf557023fbe |
comparison
equal
deleted
inserted
replaced
166:7cb97c1988d9 | 167:15baeb35f74e |
---|---|
1 function [minor, sub] = minors(A) | |
2 [n, m] = size(A); | |
3 | |
4 if n ~= m | |
5 error('A must be square'); | |
6 end | |
7 | |
8 sub = {}; | |
9 ks = {}; | |
10 | |
11 ind = 1:n; | |
12 for k = 1:n | |
13 C = nchoosek(ind,k); | |
14 for i = 1:size(C,1) | |
15 ks{end + 1} = k; | |
16 sub{end + 1} = A(C(i,:),C(i,:)); | |
17 end | |
18 end | |
19 | |
20 for i = 1:length(sub) | |
21 fprintf('%d:\n', ks{i}); | |
22 disp(sub{i}) | |
23 | |
24 minor(i) = det(sub{i}); | |
25 end | |
26 end | |
27 | |
28 | |
29 % A is positive semidefinite if all minors are non-negative | |
30 % A is negative semidefinite if all odd minors are non-positive and all even minors are non-negative | |
31 |