Skip to content
Back to formatted view

Raw Message

Message-ID: <19943.35852.518191.808752@max.nulle.part>
Date: 2011-06-02T13:11:40Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] Wrapping uBlas Matrices into Rcpp Matrices
In-Reply-To: <4DE7857F.6090101@googlemail.com>

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