% function [x,j] = sor(A,b,x0,om,maxiter,tol)
% 
%   SOR method for solving linear systems iteratively
% inputs
%	A       system matrix
%	b       system right hand side
%	x0      initial guess
%       om      omega parameter for SOR
%	maxiter max number of iterations
%       tol     relative tolerance between two consecutive iterates 
%               (in l_inf norm)
%
% outputs
%	x	current solution
%	j       iteration number
function [x,j] = sor(A,b,x0,om,maxiter,tol)
n = size(A,1); x = zeros(size(x0));
for j=1:maxiter
 % print only first few iterates

 % SOR update

 % check for convergence
 if norm(x-x0,'inf')/norm(x0,'inf')<tol return; end;

end;
fprintf('Maximum number of iterations reached and tolerance not met\n');
