[Rcpp-devel] Accessing an attribute object in C/C++
Silkworth,David J.
SILKWODJ at airproducts.com
Thu Jul 12 12:45:43 CEST 2012
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);
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)
More information about the Rcpp-devel
mailing list