[Rd] Matrix memory layout R vs. C

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 6 17:06:02 CET 2013


On 06/12/2013 15:51, Luis Carvalho wrote:
>> 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.
>
> Shouldn't 'rows' be also a parameter?

This is a macro, not a function.  'rows' (I would have use nr or nrows) 
is going to be the same at all invocations.

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


-- 
Brian D. Ripley,                  ripley at 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



More information about the R-devel mailing list