On Mon, 4 Mar 2013, Pindar wrote:
I encountered that a matrix that 'is null' cannot be filtered
by 'isnull':
(where the matrix in question exists but has zero rows and
columns).
As the help for isnull() states, this function "Returns 0 if
name is the identifier for a currently defined object, be it a
scalar, a series, a matrix, list, string or bundle; otherwise
returns 1." So it correctly returns 1 for an empty (0 x 0)
matrix.
However, there is admittedly something confusing here in that
if you do
matrix m = zeros(0,0)
print m
then gretl comes back with "m: matrix is null (0 x 0)". I've
now changed that message in CVS to say "matrix is empty". (One
could defend the distinction between a null matrix and a null
(non-existent) object, but I won't go there.)
You also state that the ok() function is not working for
matrices, as in (trimming a little),
matrix test = {1,0,3;1,1,100}
matrix seek = selifr(test,test[,1].=1)
matrix seek = selifr(seek,seek[,2].=2)
# and also not working
eval ok(test)
eval ok(seek)
Well, ok(test) is fine: it produces a 2 x 3 matrix of 1s, as
per the help -- since "test" contains no non-finite elements.
However the result from ok(seek) is arguably wrong: this gives
a "Data error" (the matrix in question being empty), while
according to the help text it probably should return an empty
matrix. This would be consistent with the recent "upgrading"
of empty matrices in general (that is, we try to treat them
simply as special cases rather than as invalid objects, to the
extent possible and reasonable).
Allin Cottrell