Swap - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


LinearAlgebra[Modular]

  

Swap

  

swap data between two mod m Matrices or Vectors of the same datatype

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Swap(m, ctype, A, B)

Parameters

m

-

modulus

A

-

mod m Matrix or Vector, including subspec

B

-

mod m Matrix or Vector, including subspec

ctype

-

(optional) swap type

Description

• 

The Swap function exchanges data between two mod m Matrices or Vectors.

  

Note that the dimensions of the object specified by 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 swap 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 uppernodiag and lowernodiag for the corresponding copy operation without the diagonal.

  

Note: These swap types are only valid for square Matrices.

• 

The Swap function allows the use of sub-Matrix and sub-Vector specifications for both input and output. For example, the function can be used to exchange a row of a Matrix with a row of another Matrix (or the same Matrix), or exchange data between a column in a Matrix and a row Vector.

  

Note: If A and B overlap, the behavior of Swap is undefined.

• 

This command is part of the LinearAlgebra[Modular] package, so it can be used in the form Swap(..) only after executing the command with(LinearAlgebra[Modular]).  However, it can always be used in the form LinearAlgebra[Modular][Swap](..).

Examples

withLinearAlgebraModular:

ACreate13,4,4,random,integer:

BCreate13,4,4,random,integer:

A,B

67731036610127612011,1210120591235251067510

(1)

Swap entire Matrices.

Swap13,A,B:

A,B

1210120591235251067510,67731036610127612011

(2)

Exchange rows 1 and 4 in A.

A

1210120591235251067510

(3)

Swap13,A,1,A,4:

A

6751059123525101210120

(4)

Swap row vector and third column of A.

VCreate13,0,4,random,integer

V25510

(5)

A

6751059123525101210120

(6)

Swap13,V,transpose,A,1..1,3:

A

672105953525101210100

(7)

Swap transposed upper triangular part of A with self (in-place transpose).

A

672105953525101210100

(8)

Swap13,upper,A,transpose,A:

A

655127921025510103100

(9)

See Also

LinearAlgebra/Details

LinearAlgebra[Modular]

LinearAlgebra[Modular][Copy]

LinearAlgebra[Modular][Create]

LinearAlgebra[Modular][Fill]

LinearAlgebra[Modular][subspec]