On Wed, 10 Jul 2019, Sven Schreiber wrote:
Am 10.07.2019 um 14:10 schrieb Allin Cottrell:
> On Mon, 8 Jul 2019, Sven Schreiber wrote:
>
>> BTW, I checked the expression "zeros(100,1) * NA" which still has all
>> zeros. Now I remember some dispute about the desired result for 0*NA,
>> but in any case the variant "zeros(100,1) .* NA" gives all
'nan', so I'm
>> sure one of the two must be a bug.
> Yep, that's inconsistent. For the present I've made 0 * NA equal 0 in
> both contexts, which is "traditional" gretl behavior. But we may want
> to revise this, given that our NA is now NaN. Thoughts, anyone?
Not sure why that internal change would affect the way users want to or
should interact with gretl?
This is kind of a long story but I'll try to be brief. Executive
summary: it's actually not just an internal thing.
At one time we attempted to distinguish between NA (= missing value,
a stand-in for an unknown value that in principle could have been
observed, but was not observed, coded as the maximum
double-precision floating point value) and NaN (not-a-number, for
instance the result of an invalid arithmetical operation such as
taking the log of a negative number).
If one could maintain this distinction consistently, then it would
be reasonable to maintain that NA * 0 = 0, even though NaN * 0 ought
to be NaN (as it is, per IEEE rules).
But the distinction is very difficult to maintain and we never
actually succeeded. (For example, in the series context, log(-1)
gave a result of NA.) Moreover (a) two-way traffic between series
and matrices has become a integral part of the modern hansl idiom
and (b) we have farmed out much of our matrix computation to
openblas, which has no notion of our "NA" definition and would
happily treat it as a valid numerical value. We were therefore
obliged to police the series/matrix interface at quite heavy cost:
NAs in series had to be converted into NaNs in matrices (on pain of
producing numerical nonsense), and (debatably) vice versa.
So in 2018 we cut through this mess: we redefined gretl's "NA" as
NaN. No more policing required; NaNs propagate through calculation
as per IEEE rules (any arithmetical operation with NaN as an operand
produces NaN as result). Except... we kept the NA*0 = 0 rules for
series, and (semi-consistently, as you noted) for multiplication of
matrices by scalars.
So my question is: should we now accept that we have no good reason
for blocking the application of the IEEE rules for NaNs?
Allin