Skip to content
Prev 2403 / 10988 Next

[Rcpp-devel] Wrapping uBlas Matrices into Rcpp Matrices

Hi again,

I have tried to do the same for Matrices. Here my naive attempt:
////////////////////////////////////////////////////////////////
template <typename T>
Rcpp::Matrix< Rcpp::traits::r_sexptype_traits<T>::rtype >
ublas2rcpp( const matrix<T>& x ){
     return Rcpp::Matrix< Rcpp::traits::r_sexptype_traits<T>::rtype >(
         x.begin(), x.end()
     );
}
//////////////////////////////////////////////////////////////
Obviously that doesn't work, and I get the following error message:
templatedFunction.h:63:5: error: ?const class 
boost::numeric::ublas::matrix<int>? has no member named ?begin?
templatedFunction.h:63:5: error: ?const class 
boost::numeric::ublas::matrix<int>? has no member named ?end?

I suppose that I either need to 'vectorized' the matrices or to run 
through both set of row and column indices. What is the best way to do so?

Best wishes,
Cedric
On 01/06/11 14:14, Romain Francois wrote: