Mercurial > matrix-functions
view toolbox/krylov.m @ 2:c124219d7bfa draft
Re-add the 1995 toolbox after noticing the statement in the ~higham/mctoolbox/ webpage.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Thu, 07 May 2015 18:36:24 +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