Usually I work with 3D vectors using following types:
typedef vec3_t float[3];
initializing vectors using smth. like:
vec3_t x_basis = {1.0, 0.0, 0.0};
vec3_t y_basis = {0.0, 1.0, 0.0};
vec3_t z_basis = {0.0, 0.0, 1.0};
and accessing them using smth. like:
x_basis[X] * y_basis[X] + ...
Now I need a vector arithmetics using SSE instructions. I have following code:
typedef float v4sf __attribute__ ((mode(V4SF)))
int main(void)
{
v4sf a,b,c;
a = (v4sf){0.1f,0.2f,0.3f,0.4f};
b = (v4sf){0.1f,0.2f,0.3f,0.4f};
c = (v4sf){0.1f,0.2f,0.3f,0.4f};
a = b + c;
printf("a=%f \n", a);
return 0;
}
GCC supports such way. But... First, it gives me 0.00000 as result. Second, I cannot access the elements of such vectors. My question is: how can I access elements of such vectors? I need smth. like a[0] to access X element, a[1] to access Y element, etc.
PS: I compile this code using:
gcc -msse testgcc.c -o testgcc