Re: [Rcpp-devel] accessing list elements without using names

2012-02-10 Thread Sameer Soi
Thank you, this makes more sense now. I do like the succinct, "show-off" style; it seems to convey the meaning better. On Fri, Feb 10, 2012 at 4:47 PM, Douglas Bates wrote: > On Fri, Feb 10, 2012 at 3:30 PM, Dirk Eddelbuettel wrote: > > > > On 10 February 2012 at 15:05, Douglas Bates wrote: > >

Re: [Rcpp-devel] accessing list elements without using names

2012-02-10 Thread Douglas Bates
On Fri, Feb 10, 2012 at 3:30 PM, Dirk Eddelbuettel wrote: > > On 10 February 2012 at 15:05, Douglas Bates wrote: > | Or if you want to show off you could collapse it to > | > | > src <- " > | +   NumericMatrix tmpMatrix(as(List(L)[0])); > | +   return wrap(tmpMatrix.ncol()); > | + " > | > f <- cxx

Re: [Rcpp-devel] accessing list elements without using names

2012-02-10 Thread Dirk Eddelbuettel
On 10 February 2012 at 15:05, Douglas Bates wrote: | Or if you want to show off you could collapse it to | | > src <- " | + NumericMatrix tmpMatrix(as(List(L)[0])); | + return wrap(tmpMatrix.ncol()); | + " | > f <- cxxfunction(signature(L="list"), src, plugin = "Rcpp" ) | > f(list(matrix(1:9,

Re: [Rcpp-devel] accessing list elements without using names

2012-02-10 Thread Douglas Bates
Or if you want to show off you could collapse it to > src <- " + NumericMatrix tmpMatrix(as(List(L)[0])); + return wrap(tmpMatrix.ncol()); + " > f <- cxxfunction(signature(L="list"), src, plugin = "Rcpp" ) > f(list(matrix(1:9,3,3))) [1] 3 On Fri, Feb 10, 2012 at 3:01 PM, Douglas Bates wrote:

Re: [Rcpp-devel] accessing list elements without using names

2012-02-10 Thread Douglas Bates
Another approach is to force the evaluation of the list element with as > src <- " + List inputList(L) ; + NumericMatrix tmpMatrix(as(inputList[0])) ; + + return wrap(tmpMatrix.ncol()); + " > f <- cxxfunction(signature(L="list"), src, plugin = "Rcpp" ) > f(list(matrix(1:9,3,3))) [1] 3 In an

Re: [Rcpp-devel] accessing list elements without using names

2012-02-10 Thread Sameer Soi
I am not exactly sure why that works, but it does! Why doesn't it directly see the NumericMatrix(SEXP)? Thank you, Dirk! On Fri, Feb 10, 2012 at 3:10 PM, Dirk Eddelbuettel wrote: > > On 10 February 2012 at 14:49, Sameer Soi wrote: > | Hello Rcpp'ers, > | > | I want to access a List of matrices

Re: [Rcpp-devel] accessing list elements without using names

2012-02-10 Thread Dirk Eddelbuettel
On 10 February 2012 at 14:49, Sameer Soi wrote: | Hello Rcpp'ers, | | I want to access a List of matrices in an Rcpp/C++ function that will passed to | me via R... | | src <- " |   using namespace Rcpp ; |   List inputList(L) ; |   NumericMatrix tmpMatrix ; | |   tmpMatrix = NumericMatrix(inpu