2D Vectors

Hello there!

Reading the specification OpenCL i got an idea that instead of complex numbers, you can use two-dimensional vector. But i don’t understand, why i can’t multiply them? Why i should use somethin like this:


float2 mul_1(float2 a,float2 b)
{
 float2 x;
 x.even = a.even*b.even-a.odd*b.odd;
 x.odd = a.even*b.odd+a.odd*b.even;
 return x;
} /*mul_1 not my function, so i not understand how it work*/

 float2 x=(float2)(10, 20);
 x=mul_1(x, x);

Why not so:


 float2 x=(float2)(10, 20);
 x=x*x;

Well … because they’re not complex numbers, they are vectors? The last example means element by element multiplication, and to change it to ‘complex multiply’ would break every bit of existing code (and make no sense).

“/mul_1 not my function, so i not understand how it work/”

Well … multiplication of complex numbers is a fairly straightforward bit of complex number arithmetic, and that comment suggests you don’t understand it. Wikipeadia has a nice page about them:

http://en.wikipedia.org/wiki/Complex_number

complex numbers in opencl are a requested feature - i’d love to see them myself.

You know about math operation called “Cross product”(or something like that, i badly know English math terms), [a, b]?
http://en.wikipedia.org/wiki/Cross_product