clear all;
close all;

N=51;
A=setA(N);
spy(A);
set(gca,'fontweight','bold','fontsize',[16]);
title('Tridiagonal matrix A');
eval(sprintf('print -depsc2 TridagA_%d.eps',N));
[L,U]=lu(A);
spy(L);
set(gca,'fontweight','bold','fontsize',[16]);
title('L');
eval(sprintf('print -depsc2 TridagL_%d.eps',N));
spy(U);
set(gca,'fontweight','bold','fontsize',[16]);
title('U');
eval(sprintf('print -depsc2 TridagU_%d.eps',N));
spy(inv(A));
set(gca,'fontweight','bold','fontsize',[16]);
title('Non-sparse A^{-1}');
eval(sprintf('print -depsc2 TridagAinv_%d.eps',N));
r=setrhs(N,8);
h=U\(L\r);
seehr(h,r);
title('Solution h and right-hand side r');
eval(sprintf('print -depsc2 Tridag_solution_%d.eps',N));
r(2:N-1)=rand(N-2,1);
h=U\(L\r);
seehr(h,r);
title('Solution for random r');
eval(sprintf('print -depsc2 Tridag_solution_rand_r_%d.eps',N));
