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

Online Help

All Products    Maple    MapleSim


Using Sub-Matrix and Sub-Vector Specifications with the Modular Package

 

Description

Examples

Description

• 

Low-level functions in the Modular package allow for working with or on part of a Matrix or Vector, or with the transpose of a Matrix or Vector. This is most useful in utilization of the package for algorithms that use some form of blocking, or when only a part of a calculation is needed.

• 

Using standard Maple syntax to define sub-Matrices and sub-Vectors, for example, M1..5,2..3) produces a copy of the data, which is inefficient when the copy is not required for some other purpose. This functionality is provided to avoid data duplication.

• 

Examples of the available functionality include interpreting a row of a Matrix as a row Vector, interpreting a row Vector as a column Vector, interpreting some part of a Matrix as a smaller Matrix, etcetera.

• 

The basic specification for a Matrix is of the form Matrix,r, r1..r2,c, or c1..c2,transpose. Each of the three trailing entries is optional, but in order to provide a column-column range for a Matrix, the row-row range must be provided.

  

If the row is specified as a fixed value, for example, 2, but the column is not provided or specified as a range, the Matrix is interpreted as a row Vector with values corresponding to the specified row of the Matrix.

  

If the row is provided as a range and the column is a fixed value, the Matrix is interpreted as a column Vector with values corresponding to the specified column of the Matrix.

  

If both the row and column are fixed values, the selected entry of the Matrix is interpreted as a scalar (only valid for output).

  

If both the row and column are specified as ranges, the Matrix is interpreted as a sub-Matrix with the specified rows and columns.

  

Note: For all functions, it is invalid for a range to be empty. Ranges can include negative values, which are interpreted as offsets from the highest available value, similar to lists. For example, 1..−1 refers to the entire range.

  

The 'transpose' keyword is only available for input objects (not for output), and indicates that the specified sub-Matrix is transposed prior to performing the requested operation.

Examples

To illustrate these ideas, use the Copy function.  Note that usage of a subspec does not produce a copy unless the Copy function is used.

withLinearAlgebraModular:

MMod13,Matrix3,4,i,jrand,integer

M1008122601192117

(1)

Specification of second row as a row Vector.

Copy13,M,2

26011

(2)

Specification of third column as a column Vector. Note that the row range must be provided.

Copy13,M,1..1,3

8011

(3)

Transpose of submatrix excluding first row and last column.

Copy13,M,2..1,1..2,transpose

2962011

(4)

The basic specification for a column Vector is of the form Vectorcolumn,r or r1..r2,transpose. Where the row-row range, and transpose are optional.

The same comments apply as for the rows of a Matrix.

VMod13,Vectorcolumn4,i,jrand,integer

V4111211

(5)

Specification of part of the Vector, and part of the transpose.

Copy13,V,2..2,Copy13,V,2..2,transpose

1112,1112

(6)

Similarly the basic specification for a row Vector is of the form Vectorrow,c or c1..c2,transpose. Where the column-column range, and transpose are optional.

VMod13,Vectorrow5,i,jrand,integer

V8941110

(7)

Specification of part of the Vector, and part of the transpose.

Copy13,V,2..2,Copy13,V,2..2,transpose

9411,9411

(8)

Now as a more involved example, consider the product of a Matrix and its transpose, but only obtain the diagonal elements of the product, placing them in the diagonal of a Matrix of the product form. The following example accomplishes this.

MMod13,Matrix4,3,i,jrand,integer

M3551673083117

(9)

PCreate13,4,4,integer

P0000000000000000

(10)

forito4doMultiply13,M,i,M,i,transpose,P,i,ienddo:P

70000800008000010

(11)

Where the whole product is specified by the following.

Multiply13,M,M,transpose

7310838711078081010

(12)

The final item involves shortcut specifications. If the function being called accepts mod m Matrix or Vector arguments, any dimensions where the range is implied by prior arguments can only be specified by the start of the range.

For example, the following two AddMultiple commands are equivalent:

M1Mod13,Matrix3,4,i,jrand,integer

M16453541046959

(13)

M2Mod13,Matrix3,4,i,jrand,integer

M2104612651164972

(14)

AddMultiple13,1,M1,2..3,3..4,M2,1..2,2..3

110107

(15)

AddMultiple13,1,M1,2..3,3..4,M2,1,2

110107

(16)

where the endpoints of the ranges for the second mod m Matrix are implied by the first.

See Also

LinearAlgebra/Details

LinearAlgebra[Modular]

LinearAlgebra[Modular][AddMultiple]

LinearAlgebra[Modular][Copy]

LinearAlgebra[Modular][Create]

LinearAlgebra[Modular][Fill]

LinearAlgebra[Modular][Mod]

LinearAlgebra[Modular][Multiply]