Conversion Functions for Vectors

You cannot use standard type casting on vector data types. Instead, convert_<destination type>(<source type>) functions are provided to convert the elements of one vector type object into another vector type object. This is done on an element-by-element basis, and the source vector type and the destination vector type must be of the same length. That is, 4-element vectors can only be converted to other types of 4-element vectors.

The following example initializes a short2 vector using two ints concatenated to form an int2 vector:

void foo(int a, int b) { short2 svec2 = convert_short2((int2)(a, b)); ... }