function x=MyLRTriDiag(A,y)

DIM = length(y);

x = zeros(1,DIM);
od = diag(A,1);
ud = diag(A,-1);
md = diag(A);
tic
R(2,1) = md(1); % R(1,1) = A(1,1)
R(1,1) = od(1); % R(1,2) = A(1,2)

for i=2:DIM
    L(i-1) = ud(i-1)/R(2,i-1);
    R(2,i) = md(i)-L(i-1)*R(1,i-1);
    if i<DIM
        R(1,i) = od(i);
    end
end

% Vorwaertsrekursion L*z=y
z(1) = y(1);
for i=2:DIM
    z(i) = y(i)-L(i-1)*z(i-1);
end

% Rueckwaertsrekursion R*x=z
x(DIM) = z(DIM)/R(2,DIM);
for i=DIM-1:-1:1
    x(i) = (z(i)-R(1,i)*x(i+1))/R(2,i);
end
toc
end