Re: manipulating structures [message #53344 is a reply to message #53343] |
Mon, 09 April 2007 08:02   |
Kenneth Bowman
Messages: 86 Registered: November 2006
|
Member |
|
|
In article <Pine.LNX.4.64.0704082118360.6079@bifur.rmki.kfki.hu>,
FOLDY Lajos <foldy@rmki.kfki.hu> wrote:
> On Sun, 8 Apr 2007, Kenneth P. Bowman wrote:
>
>> The rules for IEEE arithmetic say that the result of any operation
>> involving a NaN is a NaN. That is not true in the case of TOTAL. If
>> you sum an array that is all NaNs, the result is zero.
>
> You are summing an empty array, if the /NaN keyword (= discard NaNs) was
> set. So, what is the sum of an empty array: 0 or Nan? :-)
>
> regards,
> lajos
How can the sum of no numbers be a number?
I know we went through this same philosophical argument before, but in the end
the /NAN keyword is there as a programming convenience. Zero is
a valid answer when there are good data in the array. It should not be a
valid answer when there are no good data in the array.
As I said, it renders the /NAN keyword useless to me. I don't want to
get a valid number back when there are no valid input data.
Instead of
tot = TOTAL(x, /NAN)
I must do
i = WHERE(FINITE(x), COUNT = count)
IF (COUNT EQ 0) THEN tot = !VALUES.F_NAN $
ELSE tot = TOTAL(x[i])
Ken
|
|
|