function [u, d, l] = decomt(u, d, l) % usage: [u, d, l] = decomt(u, d, l) % % The LU decomposition of a tridiagonal matrix % using Gaussian elimination without pivoting % % Inputs % u the upper diagonal, overwritten by output % d the main diagonal, overwritten by output % l the subdiagonal, overwritten by output % Outputs % u the upper diagonal of U % d the main diagonal of U % l the subdiagonal of L n = length(d); for i=1:n-1, l(i) = l(i)/d(i); % multiplier d(i+1) = d(i+1) - l(i)*u(i); % update end