Skip to content
Prev 2480 / 10988 Next

[Rcpp-devel] Wrapping uBlas Matrices into Rcpp Matrices

Thank you very much for this Romain, and sorry for the delay in testing 
that. Basically, I have tested it in my system and I get the following 
error messages

//////////////////////////////////////////////////////////////////////////////
// Matrices:
template <typename Iterator>
     Matrix( const int& nrows_, const int& ncols, Iterator start ) :
         VECTOR( start, start + (nrows_*ncols) ),
         nrows(nrows_)
     {
         VECTOR::attr( "dim" ) = Dimension( nrows, ncols ) ;
     }

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.size1(), x.size2(), x.begin1()
     );
}
///////////////////////////////////////////////////////////////////////////////////

templatedFunction.h:60:65: error: ISO C++ forbids declaration of 
?Matrix? with no type
templatedFunction.h: In function ?int Matrix(const int&, const int&, 
Iterator)?:
templatedFunction.h:61:9: error: only constructors take base initializers
templatedFunction.h:64:9: error: ?VECTOR? has not been declared
templatedFunction.h:64:44: error: ?nrows? was not declared in this scope

//////////////////////////////////////////////////////////////////////////////////

Cheers,
Cedric
On 06/06/11 12:55, Romain Francois wrote: