On Monday 02 October 2006 19:39, Gabriel Dos Reis wrote: > "Joseph S. Myers" <[EMAIL PROTECTED]> writes: > | On Mon, 2 Oct 2006, Jan van Dijk wrote: > | > On Monday 02 October 2006 12:57, Joseph S. Myers wrote: > | > > On Mon, 2 Oct 2006, Jan van Dijk wrote: [...] > | > Triggered by 1*(Inf,0) = (Inf,NaN), I looked inside the compiler for > | > the first > | > | (Inf,NaN) is a valid complex infinity just as (Inf,0) is; see G.3. > > I think his concern is about the evaluation of 1 * (Inf, 0).
1*(Inf,0) gives (Inf,NaN) with the recent gcc version (with -O0 or arguments unknown at compile time). I now understand that this is correct: according to the standard a complex number is Inf if one of the components is Inf (even if the other is NaN). It is also *unfortunate*: std::abs(1*(Inf,0)) -> nan, where Inf would be expected by the user; 1/std::abs(1*(Inf,0)) ->nan, where 0 would be expected. The result is that (for example) in the evaluation of small-argument expansions of special functions special-case-handling is required to avoid the generation of NaNs for 'too-low' |z|, where Inf or 0 is expected. Note that the analogous expressions for (IEE 754) floating point numbers work as expected when overflow/underflow happens. The bottom line is that the concept of infinity/nan is of limited practical value for complex numbers. Doing multiplications in terms of polar representations would solve all such problems for complex numbers, BTW. Anyway, this behaviour is standard-conformant, if we assume that C++ is supposed to mimmick C in the behaviour of complex numbers (where is that written, BTW?) People doing scientific computing in C(++) shall have to live with this, I am afraid. More serious is the fact that the compiler translates 1*(Inf,Inf) into (NaN,NaN). This is plain wrong, but, as Joseph mentioned, the solution requires the implementation of mixed-mode MULT_EXPRESSIONS, since apparently 1*(Inf,Inf) == (Inf,Inf) != (1,0)*(Inf,Inf)==(NaN,NaN). Is the latter project suitable for a motivated newby? I am willing to spend some time and effort into this issue, but will definitely need guidance from time to time. With kind regards, Jan van Dijk. -- If I haven't seen further, it is by standing in the footprints of giants Dr. Jan van Dijk Eindhoven University of Technology Department of Applied Physics Group Elementary Processes in Gas Discharges Room Na-2.09 P.O. Box 513 5600 MB Eindhoven The Netherlands tel. +31 40 247 57 65