Skip to content
Prev 2398 / 10988 Next

[Rcpp-devel] Wrapping uBlas vectors into Rcpp Vectors.

Le 01/06/11 14:28, Cedric Ginestet a ?crit :
Sure. This was a typo/thinko: go with something like this :

template <typename T>
Rcpp::Vector< Rcpp::traits::r_sexptype_traits<T>::rtype >
ublas2rcpp( const vector<T>& x ){
     return Rcpp::Vector< Rcpp::traits::r_sexptype_traits<T>::rtype >(
         x.begin(), x.end()
     )  ;
}

and Rcpp::Vector<int> makes no sense, you probably want IntegerVector, 
or (the same class):

Rcpp::Vector< r_sexptype_traits<int>::rtype >

Rcpp::Vector is templated by the SEXP type.
That is much better yes. ublas probably gives a way to access the size 
of the vector.