about summary refs log tree commit diff
path: root/usth/MATH2.4/labwork/3/gauss.m
blob: 09128dc768d39f5bd3d5ff28001d63bcc18e7c96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
function x = gauss (A, b)
  issquare (A) || error ('Matrix A must be square');
  Aug = [A b];
  [m n] = size (Aug);
  % forward elimination
  for k = 1 : m - 1
    for l = k + 1 : m
      Aug(l, k:n) = Aug(l, k:n) - Aug(k, k:n)*Aug(l, k)/Aug(k, k);
    end
  end
  x = ubst (Aug);
end