L
Lars Grobe
Hi,
first hello, I am new to the list, and I guess my question will show
that clearly.
I want to use some vector operations (at the moment altivec) in
existing code. It is a raytracing-based application, and for now, I
would like to replace the operations on my data type vect3 (which is a
float[3] array) by operations on a vector float. The vect3 is simply a
typedef to an array of floats so far.
Now I thought that I could use a union of vector and array of floats.
As these share memory, I could access the value by myvect.array[0] as
well as by myvect.vect, right? But I want to keep the interface to the
existing app, and it would be inconvenient to replace all myvect by
myvect.array. Here I hope that either the preprocessor or typedef
could help me, I just don't know how. Can I "redirect" calls to an
element of an array to a element of an array in an union? If not, I
would have to browse all code for useage of the vector type and replace
the array by the array in union.
And is the whole idea of using the vector and the array in the union to
get two interfaces to the same data a possible solution? I came to this
as it is proposed to keep arrays aligned, but I am not sure if I also
are allowed to use both.
TIA+CU, Lars.
first hello, I am new to the list, and I guess my question will show
that clearly.
I want to use some vector operations (at the moment altivec) in
existing code. It is a raytracing-based application, and for now, I
would like to replace the operations on my data type vect3 (which is a
float[3] array) by operations on a vector float. The vect3 is simply a
typedef to an array of floats so far.
Now I thought that I could use a union of vector and array of floats.
As these share memory, I could access the value by myvect.array[0] as
well as by myvect.vect, right? But I want to keep the interface to the
existing app, and it would be inconvenient to replace all myvect by
myvect.array. Here I hope that either the preprocessor or typedef
could help me, I just don't know how. Can I "redirect" calls to an
element of an array to a element of an array in an union? If not, I
would have to browse all code for useage of the vector type and replace
the array by the array in union.
And is the whole idea of using the vector and the array in the union to
get two interfaces to the same data a possible solution? I came to this
as it is proposed to keep arrays aligned, but I am not sure if I also
are allowed to use both.
TIA+CU, Lars.