Re: [eigen] Eigen::Complex -- does it have a reason to exist?

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


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
>
>
>
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/