Permute Matrix
A permutation of the rows or columns of a matrix.
Description
The Permute Matrix block forms a new matrix from the columns (rows) of the input matrix by rearranging and/or copying them. The block reorders the rows or columns of the input matrix A of size M by N according to the numbers of columns (rows) received from the P input.
Ports
Input
A - input matrix
scalar
| vector
| matrix
Initial matrix.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, UInt8
, UInt16
, UInt32
, UInt64
, Bool
.
Support for complex numbers: Yes
P - numbers of columns (rows) for permutation
scalar
| vector
| matrix
Numbers of columns (rows) of matrix A, from which the 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
An output matrix formed by rearranging the rows or columns of the input matrix. The data type of the output is the same as the input. The dimensionality 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 - permutation method
Columns (by default)
| Rows
Specifies whether the columns or rows of the input matrix are rearranged to produce the output matrix.
If the Permute parameter is set to:
-
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 treats the 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 supplied to the P input, whose elements 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 treats the undirected vector of length N arriving at port A as a 1-by-N matrix.
Index mode - index mode
One-based (by default)
| Zero-based
When One-based
is set, the value 1 in the permutation vector P refers to the first row or column of the input matrix A. When Zero-based
is set, the value 0 in P refers to the first row or column of A.
Invalid permutation index - response to an invalid index value
Clip index (By default)
| Clip and warn
| Generate error
Reaction to an invalid index value. If the index value on input P refers to a non-existent row or column of input matrix A, the block reacts as specified in this parameter. The following options are possible:
-
Clip index
- trim the index to the nearest valid value (1 or M for row permutation and 1 or N for column permutation) and not issue a warning.*Example: For a 3 by 7 input matrix, a column index equal to 9 is clipped to 7 and a row index equal to −2 is clipped to 1.
-
Clip and warn
- same as the previous option; in future releases, selecting this option will display a warning message in the Engee command line window. -
Generate error
- display an error dialogue box and abort the simulation.
Error when length of P is not equal to Permute dimension size - error message for length of P
Off (by default)
| On
Option to display a dialogue box about error and stop simulation if the length of permutation vector P is not equal to the number of rows or columns of input matrix A.
You can choose to open an error dialogue box and terminate the simulation by setting this option to on
.