
function esercizio_2015





% PROBLEM.
A=gallery('minij',20);

norm(A-A',inf)
eig(A)

b=ones(size(A,1),1);

% SETTINGS.
x=zeros(size(b));
max_it=20000;
tol=10^(-6);

% JACOBI.
[xj, ej, ij, fj]  = jacobi(A, x, b, max_it, tol);
fprintf('\n \n JACOBI: ERR.: %1.1e ITER.: %4.0f FLAG: %1.0f', ...
    ej, ij, fj);


% GAUSS-SEIDEL.
omegas=0.1:0.05:2;
igs_s=[];
for omega=omegas
[xgs, egs, igs, fgs]  = sor(A, x, b, omega, max_it, tol);
igs_s=[igs_s; igs];
fprintf('\n SOR: ERR.: %1.1e ITER.: %4.0f FLAG: %1.0f \n \n',...
    egs, igs, fgs);
end

semilogy(omegas,igs_s)

cond_A=condest(A)

