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