On 31 May 2013 at 10:28, Søren Højsgaard wrote:
| Romain,
|
| Perhaps I now see the light at the end of the tunnel (hope it is not a train
comming against me!): If I understand this correctly, the following
|
| > template <int RTYPE>
| > Matrix<RTYPE> vec2matrix2(Vector<RTYPE> x, int nrow, int ncol) {
| > return Matrix<RTYPE>(nrow, ncol, x.begin()); }
|
| should do the dispatching properly if I call vec2matrix2 from a c++ function.
Right? And all the other bells and whistles are merely to be able to call the
function from R?
Yep. From R we are bound by the SEXP foo(SEXP a, SEXP b, ...) interface
that .Call() can use.
Hence Romain's
SEXP vec2matrix(SEXP x, int nrow, int ncol){
where the int values get converted by 'hidden' as<>() calls. From C++,
however, you can call the above directly.
Hth, Dirk
--
Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel