function [ L,U ] = my_lu( A )
s = size(A); % shape vector = rozmery matice = [radku, sloupcu]
if (length(s) ~= 2 || s(1) ~= s(2))
    disp('Zadejte ctvercovou matici');
    return;
end
L = 0.*A; % matice nul stejneho rozmeru jako A, dalsi moznosti je L = zeros(s)
U = 0.*A;
n = s(1); % rozmery matice A
for i = 1:n;
    L(i,i) = 1; % Jednicky na diagonalu L
end

for diagonala = 1:n %diagonala
    for sloupec = diagonala:n
        soucet = 0; %soucet prvku pod diagonalou
        for k = 1:diagonala-1
            soucet = soucet + L(diagonala,k)*U(k,sloupec);
        end 
        U(diagonala,sloupec) = A(diagonala,sloupec) - soucet;
    end
    for radek = diagonala+1:n
        soucet = 0;
        for k = 1:diagonala-1
            soucet = soucet + L(radek,k)*U(k,diagonala);
        end
        L(radek,diagonala) = (A(radek,diagonala) - soucet)/U(diagonala,diagonala);
    end
end
end

