linalg::gaussJordan --
Gauss-Jordan elimination
Introductionlinalg::gaussJordan(A) performs
Gauss-Jordan elimination on the matrix A, i.e., it returns
the reduced row echelon form of A.
Call(s)linalg::gaussJordan(A <, All>)
ParametersA |
- | a matrix of a domain of category Cat::Matrix |
OptionsAll |
- | additionally returns the rank and the determinant of
A (if A is a square) as well as the
characteristic column indices of the matrix in reduced row echelon
form. |
Returnsa matrix of the same domain type as A, or the list
[T, rank(A), det(A), j1,...,jr] when the option All is given (see below).
Related
Functions
DetailsA must be an
integral domain, i.e., a domain of category Cat::IntegralDomain.Cat::Field, then the leading entries
of the matrix T in reduced row echelon form are equal to
one.
If R is a ring providing the method "gcd",
then the components of each row of T do not have a
non-trivial common divisor.
A is a field, then the
reduced row echelon form is unique.
Option:
AllA and
{j1,...,jr} is the set of characteristic column indices of
T.
If A is not square, then the value FAIL is
given instead of det(A).
Example
1We apply Gauss-Jordan elimination to the following matrix:
>> A := Dom::Matrix(Dom::Rational)(
[[1, 2, 3, 4], [-5, 0, 3, 0], [3, 5, 6, 9]]
)
+- -+
| 1, 2, 3, 4 |
| |
| -5, 0, 3, 0 |
| |
| 3, 5, 6, 9 |
+- -+
>> linalg::gaussJordan(A, All)
-- +- -+ --
| | 1, 0, 0, 1/2 | |
| | | |
| | 0, 1, 0, 1/2 |, 3, FAIL, {1, 2, 3} |
| | | |
| | 0, 0, 1, 5/6 | |
-- +- -+ --
We see that rank(B)=3. Because the
determinant of a matrix is only defined for square matrices, the third
element of the returned list is the value FAIL.
Example
2If we consider the matrix from example 1 as an integer matrix and apply the Gauss-Jordan elimination we get the following matrix:
>> B := Dom::Matrix(Dom::Integer)(
[[1, 2, 3, 4], [-5, 0, 3, 0], [3, 5, 6, 9]]
):
linalg::gaussJordan(B)
+- -+
| 2, 0, 0, 1 |
| |
| 0, -2, 0, -1 |
| |
| 0, 0, -6, -5 |
+- -+
BackgroundThe indices j1,j2,...,jr are the characteristic column indices of the matrix T.