From csardi.gabor at gmail.com  Fri Dec  6 15:42:37 2013
From: csardi.gabor at gmail.com (=?ISO-8859-1?B?R+Fib3IgQ3PhcmRp?=)
Date: Fri, 6 Dec 2013 09:42:37 -0500
Subject: [Rd] Matrix memory layout R vs. C
In-Reply-To: <52A1E17B.8090200@gmail.com>
References: <52A1CF46.7070408@googlemail.com>
	<52A1E17B.8090200@gmail.com>
Message-ID: <CABtg=KnYfx_VYvGdmximPm7GSSj-eY-vzdcYKpPPtHDcd1ppXg@mail.gmail.com>

On Fri, Dec 6, 2013 at 9:38 AM, Duncan Murdoch <murdoch.duncan at 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.

Gabor

[...]



[Rd] Matrix memory layout R vs. C
=?ISO-8859-1?B?R+Fib3IgQ3PhcmRp?=