Dear all,
I was playing around with some C-code that I dynamically linked to R
and noticed the following inconsistency:
dat <- matrix(1,3,3)
is.double(dat)
dat <- matrix(1:9,3,3)
is.double(dat)
[1] TRUE
How did I find out? I passed `dat' to a double * in the C-code and
printed out the matrix from C. But in the .C() call I just passed
down `dat' and forgot to coerce to double via `as.double(dat)'. Of
course the print out from the C routine was garbage, but since I used
dat <- matrix(1,3,3)
first, I was confused. Note that R says that `dat' is.double! But it
seems to pass dat to C as an integer matrix nevertheless! Using the
second matrix it became clear to me why I saw garbage being printed
out from the C-routine. My question is now why does the first
`is.double(dat)' returns `TRUE'?