function priklad_twogrid_1d()

global A0 A1 Lambda1 I1 smoothingSteps

prec = 1e-6;
smoothingSteps = 3;

h = 0.1;
uzly = 0:h:1;
n = length(uzly);
prvky = [ [1:n-1] ; [2:n] ];
ID = [ 1 n ];

m = n-1;
% f = ones(1,m);
f = zeros(1,m);
for i=1:m
    ti = sum(uzly(:,prvky(:,i)),2)/3;
    f(i) = sin(8*pi*ti(1))+sin(4*pi*ti(1)) + sin(pi*ti(1));
end

[A,b] = mkp_1d(uzly,prvky,f,ID);
A0 = A;

figure
u = A\b;
plot(uzly,u,'x')
hold on
pause

for l=1:10
     
    [uzly1,prvky1,I1] = refine1d(uzly,prvky);
    n = length(uzly1);
    
    m = n-1;
%     f1 = ones(1,m);
    f1 = zeros(1,m);
    for i=1:m
        ti = sum(uzly1(:,prvky1(:,i)),2)/3;
        f1(i) = sin(8*pi*ti(1))+sin(4*pi*ti(1)) + sin(pi*ti(1));
    end

    [A1,b1] = mkp_1d(uzly1,prvky1,f1,ID);
    
    Lambda1 = Gershgorin(A1);
    
    [u,k] = twogrid_iter(A1,b1,prec);

    plot(uzly1,u,'x')
    hold on
    
    log = sprintf('uroven %d: %d iteraci',l,k);
    disp(log)
    pause
    
    A0 = A1;
    uzly = uzly1;
    prvky = prvky1;
    
end
