Skip to content
Prev 22942 / 63424 Next

array indexes in C

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