annotate toolboxes/FullBNT-1.0.7/KPMtools/is_psd.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function b = positive_semidefinite(M)
wolffd@0 2 %
wolffd@0 3 % Return true iff v M v' >= 0 for any vector v.
wolffd@0 4 % We do this by checking that all the eigenvalues are non-negative.
wolffd@0 5
wolffd@0 6 E = eig(M);
wolffd@0 7 if length(find(E>=0)) == length(E)
wolffd@0 8 b = 1;
wolffd@0 9 else
wolffd@0 10 b = 0;
wolffd@0 11 end