NVECT = [15000:5000:50000];
%=================================
j=0;
for N1 = NVECT
    nx = fix(N1^(1/2));
    [A,N]=sp_laplace(nx,nx);
    fprintf(' GE 2D: nx = %d, N = %d \n', nx,N);
    b=rand(N,1);
    tic; x=A\b; T=toc,
    j=j+1;
    TGE2D(j) = T;
    NGE2D(j) = N;
end
fprintf(' \n');

figure(1), clf, hold off
semilogy(NGE2D/1000,TGE2D)
hold on
semilogy(NGE2D/1000,TGE2D,'o')
%=================================
j=0;
for N1 = NVECT
    nx = fix(N1^(1/3));
    [A,N]=sp_laplace3D(nx,nx,nx);
    fprintf(' GE 3D: nx = %d, N = %d \n', nx,N);
    b=rand(N,1);
    tic; x=A\b; T=toc,
    j=j+1;
    TGE3D(j) = T;
    NGE3D(j) = N;
end
fprintf(' \n');

semilogy(NGE3D/1000,TGE3D,'-b')
semilogy(NGE3D/1000,TGE3D,'ob')
%=================================

%%%[x,resids,its] = cg(A,b,x0,rtol,max_it,print_step);
j=0;
for N1 = NVECT
    nx = fix(N1^(1/2));
    [A,N]=sp_laplace(nx,nx);
    fprintf(' CG 2D: nx = %d, N = %d \n', nx,N);
    b=rand(N,1);
    x0=zeros(size(b));
    rtol=1e-6;
    max_it=10000;
    print_step=1000;
    tic
    [x,resids,its] = cg(A,b,x0,rtol,max_it,print_step);
    T=toc,
    j=j+1;
    TCG2D(j) = T;
    NCG2D(j) = N;
end
fprintf(' \n');

semilogy(NCG2D/1000,TCG2D,'r')
semilogy(NCG2D/1000,TCG2D,'or')
%=================================
%%%[x,resids,its] = cg(A,b,x0,rtol,max_it,print_step);
j=0;
for N1 = NVECT
    nx = fix(N1^(1/3))
    [A,N]=sp_laplace3D(nx,nx,nx);
    fprintf(' CG 3D: nx = %d, N = %d \n', nx,N);
    b=rand(N,1);
    x0=zeros(size(b));
    rtol=1e-6;
    max_it=10000;
    print_step=1000;
    tic
    [x,resids,its] = cg(A,b,x0,rtol,max_it,print_step);
    T=toc,
    j=j+1;
    TCG3D(j) = T;
    NCG3D(j) = N;
end
fprintf(' \n');

semilogy(NCG3D/1000,TCG3D,'-r')
semilogy(NCG3D/1000,TCG3D,'or')
%=================================