vbroadcast ( u n -- v ) (original) (raw)

vbroadcast ( u n -- v )
Factor handbook » The language » Numbers » Vector operations » Vector shuffling, packing, and unpacking

Prev: vshuffle ( v perm -- w )
Next: hlshift ( v n -- w )

Vocabulary
math.vectors

Inputs

u a SIMD array
n a non-negative integer

Outputs

v a SIMD array

Word description
Outputs a new SIMD array of the same type as u where every element is equal to the nth element of u.

Examples

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

Definition

IN: math.vectors

GENERIC#: vbroadcast 1 ( u n -- v )

Methods

USING: kernel math.vectors sequences ;

M:: object vbroadcast ( u n -- v )
u length n u nth u like ; inline

USING: kernel math.vectors math.vectors.simd sequences ;

M: simd-128 vbroadcast swap [ nth ] [ simd-with ] bi ; inline