Mercurial > matrix-functions
view toolbox/krylov.m @ 8:a587712dcf5f draft default tip
funm_atom.m: rename fun_atom to funm_atom
* funm_atom.m: rename fun_atom to funm_atom.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Fri, 29 May 2015 09:48:36 +0200 |
parents | 8f23314345f4 |
children |
line wrap: on
line source
function B = krylov(A, x, j) %KRYLOV Krylov matrix. % KRYLOV(A, x, j) is the Krylov matrix % [x, Ax, A^2x, ..., A^(j-1)x], % where A is an n-by-n matrix and x is an n-vector. % Defaults: x = ONES(n,1), j = n. % KRYLOV(n) is the same as KRYLOV(RANDN(n)). % Reference: % G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, % Johns Hopkins University Press, Baltimore, Maryland, 1989, p. 369. [n, n] = size(A); if n == 1 % Handle special case A = scalar. n = A; A = randn(n); end if nargin < 3, j = n; end if nargin < 2, x = ones(n,1); end B = ones(n,j); B(:,1) = x(:); for i=2:j B(:,i) = A*B(:,i-1); end