[PATCH, libstdc++, complex] complex multiplication algorithm improved
Basile Starynkevitch
basile@starynkevitch.net
Wed Sep 15 10:27:00 GMT 2010
On Wed, 15 Sep 2010 16:10:40 +0800
Wang Feng <wanng.fenng@gmail.com> wrote:
> Hi,
> Complex number multiplication done with 4 multiplications, but
> this one only need 3:
>
> (a+ib)(c+id) = ac - bd + i( bc + ad ) -- 4 multiplies
> = ac - bd + i[ ( a + b )( c + d ) - ac
Are you sure it is worth it?
I am not a processor expert, but common folklore says that floating
point addition is slower than floating point multiplication. Also, some
recent instruction sets have a multiply and add instruction, or an add
and multiply one.
Did you happen to measure the gain in CPU time for your patch on a
recent PC running Linux or some other common machine?
And there might perhaps be some rounding or precision issues (IEEE
floating point is a tricky beast in the ugly details).
Maybe your patch should depend upon the target system (for performance
or precision reasons).
But I am not a numerician, so take all this mail with a grain of salt.
Cheers.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
More information about the Gcc-patches
mailing list