[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: how to create a permutation matrix

**From**: |
Jordi Gutiérrez Hermoso |

**Subject**: |
Re: how to create a permutation matrix |

**Date**: |
Mon, 26 Jan 2015 13:57:42 -0500 |

On Mon, 2015-01-26 at 18:58 +0100, c. wrote:
>* Is it expected that :*
>* *
>* >> P = eye (4);*
>* >> P = P([2 1 3 4], :);*
>* >> typeinfo (P)*
>* ans = permutation matrix*
>* *
>* but *
>* *
>* >> P = eye (4);*
>* >> P ([1 2], :) = P([2 1], :);*
>* >> typeinfo (P)*
>* ans = matrix*
Yes, that's the current implementation. You need to specify the full
permutation vector in order to get a permutation matrix. It would take
a bit more magic to realise that P([2 1], :) is being assigned to a
permuted version of itself and thus create a permutation matrix.
- Jordi G. H.