function [x it]=MySOR(A,y,omega,TOL)

N=length(y);
Res = norm(y,2);
itmax = 1000;
it=0;
x = zeros(1,N); % Startwert
xalt = x;

while Res > TOL & it < itmax
    for i=1:N
        summ=0;
        for j=1:N
            if j~=i
                summ = summ + A(i,j)*x(j);
            end
        end
        x(i) = ((y(i)-summ)/A(i,i))';
    end
    x = (1-omega)*xalt+x*omega;
    Res = norm(A*x'-y,2);
    it = it+1;
    xalt = x;
%    fprintf('Res (JOR) = %.2e nach %4d Iterationen\n',norm(A*x'-y,2),it);
end

FixNorm(A);

end

function FixNorm(A)

[M N] = size(A);
D = diag(diag(A));
L = zeros(N); R = zeros(N);
for i=2:N
    for j=1:i-1
        L(i,j)=A(i,j);
        R(j,i)=A(j,i);
    end
end

T = -inv(L+D)*R;

fprintf('||T||_1   = %.2e\n',norm(T,1));
fprintf('||T||_2   = %.2e\n',norm(T,2));
fprintf('||T||_inf = %.2e\n',norm(T,inf));

end
