Am 07.06.2022 um 17:01 schrieb Cottrell, Allin:
On Tue, Jun 7, 2022 at 9:42 AM Sven Schreiber
<svetosch(a)gmx.net> wrote:
> Hi,
>
> I'm wondering how I can easily construct the index vector associated
> with a permutation matrix. Here's an example:
>
> <hansl>
>
> pvec = {3,1,2} # given index vector
>
> matrix P = I(nelem(pvec))[pvec,] # associated permutation matrix
>
> matrix PT = I(nelem(pvec))[,pvec] # transpose of that
>
> wanted = {2,3,1} # associated with PT, how ??
>
> </hansl>
wanted = imaxr(PT)' # = imaxc(P)
Ah, of course, very nice!
So chaining the thing and spelling it out, for a given permutation
indexing vector p the resulting indexing for the inverse (=transpose
here) is:
pprime = imaxc( I(nelem(p))[p,] )
thanks
sven