Advertisement
ogiorgil

forward_elim()

Oct 7th, 2022
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.25 KB | None | 0 0
  1. function x = forward_elim(L, b)
  2.    n = length(b);
  3.    x = zeros(n, 1);
  4.    x(1) = b(1)/L(1, 1);
  5.    for i = 2:n
  6.      sum = 0;
  7.      for j = 1:i-1
  8.        sum = sum + L(i, j) * x(j);
  9.      endfor
  10.      x(i) = (b(i)-sum)/L(i, i);
  11.    endfor
  12. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement