<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">FYI, there is a Array template in Rcpp11.<div><a href="https://github.com/romainfrancois/Rcpp11/blob/master/inst/include/Rcpp/Array.h">https://github.com/romainfrancois/Rcpp11/blob/master/inst/include/Rcpp/Array.h</a></div><div><br></div><div>With which you could use code like this: <div><br></div><div><div>#include <Rcpp.h></div><div>using namespace Rcpp ;</div><div><br></div><div>// [[Rcpp::export]]</div><div>double NewFunc( NumericArray<3> x){</div><div>  return x(1,2,3) + x(2,3,4) ; </div><div>}</div><div><br></div><div>Romain</div><div><br></div><div><div><div>Le 12 févr. 2014 à 15:23, Nick Menzies <<a href="mailto:nick.menzies@gmail.com">nick.menzies@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi Dirk, thanks for pointing me in the right direction. <div><br></div><div>My solution below for a 3D array (documenting for rubes like myself).   N<div><br></div><div><div>library(Rcpp)</div><div>library(RcppArmadillo)</div>

<div><br></div><div>    cppFunction('<br></div><div>    double  NewFunc( NumericVector ArrayR ) {</div><div>      IntegerVector DimsA = ArrayR.attr("dim");</div><div>      arma::cube    ArrayC(ArrayR.begin(),DimsA[0],DimsA[1],DimsA[2],false);</div>

<div>      double Output = ArrayC(1,2,3) + ArrayC(2,3,4);</div><div>      return Output;      </div><div>    }', depends="RcppArmadillo")</div><div><br></div><div>    NewFunc(array(1,dim=c(5,5,5))) # Test, works</div>

</div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 11, 2014 at 3:34 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
(Resending, this time with CC to list. Sorry for the extra first post. --Dirk)<br>
<div class="im HOEnZb"><br>
On 11 February 2014 at 11:49, Nick Menzies wrote:<br>
</div><div class="im HOEnZb">| Is there a way to pass an array into c++ when using cppFunction?  I realize<br>
| arrays have been discussed a number of times, but the solutions I have found<br>
</div><div class="im HOEnZb">| (e.g. <a href="http://markovjumps.blogspot.com/2011/12/" target="_blank">http://markovjumps.blogspot.com/2011/12/</a><br>
| r-array-to-rcpparmadillo-cube.html, or <a href="https://www.mail-archive.com/" target="_blank">https://www.mail-archive.com/</a><br>
</div><div class="im HOEnZb">| <a href="http://rcpp-devel@lists.r-forge.r-project.org/msg05897.html" target="_blank">rcpp-devel@lists.r-forge.r-project.org/msg05897.html</a>) are described in the<br>
| context of cxxfunction, and I haven't been able to work how to implement this<br>
| with cppFunction.<br>
<br>
</div><div class="HOEnZb"><div class="h5">An array is just a vector with a dimension attribute. Treat it the same at<br>
the C++ level.<br>
<br>
There are several posts at the Rcpp Gallery dealing with reading / setting<br>
attributes, and you should know how to pass a single vector through.<br>
<br>
Dirk<br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com/" target="_blank">http://dirk.eddelbuettel.com</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><br>Nick Menzies<br><a href="mailto:nick.menzies@gmail.com">nick.menzies@gmail.com</a><br>404 217 1076
</div>
_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</blockquote></div><br></div></div></div></body></html>