function y=l_solve(L,z)
% y=l_solve(L,z)
% L is a lower-triangular matrix whose diagonal entries are 1
% z is the right hand side
% y is the solution of L*y=z

% your name and the date

% set n for convenience and simplicity
n=length(z);
% initialize y to zero and make sure it is a column vector
y=zeros(n,1); 

% first row is really an easy one, especially since the diagonal
% entries of L are equal to 1
Irow=1;
y(Irow)=z(Irow);

for Irow=2:n
  rhs = z(Irow);
  for Jcol=1:Irow-1
    rhs = rhs - L(Irow,Jcol)*y(Jcol);
  end
  y(Irow) = rhs;
end
