From ripley at stats.ox.ac.uk  Fri Dec  6 17:06:02 2013
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 06 Dec 2013 16:06:02 +0000
Subject: [Rd] Matrix memory layout R vs. C
In-Reply-To: <20131206155139.GA2804@saci>
References: <52A1CF46.7070408@googlemail.com>
	<52A1E17B.8090200@gmail.com>	<CABtg=KnYfx_VYvGdmximPm7GSSj-eY-vzdcYKpPPtHDcd1ppXg@mail.gmail.com>	<52A1F06D.3080701@stats.ox.ac.uk>
	<20131206155139.GA2804@saci>
Message-ID: <52A1F5EA.9000909@stats.ox.ac.uk>

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



[Rd] Matrix memory layout R vs. C
Prof Brian Ripley