LinearSolve - Maple Help

LinearAlgebra[Modular]

 LinearSolve
 solve linear system mod m

 Calling Sequence LinearSolve(m, M, naugment) LinearSolve(m, M, naugment, inplace=val)

Parameters

 m - modulus M - Matrix for solve naugment - number of augmented columns in Matrix val - inplace option true/false

Description

 • The LinearSolve function solves the linear system described by the augmented Matrix M with naugment augmented columns.
 • The allowable datatypes are hardware integer (dtype=integer[4]/integer[8] or integer[]), hardware float (dtype=float[8]), or Maple integer (dtype=integer).
 • By default the inplace option is true, and the command returns a reduced row echelon form of the input system, throwing an error if it is inconsistent, or no reduced row echelon form exists (i.e. for some composite m).
 If inplace is specified as false, the command returns the solution in forms of a sequence. The first element of the sequence is a Matrix (when naugment>1) or a Vector (when naugment=1) corresponding to a solution of the system, followed by the vectors in the nullspace. In the event of a unique solution (empty nullspace), only the one solution exists, so the return is just the first element. Note: even when inplace is set to false, the original input matrix is altered, so if this is not desired, the command should be called on a copy of the Matrix.
 • Note that this is just a high-level convenience function that uses RowReduce to do the actual work.
 • This command is part of the LinearAlgebra[Modular] package, so it can be used in the form LinearSolve(..) only after executing the command with(LinearAlgebra[Modular]).  However, it can always be used in the form LinearAlgebra[Modular][LinearSolve](..).

Examples

 > $\mathrm{with}\left({\mathrm{LinearAlgebra}}_{\mathrm{Modular}}\right):$

Create a random Matrix with a duplicate row (copy 4rth row to 2nd)

 > $p≔\mathrm{prevprime}\left({2}^{16}\right)$
 ${p}{≔}{65521}$ (1)
 > $M≔\mathrm{Create}\left(p,4,6,\mathrm{random},{\mathrm{integer}}_{[]},\mathrm{C_order}\right)$
 ${M}{≔}\left[\begin{array}{cccccc}{37606}& {6440}& {30791}& {17866}& {45834}& {55381}\\ {6159}& {7233}& {13465}& {42145}& {60796}& {36696}\\ {65135}& {63713}& {52874}& {49338}& {50505}& {50237}\\ {6211}& {46483}& {16997}& {48208}& {54630}& {19432}\end{array}\right]$ (2)
 > $\mathrm{ArrayTools}:-\mathrm{Copy}\left(6,M,18,M,6\right):$
 > $M$
 $\left[\begin{array}{cccccc}{37606}& {6440}& {30791}& {17866}& {45834}& {55381}\\ {6211}& {46483}& {16997}& {48208}& {54630}& {19432}\\ {65135}& {63713}& {52874}& {49338}& {50505}& {50237}\\ {6211}& {46483}& {16997}& {48208}& {54630}& {19432}\end{array}\right]$ (3)

Now solve a copy obtaining row reduced form:

 > $\mathrm{M2}≔\mathrm{copy}\left(M\right):$
 > $\mathrm{LinearSolve}\left(p,\mathrm{M2},2\right):$
 > $\mathrm{M2}$
 $\left[\begin{array}{cccccc}{1}& {0}& {0}& {5261}& {55562}& {46090}\\ {0}& {1}& {0}& {59286}& {23807}& {36734}\\ {0}& {0}& {1}& {43064}& {22132}& {25873}\\ {0}& {0}& {0}& {0}& {0}& {0}\end{array}\right]$ (4)

Now solve another copy obtaining the solution in (solution vector, nullspace) form

 > $\mathrm{M3}≔\mathrm{copy}\left(M\right):$
 > $\mathrm{sol}≔\left[\mathrm{LinearSolve}\left(p,\mathrm{M3},2,\mathrm{inplace}=\mathrm{false}\right)\right]$
 ${\mathrm{sol}}{≔}\left[\left[\begin{array}{cc}{55562}& {46090}\\ {23807}& {36734}\\ {22132}& {25873}\\ {0}& {0}\end{array}\right]{,}\left[\begin{array}{c}{5261}\\ {59286}\\ {43064}\\ {65520}\end{array}\right]\right]$ (5)

Check the solution and nullspace

 > $\mathrm{Multiply}\left(p,{M}_{1..4,1..4},{\mathrm{sol}}_{1}\right),{M}_{1..4,5..6}$
 $\left[\begin{array}{cc}{45834}& {55381}\\ {54630}& {19432}\\ {50505}& {50237}\\ {54630}& {19432}\end{array}\right]{,}\left[\begin{array}{cc}{45834}& {55381}\\ {54630}& {19432}\\ {50505}& {50237}\\ {54630}& {19432}\end{array}\right]$ (6)
 > $\mathrm{Multiply}\left(p,{M}_{1..4,1..4},{\mathrm{sol}}_{2}\right)$
 $\left[\begin{array}{c}{0}\\ {0}\\ {0}\\ {0}\end{array}\right]$ (7)