function z=l_solve(L,z)
% z=l_solve(L,z)
% solve the system L*y=z
% L is a lower-triangular matrix
% z is the right hand side and may have more than one column
% z is also the solution

% M. M. Sussman
% $Date: 2011/02/18 15:21:16 $

n=size(z,1);

if n~=size(L,1) | n~=size(L,2)
  error('l_solve: L and z do not have consistent dimensions');
end

for row=1:n
  z(row,:) = (z(row,:) - L(row,1:row-1)*z(1:row-1,:)) / L(row,row);
end
