LinearAlgebra[Modular] - Maple Programming Help

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

LinearAlgebra[Modular]

 Copy
 copy mod m Matrix or Vector to a new or already existing mod m Matrix or Vector

 Calling Sequence Copy(m, ctype, A, B, order)

Parameters

 m - modulus A - input object (copy from), including subspec B - (optional) output object (copy to), including subspec order - (optional) ordering of output object ctype - (optional) copy type; lower, upper, uppernodiag, or lowernodiag

Description

 • The Copy function copies data from one mod m Matrix or Vector to another, or to a new Matrix or Vector.
 If B or order are not specified, a new output object with the same ordering as the input object A is returned. If B is not specified, the returned object has the specified ordering either C_order or Fortran_order.
 If order is not specified, the copy is performed into the output object B and NULL is returned. Note that the dimensions of the object specified for A must match those specified for B.
 In all cases, the datatype of the output object must match the datatype of the input object.
 • The ctype parameter is used to specify the type of copy to be performed. Valid options are upper for the upper triangular part of a Matrix, lower for the lower triangular part of a Matrix, and $\mathrm{uppernodiag}$ and $\mathrm{lowernodiag}$ for the corresponding copy operation without the diagonal.
 Note: These copy types are only valid for square Matrices.
 • The Copy function allows the use of sub-Matrix and sub-Vector specifications for both input and output. For example, the function can be used to copy a row of a Matrix to a row of another Matrix, or convert a Matrix into a Vector.
 Note: If A and B overlap, the behavior of Copy is undefined.
 • This command is part of the LinearAlgebra[Modular] package, so it can be used in the form Copy(..) only after executing the command with(LinearAlgebra[Modular]).  However, it can always be used in the form LinearAlgebra[Modular][Copy](..).

Examples

 > $\mathrm{with}\left({\mathrm{LinearAlgebra}}_{\mathrm{Modular}}\right):$
 > $A≔\mathrm{Mod}\left(13,\mathrm{Matrix}\left(4,4,\left(i,j\right)→\mathrm{rand}\left(\right)\right),{\mathrm{integer}}_{[]}\right)$
 ${A}{≔}\left[\begin{array}{cccc}{10}& {0}& {8}& {12}\\ {2}& {6}& {0}& {11}\\ {9}& {2}& {11}& {7}\\ {4}& {11}& {12}& {11}\end{array}\right]$ (1)

Copy entire Matrix.

 > $\mathrm{Copy}\left(13,A\right)$
 $\left[\begin{array}{cccc}{10}& {0}& {8}& {12}\\ {2}& {6}& {0}& {11}\\ {9}& {2}& {11}& {7}\\ {4}& {11}& {12}& {11}\end{array}\right]$ (2)

Copy row 3 to row Vector.

 > $M≔\mathrm{Copy}\left(13,A,3\right)$
 ${M}{≔}\left[\begin{array}{cccc}{9}& {2}& {11}& {7}\end{array}\right]$ (3)
 > $\mathrm{whattype}\left(M\right)$
 ${{\mathrm{Vector}}}_{{\mathrm{row}}}$ (4)

Copy column 2 to column Vector.

 > $N≔\mathrm{Copy}\left(13,A,1..-1,2\right)$
 ${N}{≔}\left[\begin{array}{c}{0}\\ {6}\\ {2}\\ {11}\end{array}\right]$ (5)
 > $\mathrm{whattype}\left(N\right)$
 ${{\mathrm{Vector}}}_{{\mathrm{column}}}$ (6)

Copy column 2 to a 4x1 Matrix.

 > $L≔\mathrm{Copy}\left(13,A,1..-1,2..2\right)$
 ${L}{≔}\left[\begin{array}{c}{0}\\ {6}\\ {2}\\ {11}\end{array}\right]$ (7)
 > $\mathrm{whattype}\left(L\right)$
 ${\mathrm{Matrix}}$ (8)

Copy row 3,2 of A to row 2,3 of B.

 > $B≔\mathrm{Create}\left(13,4,4,{\mathrm{integer}}_{[]}\right)$
 ${B}{≔}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\end{array}\right]$ (9)
 > $\mathrm{Copy}\left(13,A,3,B,2\right):$
 > $\mathrm{Copy}\left(13,A,2,B,3\right):$
 > $A,B$
 $\left[\begin{array}{cccc}{10}& {0}& {8}& {12}\\ {2}& {6}& {0}& {11}\\ {9}& {2}& {11}& {7}\\ {4}& {11}& {12}& {11}\end{array}\right]{,}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {9}& {2}& {11}& {7}\\ {2}& {6}& {0}& {11}\\ {0}& {0}& {0}& {0}\end{array}\right]$ (10)

This is an error, as B is too small.

 > $B≔\mathrm{Create}\left(13,4,3,{\mathrm{integer}}_{[]}\right)$
 ${B}{≔}\left[\begin{array}{ccc}{0}& {0}& {0}\\ {0}& {0}& {0}\\ {0}& {0}& {0}\\ {0}& {0}& {0}\end{array}\right]$ (11)
 > $\mathrm{Copy}\left(13,A,3,B,2\right):$

This example results in an error, as datatypes cannot be mixed.

 > $B≔\mathrm{Create}\left(13,4,4,{\mathrm{float}}_{8}\right)$
 ${B}{≔}\left[\begin{array}{cccc}{0.}& {0.}& {0.}& {0.}\\ {0.}& {0.}& {0.}& {0.}\\ {0.}& {0.}& {0.}& {0.}\\ {0.}& {0.}& {0.}& {0.}\end{array}\right]$ (12)
 > $\mathrm{Copy}\left(13,A,3,B,2\right):$

An example of upper and lower copy.

 > $\mathrm{Copy}\left(13,\mathrm{upper},A\right)$
 $\left[\begin{array}{cccc}{10}& {0}& {8}& {12}\\ {0}& {6}& {0}& {11}\\ {0}& {0}& {11}& {7}\\ {0}& {0}& {0}& {11}\end{array}\right]$ (13)
 > $B≔\mathrm{Create}\left(13,4,4,{\mathrm{integer}}_{[]}\right):$
 > $\mathrm{Copy}\left(13,\mathrm{lowernodiag},A,B\right):$
 > $B$
 $\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {2}& {0}& {0}& {0}\\ {9}& {2}& {0}& {0}\\ {4}& {11}& {12}& {0}\end{array}\right]$ (14)