Functions | |
if (ismatrix(varargin{1})) n | |
if | error ("onenormest: matrix must be square") |
if (size(varargin) > 1) t | |
else | if (size(varargin, 2)< 3) print_usage() |
if (size(varargin) > 3) t | |
if (issing) myeps | |
if (est > est_old||iter==2) w | |
if (iter > itmax) | |
if (all(partest)) break | |
endif | if (any(partest)) numpar |
S (:, partest) | |
if (iter >=2 &&mhi==ind_best) break | |
if (t > 1) firstind | |
if (all(been_there(firstind))) break | |
endfor | been_there (ind(1:t)) |
v (ind_best) | |
!norm (inv(A), 1)%!test%!N | |
!assert (nm1, N,-2 *eps) | |
!assert (nminf, N,-2 *eps) | |
!assert (norm(w1, 1), nm1 *norm(v1, 1),-2 *eps)%!assert(norm(winf | |
nminf * | norm (vinf, 1) |
id | N () |
!assert (nm1, norm(A, 1),-2 *eps) | |
!assert (nminf, norm(A, inf),-2 *eps) | |
!assert (nm1, norm(A, 1),-.1) | |
!assert (nminf, norm(A, inf),-.1) | |
Variables | |
function [est, v, w, iter] | |
endif | default_t = 5 |
itmax = 10 | |
if | n = size (varargin{1}, 2) |
endif | apply = @(x) varargin{1} * x |
apply_t = @(x) varargin{1}' * x | |
else | t = min (n, default_t) |
endif | issing = isa (varargin {1}, "single") |
endif | X = rand (n, t) |
been_there = zeros (n, 1) | |
est_old = 0 | |
S = zeros (n, t) | |
else | myeps = eps |
endif for | iter |
break | |
S_old = S | |
partest = any (abs (S_old' * S - n) < 4*eps*n) | |
replacements = 2*(rand (n,numpar) < 0.5) - 1 | |
endif | Z = feval (apply_t, S) |
h = max (abs (Z),2) | |
endif [h, ind] = sort (h, 'descend') | |
endif | ind = ind (!been_there (ind)) |
for | zz |
endfor | v = zeros (n, 1) |
endfunction!demo | !N = 100 |
!A = randn(N) + eye(N) | |
!nm1inv = lu(A) onenormest(@(x) U\(L\(P*x)), @(x) P'*(L'\(U'\x)) | |
N |
!assert | ( | nminf | , | |
norm(A, inf) | , | |||
-. | 1 | |||
) |
!assert | ( | nm1 | , | |
norm(A, 1) | , | |||
-. | 1 | |||
) |
!assert | ( | nminf | , | |
norm(A, inf) | , | |||
-2 * | eps | |||
) |
!assert | ( | nm1 | , | |
norm(A, 1) | , | |||
-2 * | eps | |||
) |
!assert | ( | norm(w1, 1) | , | |
nm1 * | normv1, 1, | |||
-2 * | eps | |||
) |
!assert | ( | nminf | , | |
N | , | |||
-2 * | eps | |||
) |
!assert | ( | nm1 | , | |
N | , | |||
-2 * | eps | |||
) |
!norm | ( | inv(A) | , | |
1 | ||||
) |
if error | ( | "onenormest: matrix must be square" | ) |
if | ( | all(been_there(firstind)) | ) |
if | ( | t | , | |
1 | ||||
) |
if | ( | iter >=2 && | mhi = =ind_best |
) |
if | ( | est | , | |
est_old|| | iter = =2 | |||
) |
if | ( | issing | ) |
if | ( | size(varargin) | , | |
3 | ||||
) |
else if | ( | ) |
if | ( | size(varargin) | , | |
1 | ||||
) |
if | ( | ismatrix(varargin{1}) | ) |
id N | ( | ) | [virtual] |
nminf * norm | ( | vinf | , | |
1 | ||||
) |
S | ( | : | , | |
partest | ||||
) |
v | ( | ind_best | ) |
!A = randn(N) + eye(N) |
endfunction !demo !N = 100 |
apply = @(x) varargin{1} * x |
apply_t = @(x) varargin{1}' * x |
been_there = zeros (n, 1) |
break |
h = max (abs (Z),2) |
itmax = 10 |
N |
endif n = size (varargin{1}, 2) |
replacements = 2*(rand (n,numpar) < 0.5) - 1 |
endif S = zeros (n, t) |
S_old = S |
endfor v = zeros (n, 1) |