On Fri, 21 Oct 2016, oleg_komashko@ukr.net wrote:
> R have a native class of objects of class 'matrix':
> they can only be squared
Only rectangular, do you mean?
The matrix Sven constructed (at first) was nominally rectangular
(4 x 1), but element [4,1] (represented by "?" when printed) was
not a scalar value.
> They are atomic vectors with 'dimension' attribute (2 coordinates)
>
> Since R is an object-oriented language,
> a user can specify as many new classes of data as she wants
>
> Matrix package has many additional classes of "matrices"
> It's unreal to have gretl native interface to much
> classes defined in packages (about 10^4 packages in cran only)
>
> It's more realistic to coerce some "matrix"
> to a native (i. e. defined in r-base) class of objects
> and only then export them
Our current test, applied before attempting to build a gretl matrix
from the SEXP (call it "res") we get from an R function is,
1) does Rf_isMatrix(res) return non-zero?
2) If so, does Rf_isReal(res) return non-zero?
where the second clause is newly added in response to Sven's
example. Only if both parts of the test pass do we try to get the
data out of the R object, using
gretl_matrix_set(m, i, j, REAL(res)[<index>]);
Do you think the above is adequate? Or if not, can you suggest a
better test?
The main goal here is not that we should be able to handle any old
object returned by an R function, but that we don't provoke an error
in libR that drags gretl down!
Allin
_______________________________________________
Gretl-devel mailing list
Gretl-devel@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel