Re: [eigen] About Complex numbers Todo

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


Hi Bastien. If I get things right then there might be two issues with this: first it is only for C++0x, so older C++ versions would not be supported. Furthermore, and if I remember correctly, complex numbers are stored in memory as an array, even though it might be hidden by a struct or class.

Carlos


On Fri, Aug 20, 2010 at 9:31 AM, Bastien ROUCARIES <roucaries.bastien@xxxxxxxxx> wrote:
Hi,

It seems that the rationale of implementing a new complex class could disappear.

According to the draft of the next standard C++0x (at this proposition
is well acknowledged since 2002 see below):

Section 26.4 p 886
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3092.pdf)
say that complex is always an array (I have quote at the end of the
mail), the wording was especially choosen in order to be Fortran
compatible and C99 compatible (see
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-active.html#387 and the
last remark about
"All existing implementations already have the layout proposed here").

Thus I think we could remove this todos item, if you want to be safe
you could publish a test case and use crash the compilation. I could
write a cmake test case if you want

Bastien

The standard:
2 The effect of instantiating the template complex for any type other
than float, double, or long double
is unspecified. The specializations complex<float>, complex<double>,
and complex<long double> are
literal types (3.9).
3 If the result of a function is not mathematically defined or not in
the range of representable values for its
type, the behavior is undefined.
4 If z is an lvalue _expression_ of type cv std::complex<T> then:
— the _expression_ reinterpret_cast<cv T(&)[2]>(z) shall be well-formed,
— reinterpret_cast<cv T(&)[2]>(z)[0] shall designate the real part of z, and
— reinterpret_cast<cv T(&)[2]>(z)[1] shall designate the imaginary part of z.
Moreover, if a is an _expression_ of type cv std::complex<T>* and the
_expression_ a[i] is well-defined for an
integer _expression_ i, then:
— reinterpret_cast<cv T*>(a)[2*i] shall designate the real part of a[i], and
— reinterpret_cast<cv T*>(a)[2*i + 1] shall designate the imaginary
part of a[i].





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