Mercurial > hg > camir-ismir2012
view toolboxes/FullBNT-1.0.7/KPMtools/checkpsd.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
line wrap: on
line source
function s = checkpsd(s) if (any(isnan(s) | isinf(s) | ~isreal(s))) warning('S contains complex numbers, Inf, or NaN'); end % Drop any negative eigenvalues. [V, D] = eig(full(s)); d = real(diag(D)); if (any(d < 0)) warning(sprintf(['S is not positive semidefinite (min. eig. =' ... ' %0.5g); projecting.'], min(d))); d(find(d < 0)) = 0; D = diag(d); s = V * D * V'; end