LinearAlgebra[Modular] - Maple Help

Online Help

All Products    Maple    MapleSim


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

LinearAlgebra[Modular]

  

AddMultiple

  

add multiple of a mod m Matrix or Vector to another

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

AddMultiple(m, mult, A, B, order, 'sparse')

AddMultiple(m, mult, A, B, C, 'sparse')

Parameters

m

-

modulus

A

-

Matrix or Vector, including subspec

B

-

Matrix or Vector, including subspec

order

-

ordering of output object

sparse

-

(optional) controls behavior of operation

mult

-

(optional) multiplier, default is 1

C

-

output Matrix or Vector, including subspec

Description

• 

The AddMultiple function performs the operation Bmult+A placing the output in a new object, or in C, depending on calling sequence. All of A, B, and C must be mod m Matrices or Vectors, and mult must be a scalar.

  

The first calling sequence returns a new mod m Matrix or Vector for the result with the specified ordering, order, or the ordering of the input objects A and B.

  

Note: If A and B have different ordering, order must be specified.

  

The second calling sequence places the output of the computation into C, returning NULL.

  

Note: The parameter C can be the same Matrix or Vector as A or B as long as the operation is performed with direct overlap.  For example, if A and C are the same Matrix, the operation involving the entry Ai,j must have the result going to Ci,j.

• 

The multiplier, mult, is an optional parameter.  However, if it is not specified, it is assumed to be 1. The multiplier must be in the range 0..m1.  This function can be used to perform Matrix or Vector subtraction by the selection of mult=m1. This is coded efficiently, that is, without multiplication.

• 

If specified, the optional keyword 'sparse', is only applicable if the multiplier is not 1 or m1 and the datatype is a hardware datatype.  It indicates that the algorithm checks for zero entries before performing multiplications. This typically provides an efficiency gain if matrices have 10% or more entries in B equal to zero. This is not implemented for the integer datatype, as it typically provides very little gain.

  

Note: In cases for which sparse does not apply but has been specified, the option is ignored.

• 

The AddMultiple function allows the use of sub-Matrix and sub-Vector specifications for both input and output Matrices or Vectors. For example, the function can be used to add a row of a Matrix to a row Vector, placing the result in the column of another Matrix.

• 

Note: If the used portion of A or B, and C overlap, but not directly, the behavior of AddMultiple is undefined.

• 

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

Examples

withLinearAlgebra[Modular]:

AMod13,Matrix4,4,i,j→rand,integer[]

A:=10081226011921174111211

(1)

BMod13,Matrix4,4,i,j→ifi=jthen1else0end if,integer[]

B:=1000010000100001

(2)

Default multiplier and new output Matrix (A+B).

AddMultiple13,A,B

11081227011921274111212

(3)

Chosen multiplier of 2 (A+2*B).

AddMultiple13,2,A,B

120812280119207411120

(4)

Replace A with the result.

AddMultiple13,2,A,B,A:

A

120812280119207411120

(5)

Add row 3 of A to row 2 of A, with output in column 1 of B.

AddMultiple13,A,3,'transpose',A,2,'transpose',B,1..1,1:

A,B

120812280119207411120,110001010000105001

(6)

Construct a larger Matrix and identity Matrix, using larger modulus.

N100:

p65535:

AModp,MatrixN,N,i,j→rand,float[8]

A:= 100 x 100 MatrixData Type: float8Storage: rectangularOrder: C_order

(7)

BModp,MatrixN,N,i,j→ifi=jthen1else0end if,float[8]

B:= 100 x 100 MatrixData Type: float8Storage: rectangularOrder: C_order

(8)

Time addition of 327*B to A 2000 times.

ttime:

forito2000doAddMultiplep,327,A,B,Aend do:timet

0.150

(9)

Time addition of 327*B to A 2000 times using sparse.

ttime:

forito2000doAddMultiplep,327,A,B,A,'sparse'end do:timet

0.047

(10)

See Also

LinearAlgebra/Details

LinearAlgebra[Modular]

LinearAlgebra[Modular][Mod]

LinearAlgebra[Modular][subspec]

 


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