In the end I wrote an obvious miniature sugary hack to convert 3d array indices into numeric vector indices<div><br><div><div>int threeDIndex(int j, int k, int l, int J, int K, int L) { </div><div>    return j*K*L + k*L + l;</div>
<div>}</div><div><br></div><div>so that where one wants to call A[j,k,l], instead one calls A[ threeDIndex(j,k,l,J,K,L) ], where dim(A) = (J,K,L). Presumably a programmer with more experience than me could write a cpp method to do this for NumericVectors with dimension attribute?</div>
<div><br></div><div>Edward</div><br>On Wednesday, January 4, 2012, Dirk Eddelbuettel  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
On 4 January 2012 at 19:11, Hadley Wickham wrote:<br>
| &gt; Our arrays in Rcpp can be multidimensional just like they can in R. Here is a<br>
| &gt; line from one of the unit tests:<br>
| &gt;<br>
| &gt;   return IntegerVector( Dimension( 2, 3, 4) ) ;<br>
| &gt;<br>
| &gt; which sets the dim attribute of a given vector to c(2,3,4) just like you<br>
| &gt; would in R.  That should all work too but may have seen less exposure than<br>
| &gt; other parts of our code.<br>
|<br>
| Am I reading the Vector documentation correctly<br>
| (<a href="http://dirk.eddelbuettel.com/code/rcpp/html/classVector.html" target="_blank">http://dirk.eddelbuettel.com/code/rcpp/html/classVector.html</a>) in<br>
| interpreting that while you can create vectors with dimensions, that<br>
| there is no syntactic sugar for  multidimensional indexing?  I&#39;m not<br>
<br>
I think that is correct. We do have Range objects, and that is about it.<br>
This is not yet a level comparable to R.<br>
<br>
The unitTests/ directories, as always, has the largest collections of working<br>
idioms to copy from.  runit.Vector.r is probably what you want to look at.<br>
<br>
| quite sure how to interpret method signatures like operator() (const<br>
| size_t &amp;i, const size_t &amp;j) const. I can guess that means you can<br>
| index by two integers - but I don&#39;t know what those two integers mean.<br>
<br>
Well if I had to guess I&#39;d say row and column ...<br>
<br>
Dirk<br>
<br>
|<br>
| Hadley<br>
|<br>
| --<br>
| Assistant Professor / Dobelman Family Junior Chair<br>
| Department of Statistics / Rice University<br>
| <a href="http://had.co.nz/" target="_blank">http://had.co.nz/</a><br>
<br>
--<br>
&quot;Outside of a dog, a book is a man&#39;s best friend. Inside of a dog, it is too<br>
dark to read.&quot; -- Groucho Marx<br>
</blockquote></div></div><br><br>-- <br>Edward Wallace, PhD<br>Harvard FAS center for Systems Biology<br>+1-773-517-4009<br>