[Rcpp-devel] Accessing an attribute object in C/C++
Dirk Eddelbuettel
edd at debian.org
Thu Jul 12 13:26:19 CEST 2012
On 12 July 2012 at 10:45, Silkworth,David J. wrote:
| Sweet! Here is my sample now:
|
| src<- '
| Rcpp::NumericMatrix m_rcpp(arg1);
| arma::mat m_arma = Rcpp::as<arma::mat>(arg1);
| Rcpp::NumericVector v_rcpp(m_rcpp.attr("attachment"));
| arma::vec v_arma = Rcpp::as<arma::vec>(v_rcpp);
Why not pass two argument arg1 and arg2 as in
attr_sep<-cxxfunction(signature(arg1="numeric", arg2="numeric),
[...]
Why the attachment at all _to pass a variable_ ?
Dirk
|
| return(Rcpp::List::create(Rcpp::Named("origMatrix")=wrap(m_arma),
| Rcpp::Named("origVector")=wrap(v_arma)));
| '
|
| attr_sep<-cxxfunction(signature(arg1="numeric"),
| body = src, plugin = "RcppArmadillo")
|
|
| ## R test code:
| mymat<-matrix(1:12,3,4)
| myvec<-rep(5,4)
| attr(mymat,"attachment")<-myvec
|
| return_list<-attr_sep(mymat)
|
|
|
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list