[Rcpp-devel] Wrapping uBlas Matrices into Rcpp Matrices
Dirk Eddelbuettel
edd at debian.org
Thu Jun 2 15:11:40 CEST 2011
On 2 June 2011 at 13:43, Cedric Ginestet wrote:
| 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?
Hm, maybe you can tell us?
Do some research on uBlas internals, prototype a few approaches, profile the
hell out of them, and then report back.
If you don't want to do that, or feel you can't, then consider RcppArmadillo
which gives you a well designed and actively developed Matrix call.
Dirk
--
Gauss once played himself in a zero-sum game and won $50.
-- #11 at http://www.gaussfacts.com
More information about the Rcpp-devel
mailing list