Results 1 to 2 of 2

Thread: vector component duplication

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Location
    Paris
    Posts
    11

    vector component duplication

    Hi,

    I need to make a vector B from vector A but with possibly duplicating some of the elements (i.e. arbitrary sampling and not a permutation)

    does

    float8 A,B;
    B=shuffle(A,(int 8)(0,0,0,1,1,2,3,3));

    makes sense for all (or any) OpenCL implementation for accomplishing:

    B.s0=A.s0;
    B.s1=A.s0;
    B.s2=A.s0;
    B.s3=A.s1;
    B.s4=A.s1;
    B.s5=A.s2;
    B.s6=A.s3;
    B.s7=A.s3;

    i.e. is it strictly necessary to have in mask variable entries all the numbers from 0 to pow2(vec_step)-1 or could we assume that duplicate (hence also missing) numbers are accepted

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: vector component duplication

    I find this syntax somewhat easier:

    B = A.s00011233;

    You can create arbitrary permutations this way, each side just has to have the right number of elements.

    e.g.
    B.s05 = A.s23;
    is also valid.

    (how efficiently such operations are implemented on a given machine are another matter).

    On your last question, any valueN taking things need to take the same sized value. Casting up pads the higher elements with zero.

Similar Threads

  1. confusing duplication
    By rcvangemert in forum OpenCL
    Replies: 3
    Last Post: 01-12-2010, 05:17 AM
  2. Replies: 1
    Last Post: 10-01-2009, 05:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •