Re: [eigen] Eigen::Complex -- does it have a reason to exist? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Eigen::Complex -- does it have a reason to exist?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 6 Jan 2010 23:13:48 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=TKH40Adz+ntPUiWWXUCjast8oMsdCwUKwiXEnSjGuTs=; b=PLleCfs9zYcpV88mYMeLtMyg+0qtQFTZPoQxdqTWom/GRRRuGZwNnP8R9apuJdPe6u j8GDwIkriiHG/otFAI2J+9ejsqMa5yWELROhwPof5UFu+7Pf56nqn7pvQQgTuCH/QcL9 Ekb+9RndwWt4z3ePGx/3rI5QPsgmhzww2YlX4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=o/Ms1YAdavzzhsxV/T/5AwheEAG0vJqSRBeYYrrjc+Oqw1KPBS+xtzM3a2RyKhuu0g Ai6IZ0NYoWSWeOz9g4iKaiywUzx9y3iVh1RVwY4+3EzR0p4eJMHE8PxTOZwYTev5Jem0 tm0aT9mA7uimkzkgAn29UUzwIU0vg4i3WLQl0=
There was another reason, which from my point of view was the main reason:
3. Vectorizing complex operations.
But you got me thinking and I just realized that we were wrong in
believing that we needed our own Complex class for that.
The much simpler approach is as follows: all we need to do is to add
specializations of PacketMath.h for std::complex<float> and
std::complex<double>. In this way, Eigen already feeds us with 16-byte
packets containing 1 or 2 complex numbers (for double or float
respectively) at 16-byte-aligned locations, so in the functions
ei_padd, ei_pmul etc... we can use SIMD intrinsics.
That escaped me totally, perhaps due to the point 1. that you mention.
There is still a problem: so far, we use the criterion "a packet
consists of a single scalar", formulated
ei_packet_traits<Scalar>::Size==1, to determine if a scalar type
doesn't have vectorization. This test breaks on complex<double> as its
sizeof is 16, so we need a more future-proof test.
Thanks a lot for this observation. I am sorry for having suggested you
to work on something we may end up not using after all, and I
appreciate a lot that you brought this issue up!
Benoit
2010/1/6 Mark Borgerding <mark@xxxxxxxxxxxxxx>:
> If I recall correctly, the reasons behind the creation of Eigen::Complex
> were :
>
> fear of optimizing complex math without a hard guarantee of std::complex
> structure layout
> intellectual curiosity to see if I could make operator & return a class that
> was convertible to either type of pointer.
>
> I think we can verify #1 at compile time.
> and #2 is not a reason to continue.
>
>
> Are there other reasons for Eigen to have its own Complex class? If not, I
> suggest we yank it.
>
>
> -- Mark
>
>
>
>
>