Dear list, On a follow up from my previous email, I am now trying to allocate vectors of length larger than 32-bit in C.>From the R internals documentation, I read that:"The sxpinfo header is defined as a 32-bit C structure..." and "A SEXPREC is a C structure containing the 32-bit header..." The question is: does the INTSXP allow vectors larger than 32-bit? A test example: //### int *p_temp; SEXP root = PROTECT(allocVector(VECSXP, 5)); long long int verylargeinteger; // something to compute verylargeinteger, > 32-bit SEXP temp = SET_VECTOR_ELT(root, 0, allocVector(INTSXP, verylargeinteger)); p_temp = INTEGER(temp); //### "temp" should be a vector of length > 32-bit, and "p_temp" should be the pointer to that vector. If declaring: long long int *p_temp; (but the compiler throws a warning with an incompatible pointer type, because pointers should be integers of course). I've looked at all SEXPTYPEs in the R internals, and the only one specific to integer vectors is INTSXP. Can this be used for vectors of length larger than 32-bit? Thank you again, in advance, Adrian -- Adrian Dusa University of Bucharest Romanian Social Data Archive 1, Schitu Magureanu Bd. 050025 Bucharest sector 5 Romania Tel.:+40 21 3126618 \ +40 21 3120210 / int.101 Fax: +40 21 3158391 [[alternative HTML version deleted]]
On 16/05/2014, 4:16 AM, Adrian Du?a wrote:> Dear list, > > On a follow up from my previous email, I am now trying to allocate vectors > of length larger than 32-bit in C. > >>From the R internals documentation, I read that: > "The sxpinfo header is defined as a 32-bit C structure..." > and > "A SEXPREC is a C structure containing the 32-bit header..." > > The question is: does the INTSXP allow vectors larger than 32-bit? > > > A test example: > > //### > int *p_temp; > > SEXP root = PROTECT(allocVector(VECSXP, 5)); > > long long int verylargeinteger; > // something to compute verylargeinteger, > 32-bit > > SEXP temp = SET_VECTOR_ELT(root, 0, allocVector(INTSXP, verylargeinteger)); > p_temp = INTEGER(temp); > //### > > "temp" should be a vector of length > 32-bit, and "p_temp" should be the > pointer to that vector. > > If declaring: > long long int *p_temp; > (but the compiler throws a warning with an incompatible pointer type, > because pointers should be integers of course). > > I've looked at all SEXPTYPEs in the R internals, and the only one specific > to integer vectors is INTSXP. Can this be used for vectors of length larger > than 32-bit?Yes, see the section on "Long Vectors" in chapter 12. Duncan Murdoch> > Thank you again, in advance, > Adrian > >
Apparently Analagous Threads
- Why does typeof() modify an object's "named" field?
- Problem with S4 slots in C code (PR#4073)
- Returning vectors of two different data types back to R environment (from C).
- External pointers and changing SEXPTYPE
- using C code to create data frame but always return as list