Permute Matrix
Rearranging rows or columns of a matrix.
blockType: PermuteMatrix
Path in the library:
|
Description
Block Permute Matrix generates a new matrix from the columns (rows) of the original matrix by rearranging and/or copying them. The block re-orders the rows or columns of the input matrix size on according to the column (row) numbers received from the Input P.
Ports
Input
A — input matrix
scalar
| vector
| matrix
The original matrix.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, UInt8
, UInt16
, UInt32
, UInt64
, Bool
Support for complex numbers: Yes
P — column (row) numbers for permutation
scalar
| vector
| matrix
The numbers of columns (rows) of matrix A, from which a new matrix will be formed. Scalar or vector.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, UInt8
, UInt16
, UInt32
, UInt64
Support for complex numbers: None
Output
Port_1 — output matrix
scalar
| vector
| matrix
The output matrix formed by rearranging the rows or columns of the input. The output data type is the same as the Input. The dimension of the original matrix is preserved.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, UInt8
, UInt16
, UInt32
, UInt64
, Bool
Support for complex numbers: Yes
Parameters
Permute — pass permutation method:q[<br>] Columns (by default)
| Rows
Specifies whether the columns or rows of the input matrix will be rearranged to get the output matrix.
If the Permute parameter has the value:
-
Rows
— the block uses the rows of the input matrix A to create a matrix having the same column dimension. The Input P is a vector of length L, whose elements determine where each row from the input matrix A should be placed in the output matrix L by N.To rearrange the rows, the block considers an undirected vector of length M arriving at port A as an M-by-1 matrix.
-
`Columns' — the block uses the columns of the input matrix A to create a matrix having the same row dimension. A vector of length L is fed to the Input P, the elements of which determine where each column from the input matrix A should be placed in the output matrix M by L.
To rearrange the columns, the block considers an undirected vector of length N arriving at port A as a 1-by-N matrix.
Index mode — pass index mode:q[<br>] One-based (by default)
| Zero-based
When setting the One-based
value, the value 1 in the permutation vector P refers to the first row or column of the input matrix A. When set to Zero-based
, the value 0 in P refers to the first row or column of A.
Invalid permutation index — reaction to an invalid pass index value:q[<br>] Clip index (by default)
| Clip and warn
| Generate error
Reaction to an invalid index value. If the index value on the Input P refers to a non-existent row or column of the input matrix A, the block reacts as specified in this parameter. The following options are possible:
-
Clip index
— trim the index to the nearest acceptable value (1 or M for rearranging rows and 1 or N for rearranging columns) and do not issue a warning.Example: For a 3-by-7 input matrix, the column index equal to 9 is trimmed to 7, and the row index equal to −2, is trimmed to 1.
-
Clip and warn
is the same as the previous option; in future releases, when you select this option, a warning message will be displayed in the Engee command prompt window. -
`Generate error' — displays the error dialog box and aborts the simulation.
Error when length of P is not equal to Permute dimension size — error message for length P
disabled (by default)
| enabled
The option to display an error dialog box and stop modeling if the length of the permutation vector P is not equal to the number of rows or columns of the input matrix A.
You can choose to open the dialog box with an error and end the simulation by setting this parameter to on
.