help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difference between NaN and NA?


From: John W. Eaton
Subject: Re: Difference between NaN and NA?
Date: Thu, 8 Apr 2010 07:45:58 -0400

On  8-Apr-2010, Jaroslav Hajek wrote:

| But why make it built-in? I think that even with the current limited
| OOP capabilities, it is possible to build a class that maintains the
| NA's as a separate mask, making even the elementary operations
| NA-aware (i.e. so that x + NA is NA and never NaN). Overloading the
| statistics functions like mean etc. would also be quite simple.

But don't you then have to overload pretty much every function to
ensure that NA is handled correctly in all instances?  I guess it's
just a SMOP.

| Of course, as a performance zealot, I would oppose making Octave's
| built-in operations NA-aware by inserting special checks, because in
| general I don't like to pay for something I never use. Neither do R
| users, I suppose, so even in R, skipping the NA's is, in general,
| optional:
| 
| > mean (c(1, 1, NA))
| [1] NA
| > mean (c(1, 1, NA), na.rm=1)
| [1] 1
| 
| Yes, we could do something similar in Octave, but isn't an extra class
| taking care of this more elegant?

Yes.

| It seems quite inconvenient to have to pass the flag everywhere.

Definitely.  OTOH, I don't think you want a global variable for this
either.  So yes, having the behavior depend on a special data type
seems better, but overloading every function in sight does not seem
all that great either, at least from the point of view of actually
implementing such a feature.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]