Mercurial > repos > public > sbplib
view minors.m @ 1198:2924b3a9b921 feature/d2_compatible
Add OpSet for fully compatible D2Variable, created from regular D2Variable by replacing d1 by first row of D1. Formal reduction by one order of accuracy at the boundary point.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Fri, 16 Aug 2019 14:30:28 -0700 |
parents | eaf557023fbe |
children |
line wrap: on
line source
function [minor, sub] = minors(A, verbose) default_arg('verbose', true); [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) if verbose fprintf('%d:\n', ks{i}); disp(sub{i}) end 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