On 06/12/2013 14:42, Gábor Csárdi wrote:
On Fri, Dec 6, 2013 at 9:38 AM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote:
On 06/12/2013 8:21 AM, Larissa Hauer wrote:
[...]


I would not assume that a 2D matrix in C doesn't have gaps in it between the
rows.  Let C treat it as a vector, and write a little macro that does the
indexing.  For example,

#define INDEX(i,j) (i) + rows*(j)

I would make this

#define INDEX(i,j) ((i) + rows*(j))

just to be on the safe side.

And to be safer on a 64-bit platform

#define INDEX(i,j) ((i) + rows*(R_xlen_t)(j))

since rows*j might overflow there.

--
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, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to