This forum has been archived. All content is frozen. Please use KDE Discuss instead.

dot/cross product between Vector3d and Vector3cd

Tags: None
(comma "," separated)
sedibald
Registered Member
Posts
4
Karma
0
Hi,

I'd like to perform a dot/cross product between a Vector3d and a Vector3cd, but the code won't compile. Should I cast Vector3d into Vector3cd? But then I would lose efficiency in addition to casting, since:

1) complex times real = 2 real multiplications
2) complex times complex = 4 real multiplications

Maybe the code doesn't compile due to wrong headers? Or the code isn't implemented (in which case I would be happy to write the corresponding short piece of software, since I really need it).

Any help much appreciated!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
indeed currently this is forbidden, though we have all the logic for that. In the meantime for the dot product you can do:

a.adjoint() * b

and for the cross product you'll have to use cast<std::complex<double> >. I'll try to fix it asap.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
done for the dot() function.
sedibald
Registered Member
Posts
4
Karma
0
Thanks! That was a quick one!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
done for the cross product too.

btw, the cross product function was not correct for complexes. I also fixed that.
sedibald
Registered Member
Posts
4
Karma
0
Is it an efficient multiplication, meaning: double times complex? Or is it casting of the doubles to complex, then multiplying?

Oh, and is it ok for Vector3f and Vector3cf as well?

Thanks for the speedy implementation!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
there is no conversion, and yes this works for float and any other numeric types.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft