This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, libstdc++, complex] complex multiplication algorithm improved
On Wed, Sep 15, 2010 at 3:39 PM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Wed, Sep 15, 2010 at 3:10 AM, 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
>> - bd ] -- 3 multiplies
>>
>
> Hi,
> I would like to see more data to support the change.
> (I apologize if the mere mention of "numerical recipe"
> does not move me.)
> I am in no way claiming that the current implementation
> in all conceivable aspects. ?However, I think we need to
> have "good" reasons to move the implementation one
> way or the other. ? I also think we should be using
> builtin __complex__ T for standard integer type T.
As multiplies are generally as fast as adds nowadays the
new variant would be slower. Also pairing for fmas is
easier for the original variant (that is actually something
one might consider changing - manually use fma
intrinsics when the CPU supports that).
Richard.