[Numpy-discussion] Apropos ticked #913
Wed Mar 4 23:53:55 CST 2009
Robert Kern wrote:
> On Wed, Mar 4, 2009 at 23:32, Charles R Harris
> <email@example.com> wrote:
>> One thing that still bothers me a bit is the return value of fmax/fmin when
>> comparing two complex nan values. A complex number is a nan whenever the
>> real or imaginary part is nan, and currently the functions return such a
>> number but originally they returned a complex number with both parts set to
>> nan. The current implemetation was a compromise that kept the code simple
>> while never explicitly using a nan value, i.e., the nan came from one of the
>> inputs. I avoided the explicit use of a nan value because the NAN macro was
>> possibly unreliable at the time. I'm open to thoughts on what the behavior
>> should be.
> Do we have examples from other implementations?
For R, I believe there is no Nan complex number: 1+NaN * 1i, NaN, NaN+1i
are all printed the same as NaN, and according to the doc on complex
Complex vectors can be created with 'complex'. The vector can be
specified either by giving its length, its real and imaginary
parts, or modulus and argument. (Giving just the length generates
a vector of complex zeroes.)
'as.complex' attempts to coerce its argument to be of complex
type: like 'as.vector' it strips attributes including names. All
forms of 'NA' and 'NaN' are coerced to a complex 'NA', for which
both the real and imaginary parts are 'NA'.
I would guess this is a consequence of R biased toward statistics, with
Na being mostly for missing data ?
More information about the Numpy-discussion