% demonstration of preconditioned conjugate gradient method:
% using K from discretization of the second derivative on a 
% L-shaped domain in 2d

 K = delsq(numgrid('L',62));
 L = ichol(K,struct('type','ict','droptol',1e-02,'michol','on'));
 f = ones(size(K,2),1);

 [a,flag,relres,iter,resvec] = pcg(K,f,1e-6,max(200,N));

 figure(1), clf
 semilogy([0:length(resvec)-1], resvec,'b.-','linewidth',2,'markersize',20)
 hold on

 L = ichol(K);
 [a,flag,relres,iter,resvec] = pcg(K,f,1e-6,max(200,N),L,L');
 semilogy([0:length(resvec)-1], resvec,'r.-','linewidth',2,'markersize',20)
