art.m 926 Bytes
 Jan-Gerrit Richter committed Jul 29, 2016 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ``````function [X,rho,eta] = art(A,b,k) %ART Algebraic reconstruction technique (Kaczmarz's method). % % [X,rho,eta] = art(A,b,k) % % Classical Kaczmarz iteration, or ART (algebraic reconstruction % technique), applied to the system A x = b. The number of % iterations is k. % Reference: F. Natterer and F. Wbbeling, Mathematical Methods % in Image Reconstruction, SIAM, Philadelphia, 2001; Sect. 5.3.1. % Per Christian Hansen, IMM, Dec. 6, 2006. % Initialization. if (k < 1), error('Number of steps k must be positive'), end [m,n] = size(A); X = zeros(n,k); if (nargout > 1) eta = zeros(k,1); rho = eta; end % Prepare for iteration. x = zeros(n,1); %nai2 = full(sum(A.*A,2)); nai2 = full(sum(abs(A.*A),2)); I = find(nai2>0)'; % Iterate. for j=1:k for i=I Ai = full(A(i,:)); x = x + (b(i)-Ai*x)*Ai'/nai2(i); end if (nargout > 1) eta(j) = norm(x); rho(j) = norm(b-A*x); end X(:,j) = x; end``````