itermult.m

来自「D:matlab mmeigen.rar特征值」· M 代码 · 共 24 行

M
24
字号
function [u,lambda] = iterMult(A,x,nit)
% iterMult  Iterated multiplication of a vector by a matrix: u = A*A*...*A*x
%
% Synopsis:  u          = iterMult(A,x,nit)
%            [u,lambda] = iterMult(A,x,nit)
%
% Input:     A = an n by n matrix
%            x0 = n by 1 (column) vector to start the iterations
%            nit = number of iterations
%
% Output:    u = A*A* ... A*x, result of m multiplications of A on x
%                scaled by the max norm of the result at each step
%                The max norm of u is printed at each step
%            lambda = (optional) infinity norm of the scaled u
u = x;
fprintf('  k    norm(u,inf)\n');
for k=1:nit
  u = A*u;
  r = norm(u,inf);
  u = u/r;
  fprintf('%3d     %f\n',k,r);
end
if nargout==2, lambda = r; end

⌨️ 快捷键说明

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