Fri, 28 Jan 2011 11:49:34 +0100, Mark Bakker wrote: [clip] > Yet when the imaginary part is zero (and it really is a real number), > the imaginary part is nan: > > In [19]: inf * (1+0j) > Out[19]: (inf+nan*j) > > That is not correct. It should really given (inf+0*j). (I know where it > comes from, inf*0 is not defined, but in this case it is, as 1+0j is > really a real number and inf is by definition real as well). > > If there is consensus I can file a ticket.
Both behaviors are accepted by the C99 standard: all combinations where one entry is `+-inf` are equivalent to the complex infinity. gcc itself returns `inf-1j*nan`. gfortran returns `inf+1j*nan`. A good rationale for the present behavior is that there is no way to know that 1+0j is supposed to be real; it could as well be a number too small to represent (eg. result from an underflow in the imaginary part), in which case `nan` is indeed the correct result. -- Pauli Virtanen _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion