vshuffle ( v perm -- w )
Factor handbook » The language » Numbers » Vector operations » Vector component- and bit-wise logic

Prev:vnone? ( v -- ? )


Vocabulary
math.vectors

Inputs
va SIMD array
perman array of integers, or a byte-array


Outputs
wa SIMD array


Word description
Permutes the elements of a SIMD array. Duplicate entries are allowed in the permutation. The perm argument can have one of two forms:
A literal array of integers of the same length as the vector. This will perform a static, elementwise shuffle.
A byte array or SIMD vector of the same byte length as the vector. This will perform a variable bytewise shuffle.


Examples
USING: alien.c-types math.vectors math.vectors.simd prettyprint ; int-4{ 69 42 911 13 } { 1 3 2 3 } vshuffle .
int-4{ 42 13 911 13 }

USING: alien.c-types combinators math.vectors math.vectors.simd namespaces prettyprint prettyprint.config ; IN: scratchpad : endian-swap ( size -- vector ) { { 1 [ uchar-16{ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 } ] } { 2 [ uchar-16{ 1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 } ] } { 4 [ uchar-16{ 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12 } ] } } case ; int-4{ 0x11223344 0x11223344 0x11223344 0x11223344 } 4 endian-swap vshuffle 16 number-base [ . ] with-variable
int-4{ 0x44332211 0x44332211 0x44332211 0x44332211 }


Definition


Methods