static_math icon indicating copy to clipboard operation
static_math copied to clipboard

Complex Multiplication uses more multiplications than necessary

Open jm2118 opened this issue 8 years ago • 3 comments

(a + ib)(c + id) = (ac - bd) + (bc + ad)i (bc + ad) = (a+b)(c+d) - ac - bd

jm2118 avatar Oct 08 '17 18:10 jm2118

I reckon that you're right, but would that make any difference for such a library which is meant to be used at compile-time (and only at compile-time)? If not, I'd rather keep the naive albeit obvious formula which is currently used.

It could be interesting if the proposed formula somehow avoids precision loss for floating point numbers though, or if it is somehow less likely to overflow.

Morwenn avatar Oct 08 '17 20:10 Morwenn

It could be interesting if the proposed formula somehow avoids precision loss for floating point numbers though, or if it is somehow less likely to overflow.

Faster compile times are also nice to have especially in the kinds of bonkers template-heavy programs that are likely to be using your library.

ChrisKitching avatar Aug 02 '18 10:08 ChrisKitching

But does the change even make a significant difference in compile times?

Morwenn avatar Aug 02 '18 11:08 Morwenn