function [Uzly,Dimenze,Usecky,Matice,PraveStrany,Omegy,Interpolace] = multigrid1D_setup(L)

% function [Uzly,Dimenze,Usecky,Matice,PraveStrany,Omegy,Interpolace] = multigrid1D_setup(L)

Uzly{1} = 0:0.01:1; %[0,0.5,1];
Dimenze{1} = length(Uzly{1});
Usecky{1} = [ [1:Dimenze{1}-1] ; [2:Dimenze{1}] ];
Interpolace{1} = [];

for l=1:L
    l
    
    % zjemneni site
    if l>1
        Uzly{l} = Uzly{l-1};
        Dimenze{l} = Dimenze{l-1};
        Usecky{l} = [];        
        Interpolace{l} = speye(Dimenze{l-1});
        for j=1:Dimenze{l-1}-1 % pro vsechny usecky spocti stredy
            idxUzel1 = Usecky{l-1}(1,j);
            idxUzel2 = Usecky{l-1}(2,j);
            uzel1 = Uzly{l-1}(idxUzel1);
            uzel2 = Uzly{l-1}(idxUzel2);
            novyUzel = 0.5 * ( uzel1 + uzel2 );
            Uzly{l} = [ Uzly{l} , novyUzel ];
            Dimenze{l} = Dimenze{l} + 1;
            Usecky{l} = [ Usecky{l} , [idxUzel1;Dimenze{l}] [Dimenze{l};idxUzel2] ];
            Interpolace{l} = [ Interpolace{l} ; zeros(1,Dimenze{l-1}) ];
            Interpolace{l}(Dimenze{l},idxUzel1) = 1/2;
            Interpolace{l}(Dimenze{l},idxUzel2) = 1/2;
        end
    end
    
    n = Dimenze{l};
    m = size(Usecky{l},2);
    tau = ones(m,1);
    f = ones(m,1);
    delka = 1;
    ID = [1,Dimenze{1}];
    uD = zeros(n,1);
    [A,b] = mkp_1d(Uzly{l},Usecky{l},tau,f,delka,ID,uD);
    Matice{l} = A;
    PraveStrany{l} = b;
    
    Omegy{l} = 1/Gershgorin(A);
            
end