%forwardsubs % forward substitution to solve L y = b % input: L, b, n Output: y % L is a lower triangular matrix % b is the right-hand side vector % y is the solution vector % n is the number of rows (and columns) of L y= zeros(n,1); temp= b; for j=1:n, if (abs(L(j,j)) <= eps) sprintf('small diagonal element'); return; else y(j) = temp(j)/ L(j,j); i=j+1:n; temp(i) = temp(i) - L(i,j) * y(j); end; end;