Vector elements permutation

Vector elements permutation

Hello everybody,

I was wondering if there is a function which performs a permutation of the elements of a vector, in order to avoid the classic method consisting of defining a permutation matrix (which is filled with 1 or 0) and then calculating the product of this permutation matrix by the fixed vector.

For example, this function could probably have two vectors as input : X and P

  • X is the vector whose elements are to reorder, for eg : X = (2.3 / 5.4 / 9.1 / 3.1)
  • P is a vector filled with new positions, for eg : P = (2 / 1 / 4 / 3)

The supposed function will return an output vector Y (or X if it is overwritten by the reordered vector).

In the example above, Y = (5.4 / 2.3 / 3.1 / 9.1).

I have searched in the mkl manual and in the help, but I didn't succeed to find such function.

Thank you for your help !

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Best Reply

Have you tried the statement

y(1:4) = x(p(1:4))

or,  equivalent

y = x(p)    ?

Robert

 

How silly of me!

Thanks Robert :)

Charaf

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen