view minors.m @ 1037:2d7ba44340d0 feature/burgers1d

Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 18 Jan 2019 09:02:02 +0100
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