Write Barrier: was: [Rd] function-like macros undefined

From: Vadim Ogranovich <vograno_at_evafunds.com>
Date: Wed 16 Mar 2005 - 18:34:56 GMT


Hi,

Thank you to Duncan Murdoch for pointing to http://www.stat.uiowa.edu/~luke/R/barrier.html. I have a couple of questions in this regard:

int * xIPtr = INTEGER(x);
int i;

for (i=0; i<LENGTH(x); ++i)

     SET_VECTOR_ELT(x, i, xIPtr[i]+1);

is the recommended way of doing it. However it seems that only the very first call to SET_VECTOR_ELT, i.e. the one that corresponds to i=0, is strictly necessary. For example, and this is my question, the following should be perfectly safe:

SET_VECTOR_ELT(x, 0, xIPtr[0]);

for (i=0; i<LENGTH(x); ++i)

     ++xIPtr[i];

Admittedly this looks a bit odd and breaks if LENGTH(x) is zero, but it illustrates the point.

Thanks,
Vadim



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Mar 17 05:37:46 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:02 GMT