This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [v3] complex functions with expression template reals
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 24 Feb 2014 10:10:02 +0100
- Subject: Re: [v3] complex functions with expression template reals
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1402231050480 dot 29647 at stedding dot saclay dot inria dot fr> <530A0962 dot 7020509 at oracle dot com> <alpine dot DEB dot 2 dot 10 dot 1402231600460 dot 3595 at laptop-mg dot saclay dot inria dot fr>
Hi,
On 02/23/2014 04:11 PM, Marc Glisse wrote:
On Sun, 23 Feb 2014, Paolo Carlini wrote:
On 02/23/2014 11:32 AM, Marc Glisse wrote:
Hello,
looking at this question:
http://stackoverflow.com/q/21737186/1918193
I was surprised to see that libstdc++'s std::complex basically just
works with user-defined types, even weird expression template ones,
although that's not a supported use afaik.
The only functions that fail seem to be exp and pow, both because
they call polar with two arguments that have different (expression)
types.
I am not proposing to make this a supported use, but the cost of
this small patch seems very low, and if it makes a couple users
happy...
Regtested with no problem on x86_64-linux-gnu, ok for stage 1?
I would even be in favor of applying it now. Can we figure out simple
(ie, not relying on boost...) testcases too?
I didn't try std::complex<std::valarray<X>>, maybe...
Otherwise, you need a type T with all the (real) math functions
defined, and where every operation returns a different type
(implicitly convertible to T). And then you want to call all the
complex functions.
That seems doable, but way bigger than I'm willing to go for this
feature. If you want to take over, be my guest ;-)
Another option would be just using boost/multiprecision/mpfr.hpp when
available. In general, I think it makes sense to have a minimum of
infrastructure enabling tests checking interoperability with boost. If
only we had a check_v3_target_header { args } it would be most of it,
but it doesn't seem we do?!? Anyway I guess we can take care of that
post 4.9.0 and commit the straightforward code tweak now. Jon?
Paolo.
PS: Resending message, yesterday had issues with html