function ShowCG()
close all
n = 1000;
density = .01;
% Nicely conditioned...
%eVals = rand(n,1); A = sprandsym(n,density,eVals); kMax = 250;

% Poorly conditioned
%A = sprandsym(n, density, .00000001, 1); kMax = 500;

% 20 distinct eigenvalues...
eVals = [rand(20,1);ones(n-20,1)+.00001*randn(n-20,1)]; A = sprandsym(n,density,eVals); kMax = 31;



b = A*ones(length(A),1);



[x,rVals] = cg0(A,b,kMax);
semilogy(rVals)
title('cg0','fontsize',18)
title(sprintf('cg0    n = %1d',length(n)),'Fontsize',18)
ylabel('|| A*xk - b ||','fontsize',18)
xlabel('k','fontsize',18)
shg
pause(1)

[x,rVals] = cg1(A,b,kMax);
semilogy(rVals)
title('cg1','fontsize',18)
ylabel('|| A*xk - b ||','fontsize',18)
xlabel('k','fontsize',18)
shg
pause(1)

[x,rVals] = cg2(A,b,kMax);
semilogy(rVals)
title('cg2','fontsize',18)
ylabel('|| A*xk - b ||','fontsize',18)
xlabel('k','fontsize',18)
shg


