cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Zoltan_Maric
Journeyman III

Accessing elements of a vector in a loop

Hello!

Is there any way to access vector elements in a loop with a variable?

I'm looking for something like this:

int16 temp;
for (i = 0; i < 16; i++){
temp.s(i)= i;
}

or do i have to do it like this

temp.s0 = 0;
temp.s1 = 1;
etc.

?

0 Likes
4 Replies

Dynamically indexing into a vector is not allowed as a vector is not an array.
0 Likes

Thanks for the quick reply.

How about an arithmetic workaround then? How does shifting on vector datatypes work? Does the carry bit transfer to the neighbouring element?

0 Likes

Please see the OpenCL spec on shift operations on Vectors. It states that they are done per component.
0 Likes

Indeed. Thank you

0 Likes