
A = [2 4 -2; 4 9 -3; -2 -3 7]
b = [2; 8; 10]
pi = 1:3

% Schritt 1.a
temp = A(1,:)
A(1,:) = A(2,:)
A(2,:) = temp

temp = pi(1)
pi(1) = pi(2)
pi(2) = temp

% Schritt 1.b

% Eintraege in L berechnen
A(2:3,1) = A(2:3,1)/A(1,1)

% Rest der Matrix updaten
do_it_quick = false;
if( ~do_it_quick )
   for i=2:3
      for j=2:3
         A(i,j) = A(i,j) - A(i,1)*A(1,j)
      end
   end
else
   A(2:3, 2:3) = A(2:3, 2:3) - A(2:3,1)*A(1,2:3)
end

% Schritt 2.a
temp = A(2,:)
A(2,:) = A(3,:)
A(3,:) = temp

temp = pi(2)
pi(2) = pi(3)
pi(3) = temp

% Schritt 2.b
A(3,2) = A(3,2)/A(2,2)

A(3,3) = A(3,3) - A(3,2)*A(2,3)

