Re: [Rd] Linking to native routines in other packages

2013-12-06 Thread Romain Francois
Le 06/12/2013 22:29, Hadley Wickham a écrit : But now if I do Depends: Rcpp or Imports: Rcpp for the sole purpose of this LinkingTo mechanism, I'm getting * checking dependencies in R code ... NOTE Namespace in Imports field not imported from: ‘Rcpp’ All declared Imports should be used. See t

Re: [Rd] Linking to native routines in other packages

2013-12-06 Thread Hadley Wickham
> But now if I do Depends: Rcpp or Imports: Rcpp for the sole purpose of this > LinkingTo mechanism, I'm getting > > * checking dependencies in R code ... NOTE > Namespace in Imports field not imported from: ‘Rcpp’ > All declared Imports should be used. > See the information on DESCRIPTION files

[Rd] Depending/Importing data only packages

2013-12-06 Thread Hadley Wickham
Hi all, What should you do when you rely on a data only package. If you just "Depend" on it, you get the following from R CMD check: Package in Depends field not imported from: 'hflights' These packages needs to imported from for the case when this namespace is loaded but not attached. But t

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Prof Brian Ripley
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 s

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Luis Carvalho
> 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? #define INDEX(rows,i,j) ((i) + (rows)*((R_xlen_t)(j))) Cheers, Luis -- Computers are useless. They can only give you answers.

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Prof Brian Ripley
On 06/12/2013 15:49, Gábor Csárdi wrote: On Fri, Dec 6, 2013 at 10:42 AM, Prof Brian Ripley wrote: On 06/12/2013 14:42, Gábor Csárdi wrote: On Fri, Dec 6, 2013 at 9:38 AM, Duncan Murdoch wrote: On 06/12/2013 8:21 AM, Larissa Hauer wrote: [...] I would not assume that a 2D matrix in C

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Luis Carvalho
Hi Larissa, > I'm trying to pass a matrix from R to C, where some computation is > done for performance reasons, and back to R for evaluation. But I've > run into the problem that R and C seem to have different ways of > representing the matrix in main memory. The C representation of a 2D > matrix

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Gábor Csárdi
On Fri, Dec 6, 2013 at 10:42 AM, Prof Brian Ripley wrote: > On 06/12/2013 14:42, Gábor Csárdi wrote: >> >> On Fri, Dec 6, 2013 at 9:38 AM, Duncan Murdoch >> wrote: >>> >>> On 06/12/2013 8:21 AM, Larissa Hauer wrote: >> >> [...] >>> >>> >>> >>> I would not assume that a 2D matrix in C doesn't have

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Prof Brian Ripley
On 06/12/2013 14:42, Gábor Csárdi wrote: On Fri, Dec 6, 2013 at 9:38 AM, Duncan Murdoch 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

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Gábor Csárdi
On Fri, Dec 6, 2013 at 9:38 AM, Duncan Murdoch 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, > > #de

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Duncan Murdoch
On 06/12/2013 8:21 AM, Larissa Hauer wrote: Hi everybody, I'm trying to pass a matrix from R to C, where some computation is done for performance reasons, and back to R for evaluation. But I've run into the problem that R and C seem to have different ways of representing the matrix in main memor

Re: [Rd] Matrix memory layout R vs. C

2013-12-06 Thread Lorenz, David
Larissa, So is the problem "in the matrix reference is mat[col][row] whereas in R it is mar[row, col]?" The solution is just recognizing the difference in references. Dave On Fri, Dec 6, 2013 at 7:21 AM, Larissa Hauer wrote: > > Hi everybody, > > I'm trying to pass a matrix from R to C, wher

[Rd] Matrix memory layout R vs. C

2013-12-06 Thread Larissa Hauer
Hi everybody, I'm trying to pass a matrix from R to C, where some computation is done for performance reasons, and back to R for evaluation. But I've run into the problem that R and C seem to have different ways of representing the matrix in main memory. The C representation of a 2D matrix in