cmatrix.Matrix.permut

Matrix.permut()

Do the permutation of the self matrix with the given signed permutation.

Parameters

type

Description

Permut

int list

list representing the signed permutation

([2,0,1] mean [a,b,c] become [c,a,b])

mode

int

Algorithm mode :
  • O mean vertical permutation

  • 1 mean horizontal permutation

Returns
Matrix

The permuted matrix from the given signed permutation (as vector)

Examples

>>> m=rand(4)
>>> print(m)
| +13.000 | +14.000 | +12.000 | +0.000 |
| +7.000 | +7.000 | +13.000 | +10.000 |
| +10.000 | +4.000 | +2.000 | +16.000 |
| +6.000 | +12.000 | +7.000 | +11.000 |
printed
>>> permut=[1,0,3,2]
>>> print(m.permut(permut,0))
| +14.000 | +7.000 | +4.000 | +12.000 |
| +13.000 | +7.000 | +10.000 | +6.000 |
| +0.000 | +10.000 | +16.000 | +11.000 |
| +12.000 | +13.000 | +2.000 | +7.000 |
printed
>>> print(m.permut(permut,1))
| +7.000 | +13.000 | +6.000 | +10.000 |
| +7.000 | +14.000 | +12.000 | +4.000 |
| +13.000 | +12.000 | +7.000 | +2.000 |
| +10.000 | +0.000 | +11.000 | +16.000 |
printed