Symmetric Lanczos approximations: error (column index out of bounds)

4 views (last 30 days)
I'm trying to calculate symmetric Lanczos approximations to exp(A)e_j (A is a 2361x2361 matrix, e_j is the j'th unit vector for j=1:2361) but can't get my code to work (I get the error "error: A(I,J): column index out of bounds; value 28 out of bound 1"). I think this is due to "lucky breakdown" but I still need the code to output an approximation for ALL j for use later on. My code:
% code
end
n = length(A);
for m = 1:n
v = eye(n)(:,m);
V = v/norm(v);
for j = 1:28
w = A*V(:,j);
for i = max(1,j-1):j
T(i,j) = V(:,i)'*w;
w = w - T(i,j)*V(:,i);
end
T(j+1,j) = norm(w);
if T(j+1,j) < j*eps
break;
end
V(:,j+1) = w/T(j+1,j);
end
Y(:,m) = V(:,1:28)*(expm(T(1:28,1:28))*(norm(v)*eye(28,1)));
end
Does anyone have any ideas of how I could fix this? Thanks in advance.

Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!