⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regularize.m

📁 These Matlab files are a convenient interface for the Java library containing the implementation of
💻 M
字号:
% REGULARIZE - Regularizes a matrix so that it is positive definite.
%
%
%
%
function s = regularize(s)

if (isempty(s))
  return;
end
thresh = sqrt(eps);
span = 1e5;
[V, D] = eig(full(s));
% Eliminate imaginary and negative eigenvalues.
d = real(diag(D));
d(find(d < 0)) = 0;
% Compute the condition number of the matrix.
if ~min(d)
  cond = Inf;
else
  cond = max(d) / min(d);
end
% If the condition number is greater than a threshold, then
% regularize the matrix by filling out its eigenspectrum.
if (cond > span)
  min_eig = max(d) / span;
  d = d + min_eig;
end
s = V * diag(d) * V';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -