2021-03-06 15:54:10 +01:00
|
|
|
% Algorithm 1: Outer Product Gaussian Elimination (Alg. 3.2.1)
|
|
|
|
function [U, Mk] = outer_product_gaussian_elimination(A)
|
2021-03-06 13:11:29 +01:00
|
|
|
|
|
|
|
[n, m] = size(A);
|
|
|
|
if n ~= m
|
|
|
|
error('Matrix is not squared!')
|
|
|
|
end
|
|
|
|
|
|
|
|
if det(A) == 0
|
|
|
|
error('Matrix is not nonsingular!')
|
|
|
|
end
|
|
|
|
|
2021-03-06 15:54:10 +01:00
|
|
|
A;
|
2021-03-06 13:11:29 +01:00
|
|
|
|
|
|
|
for k = 1 : n-1
|
2021-03-06 14:15:22 +01:00
|
|
|
rows = k + 1 : n;
|
|
|
|
A(rows, k) = A(rows, k)/A(k, k);
|
|
|
|
A(rows, rows) = A(rows, rows) - A(rows, k) * A(k, rows);
|
2021-03-06 15:54:10 +01:00
|
|
|
A;
|
2021-03-06 14:15:22 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
U = triu(A)
|
|
|
|
Mk = diag(A,-1) % Gauss vector
|