function x = my_tdma(c,a,b,f)
% reseni soustav s tridiagonalni matici
% Vstup :	a(i=1..n) - diagonalni prvky
%		c(i=2..n) - prvky pod diagonalou
%		b(i=1..n-1) - prvky nad diagonalou
%		f(i=1..n) - prave strany

    n = length(b);
    % pomocne promenne
    rho = zeros(1,n+1);
    mu = zeros(1,n+1);
    %  vektor s resenim
    x = zeros(1,n+1);
    % substituce + reseni
    for i=1:n
        mu(i+1) = -b(i)/(c(i)*mu(i)+a(i));
        rho(i+1)= (f(i)-c(i)*rho(i))/(c(i)*mu(i)+a(i));
    end
    % zpetna substituce
    for i = n:-1:1
        x(i) = mu(i+1)*x(i+1)+rho(i+1);
    end
    x(n+1) = []; %smazeme posledni pomocny prvek x
end