📄 condnum.m
字号:
function y = condnum (A,m)
%----------------------------------------------------------------
% Usage: y = condnum (A,m)
%
% Description: Compute the estimated or exact condition number of
% the n by n matrix A using the infinity norm:
%
% K(A) = ||A|| ||inv(A)||
%
% Inputs: A = n by n matrix
% m = number of vectors used to estimate K(A)
% (1 <= m <= n). If m = n, then the exact K(A)
% is computed using inv(A).
%
% Outputs: y = condition number K(A) of A.
%----------------------------------------------------------------
n = size(A,1);
if (m <= 0)
y = cond (A,1);
else
y = 0;
for i = 1 : m
b = randu(n,1,-1,1);
x = A\b;
y = max(y,norm(x,inf)/norm(b,inf));
end
y = y*norm(A,1);
end
%----------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -