Hello Rcpp'ers,<br><br>I want to access a List of matrices in an Rcpp/C++ function that will passed to me via R...<br><br>src <- "<br> using namespace Rcpp ;<br> List inputList(L) ;<br> NumericMatrix tmpMatrix ;<br>
<br> tmpMatrix = NumericMatrix(inputList[0]) ;<br> return(wrap(tmpMatrix.ncol())) ;<br>"<br>test <- cxxfunction(signature(L="list"), src, plugin = "Rcpp" )<br><br>This gives me the following error-<br>
<br>file30b9664194fc.cpp: In function ‘SEXPREC* file30b9664194fc(SEXPREC*)’:<br>file30b9664194fc.cpp:34: error: call of overloaded ‘Matrix(Rcpp::internal::generic_proxy<19>)’ is ambiguous<br>/usr/share/R/include/Rcpp/vector/SubMatrix.h:57: note: candidates are: Rcpp::Matrix<RTYPE>::Matrix(const Rcpp::SubMatrix<RTYPE>&) [with int RTYPE = 14]<br>
/usr/share/R/include/Rcpp/vector/Matrix.h:67: note: Rcpp::Matrix<RTYPE>::Matrix(const Rcpp::Matrix<RTYPE>&) [with int RTYPE = 14]<br>/usr/share/R/include/Rcpp/vector/Matrix.h:65: note: Rcpp::Matrix<RTYPE>::Matrix(const int&) [with int RTYPE = 14]<br>
/usr/share/R/include/Rcpp/vector/Matrix.h:46: note: Rcpp::Matrix<RTYPE>::Matrix(const Rcpp::Dimension&) [with int RTYPE = 14]<br>/usr/share/R/include/Rcpp/vector/Matrix.h:39: note: Rcpp::Matrix<RTYPE>::Matrix(SEXPREC*) [with int RTYPE = 14]<br>
make: *** [file30b9664194fc.o] Error 1<br><br clear="all">In looking at the error, it's not clear to me how these candidates will help. What am I missing in telling Rcpp what class of object it should be expecting coming out of inputList?<br>
<br>I know this kind of question (i.e. I want a 3d cube etc) pops up frequently and the answer is typically "use arma's 3d cubes" (e.g. <a href="http://stackoverflow.com/questions/8159872/r-list-of-numeric-vectors-c-2d-array-with-rcpp">http://stackoverflow.com/questions/8159872/r-list-of-numeric-vectors-c-2d-array-with-rcpp</a>), but I don't intend on doing linear algebra. My data really is just a series of matrices of arbitrary sizes. <br>
<br>Also, I looked into multi-dimensional arrays, but how to access them seems unclear; I did see a post on this list to that nature but the solution seemed inelegant.<br><br>Thanks in advance for any help!<br>