Using Sub-Matrix and Sub-Vector Specifications with the Modular Package
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.
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.
Specification of second row as a row Vector.
Specification of third column as a column Vector. Note that the row range must be provided.
Transpose of submatrix excluding first row and last column.
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.
Specification of part of the Vector, and part of the transpose.
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.
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.
Where the whole product is specified by the following.
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:
where the endpoints of the ranges for the second mod m Matrix are implied by the first.
Download Help Document
What kind of issue would you like to report? (Optional)