LinearAlgebra[Modular][RowReduce] - Gauss row reduction of input Matrix
|
Calling Sequence
|
|
RowReduce(p, A, rows, cols, rcol, det, pdet, rank, sig, incrow, redflag)
|
|
Parameters
|
|
p
|
-
|
modulus
|
A
|
-
|
mod p Matrix
|
rows
|
-
|
number of rows, or range of rows to use
|
cols
|
-
|
number of columns, or range of columns to use
|
rcol
|
-
|
number of columns that represent variables
|
det
|
-
|
name to use for output determinant; 0 to disable
|
pdet
|
-
|
name to use for output pseudo-determinant; 0 to disable
|
rank
|
-
|
name to use for output rank; 0 to disable
|
sig
|
-
|
name to use for output signature; 0 to disable
|
incrow
|
-
|
name to use for output inconsistent row count; 0 to disable
|
redflag
|
-
|
boolean or integer; indicate whether to reduce row echelon form, or for how many rows
|
|
|
|
|
Description
|
|
•
|
The RowReduce function performs in-place Gauss elimination on the input mod p Matrix A. If redflag=false, it produces a row echelon form. If redflag=true, it produces a reduced row echelon form.
|
•
|
Generally, it is required that p be a prime, as inverses are needed, but in some cases it is possible to obtain row echelon form when p is composite. For the cases where row echelon form cannot be obtained for p composite, the function returns an error indicating that the algorithm failed because p is composite.
|
•
|
RowReduce can act on a sub-Matrix or augmented Matrix based on the values of rows, cols, and rcol. The parameters rows and cols can be integer values, or nonempty ranges with integer endpoints, which represent the total rows and columns (including any augmented columns) on which the row reduction should be performed. If specified as integer values, the range is assumed to start at 1.
|
•
|
If the determinant of the Matrix being reduced is required, specify det as a name. Otherwise, specify det as the value 0. On output, the name specified for det is assigned the value of the determinant. If the input Matrix has more variable columns than rows, the determinant is computed from the square Matrix formed by removing the extra columns from the end of the Matrix. If the input Matrix has fewer variable columns than rows, an error is produced.
|
|
Note: If the determinant is not required, set det to zero to avoid unnecessary calculations.
|
•
|
The pseudo-determinant of a Matrix is the determinant of the Matrix formed by removing any dependent rows and parametric columns (up to sign). In cases where the input ( ) Matrix is of full rank with respect to the first submatrix, the determinant and pseudo-determinant are the same. Use this value for reconstruction of solutions of integer linear systems that are rank deficient or underdetermined.
|
|
If the pseudo-determinant of the Matrix being reduced is required, specify pdet as a name. Otherwise, specify pdet as the value 0. On output, the name specified for pdet is assigned the value of the pseudo-determinant. If the input Matrix has fewer variable columns than rows, an error is produced.
|
|
Note: If the pseudo-determinant is not required, set pdet to zero to avoid unnecessary calculations.
|
•
|
The signature of a Matrix is an integer checksum that represents the correspondence of the solving columns and corresponding rows in the row echelon or reduced row echelon form of a Matrix. If for two Matrices, the pattern of pivots (location of the leading 1 entries in each row) is the same, their signature is also the same. However, two signatures being equal does not necessarily mean the two Matrices have the same pattern of pivots. Use this value is rapidly detect bad homomorphisms for reconstruction of the solution of an integer linear system.
|
|
If the signature of the Matrix being reduced is required, specify sig as a name. Otherwise, specify sig as the value 0. On output, the name specified for sig is assigned the value of the signature.
|
•
|
If the rank of the Matrix being reduced is required, specify rank as a name. Otherwise, specify rank as the value 0. On output, the name specified for rank is assigned the rank of the Matrix.
|
•
|
Specifying incrow as a name accomplishes two things. Firstly, it indicates that the algorithm continues computation even if inconsistent rows are found, placing those rows immediately after the consistent rows in the Matrix upon completion. Secondly, it indicates that the algorithm assigns the number of inconsistent rows found to incrow upon completion. If you specify incrow=0, the algorithm halts with an error when inconsistent rows are found.
|
•
|
The redflag parameter controls whether the output should be a reduced row echelon form (true) or a standard row echelon form with no back-substitution (false). In addition to these all-or-nothing settings, one can specify that the first rows of a matrix should have back-substitution performed on them if redflag is set to .
|
•
|
This command is part of the LinearAlgebra[Modular] package, so it can be used in the form RowReduce(..) only after executing the command with(LinearAlgebra[Modular]). However, it can always be used in the form LinearAlgebra[Modular][RowReduce](..).
|
|
|
Examples
|
|
For this basic augmented system, find the rank and determinant.
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
>
|
|
>
|
|
| (3) |
Check the determinant.
>
|
|
| (4) |
>
|
|
| (5) |
Check the solution.
>
|
|
| (6) |
Consider the system solution. Two steps looking at submatrices.
>
|
|
| (7) |
>
|
|
First step, working with the first two rows of B.
>
|
|
>
|
|
| (8) |
Forward substitute.
>
|
|
| (9) |
Work with the remaining two rows of B.
>
|
|
>
|
|
| (10) |
Back-substitute last two rows with entries in first two by using shortcut specification for last three columns.
>
|
|
| (11) |
Check the determinant.
>
|
|
| (12) |
>
|
|
| (13) |
Check the solution.
>
|
|
| (14) |
Back substitution only acting on the first row
>
|
|
| (15) |
>
|
|
| (16) |
>
|
|
>
|
|
| (17) |
|
|