[Rcpp-devel] List of matrices mimicking 3d array?

Dirk Eddelbuettel edd at debian.org
Thu Jan 5 02:32:50 CET 2012


On 4 January 2012 at 19:11, Hadley Wickham wrote:
| > Our arrays in Rcpp can be multidimensional just like they can in R. Here is a
| > line from one of the unit tests:
| >
| >   return IntegerVector( Dimension( 2, 3, 4) ) ;
| >
| > which sets the dim attribute of a given vector to c(2,3,4) just like you
| > would in R.  That should all work too but may have seen less exposure than
| > other parts of our code.
| 
| Am I reading the Vector documentation correctly
| (http://dirk.eddelbuettel.com/code/rcpp/html/classVector.html) in
| interpreting that while you can create vectors with dimensions, that
| there is no syntactic sugar for  multidimensional indexing?  I'm not

I think that is correct. We do have Range objects, and that is about it.
This is not yet a level comparable to R.

The unitTests/ directories, as always, has the largest collections of working
idioms to copy from.  runit.Vector.r is probably what you want to look at.

| quite sure how to interpret method signatures like operator() (const
| size_t &i, const size_t &j) const. I can guess that means you can
| index by two integers - but I don't know what those two integers mean.

Well if I had to guess I'd say row and column ...

Dirk

| 
| Hadley
| 
| -- 
| Assistant Professor / Dobelman Family Junior Chair
| Department of Statistics / Rice University
| http://had.co.nz/

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list