LinearAlgebra[Modular] - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Linear Algebra : LinearAlgebra Package : Modular Subpackage : LinearAlgebra/Modular/RowReduce

LinearAlgebra[Modular]

  

RowReduce

  

Gauss row reduction of input Matrix

 

Calling Sequence

Parameters

Description

Examples

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.

  

For a standard nxm Matrix, augmented with two columns, specify rows=n, cols=m+2, and rcol=m. For a partially reduced nxn Matrix with one augmented column, where the first r rows have leading identity, the reduction of the remaining rows can be accomplished by specifying rows=r..n, cols=r..n+1, and rcol=nr+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 ( nxm ) Matrix is of full rank with respect to the first nxn 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 i rows of a matrix should have back-substitution performed on them if redflag is set to i.

• 

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.

withLinearAlgebra[Modular]:

p2741

p:=2741

(1)

AModp,Matrix4,5,i,j→rand,integer[]

A:=25431568127356581430154923761511183916419462114924183014807541049423

(2)

BCopyp,A:

RowReducep,B,4,5,4,'det',0,'rank',0,0,true:

B,rank

1000191601006590010181000125,4

(3)

Check the determinant.

det

82

(4)

modpLinearAlgebra:-DeterminantMatrixA1..4,1..4,datatype=integer,p

82

(5)

Check the solution.

Multiplyp,A,1..4,1..4,B,1..4,5,Copyp,A,1..4,5

58118392418423,58118392418423

(6)

Consider the system solution. Two steps looking at submatrices.

AModp,Matrix4,5,i,j→rand,float[8]

A:=1980.2533.1439.67.2051.2635.353.2657.1617.2198.2587.1857.827.1848.2338.1720.1181.493.1731.2264.

(7)

BCopyp,A:

First step, working with the first two rows of B.

RowReducep,B,1..2,5,4,'det1',0,0,0,0,true:

B

1.0.732.2653.1849.0.1.1097.941.1501.2587.1857.827.1848.2338.1720.1181.493.1731.2264.

(8)

Forward substitute.

forito2doforjto2doAddMultiplep,pB2+i,j,B,2+i,B,j,B,2+iend doend do:B

1.0.732.2653.1849.0.1.1097.941.1501.0.0.608.581.2260.0.0.508.1120.2290.

(9)

Work with the remaining two rows of B.

RowReducep,B,3..4,3..5,2,'det2',0,0,0,0,true:

B

1.0.732.2653.1849.0.1.1097.941.1501.0.0.1.0.2413.0.0.0.1.1536.

(10)

Back-substitute last two rows with entries in first two by using shortcut specification for last three columns.

forito2doforjto2doAddMultiplep,pBi,2+j,B,i,3..5,B,j+2,3,B,i,3end doend do:B

1.0.0.0.1596.0.1.0.0.1377.0.0.1.0.2413.0.0.0.1.1536.

(11)

Check the determinant.

modprounddet1det2,p

2603

(12)

modpLinearAlgebra:-DeterminantMatrix4,4,i,j→roundAi,j,datatype=integer,p

2603

(13)

Check the solution.

Multiplyp,A,1..4,1..4,B,1..4,5,Copyp,A,1..4,5

2051.2198.2338.2264.,2051.2198.2338.2264.

(14)

Back substitution only acting on the first row

p65521

p:=65521

(15)

MCreatep,4,5,'random',integer[]

M:=376066440307911786645834553816159723313465421456079636696651356371352874493385050550237621146483

(16)

RowReducep,M,4,5,4,0,0,0,0,0,1:

M

100017540014564514195369120016472852075000141141

(17)

See Also

LinearAlgebra/Details

LinearAlgebra[Modular]

LinearAlgebra[Modular][AddMultiple]

LinearAlgebra[Modular][Copy]

LinearAlgebra[Modular][Create]

LinearAlgebra[Modular][Determinant]

LinearAlgebra[Modular][Mod]

LinearAlgebra[Modular][Multiply]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam