# Transforming a permutation into a matrix: permu2mat

### 5.9.6 Transforming a permutation into a matrix: permu2mat

The matrix of a permutation p of size n is the matrix obtained by permuting the rows of the identity matrix of size n with the permutation p. Multiplying this matrix by a column vector of size n is the same as permuting the elements of the vector with the permutation p.

The permu2mat command finds the matrix of a given permutation.

- permu2mat takes one argument:
  p, a permutation p.
- permu2mat(p) returns the matrix of the permutation p.

#### Example.

Input:

permu2mat([2,0,1])

Output:

⎡
⎢
⎢
⎣

0 | 0 | 1
1 | 0 | 0
0 | 1 | 0

⎤
⎥
⎥
⎦