Re: [Rd] SEXPTYPEs
On Fri, May 16, 2014 at 2:15 PM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On 16/05/2014 11:06, Duncan Murdoch wrote: [...] 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. ('Yes on a 64-bit platform.') The type for a vector length is R_xlen_t, e.g. allocVector is declared as SEXP Rf_allocVector(SEXPTYPE, R_xlen_t); That is never 'long long int' Oh yes, of course. I now have all the information I need. Thanks and best wishes, 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]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] SEXPTYPEs
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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] SEXPTYPEs
On 16/05/2014 11:06, Duncan Murdoch wrote: 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. ('Yes on a 64-bit platform.') The type for a vector length is R_xlen_t, e.g. allocVector is declared as SEXP Rf_allocVector(SEXPTYPE, R_xlen_t); That is never 'long long int' Duncan Murdoch Thank you again, in advance, Adrian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel