|Re: [eigen] About Complex numbers Todo|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] About Complex numbers Todo
- From: Carlos Becker <carlosbecker@xxxxxxxxx>
- Date: Fri, 20 Aug 2010 09:41:31 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=zVMi4ACxuK3zQmEQRpASwFR3hey6Q0Bk1yVPUB9vIIg=; b=qd6YQbXhSWYLff0vE89oQYuFkpyKoGlKt7jS01PUk388SRZFufAHGapLFcMHE3+six JqZm3dQIhwZWWd5kAgWBnha2TwTIj/Kmi0Yc2IJBxTF3jrrh9hXaFtCc+mA6WmMugNNi vqpWVwe6NCGRI42Ak85ACRKaVBKHlp9jEQbf8=
- 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; b=czERJ+bwyk/E/qAZxIjvuyEwwpyr5bk65pfaKnUEELuhIrmqTu9vSPhuvGP2p5xJRq 7zEy+yGpXwJnhqEEZEER7IaYaEM05bhefLE4MU+MvivOpdZ4cP4XflIIqA6/6uHq3/Sp B231XhmhZTVnSOKXpmDHrIeumRjDct2aegmsM=
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.
On Fri, Aug 20, 2010 at 9:31 AM, Bastien ROUCARIES <roucaries.bastien@xxxxxxxxx>
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
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
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(&)>(z) shall be well-formed,
— reinterpret_cast<cv T(&)>(z) shall designate the real part of z, and
— reinterpret_cast<cv T(&)>(z) 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].