[Rd] array indexes in C

Tamas K Papp tpapp at Princeton.EDU
Sat Nov 18 18:54:39 CET 2006


I am passing (numeric) arrays to a C function, called with .C.  To the
best of my knowledge, I can do this in R by passing it as a vector
(with as.vector) to the .C call.

However, it would be useful to access the array as an array inside C,
ie not have to calculate how array indices (i,j,k) map to the vector
elements.  What is the right way to do this?  Are there convenience
functions to do the index calculations (knowing the dimensions) that I
could call?

In the C99 standard, I have seen something about flexible arrays, I
don't know if that would help here.

Thanks,

Tamas



More information about the R-devel mailing list