Skip to content

[Rcpp-devel] problem with devel code (solved)

1 message · Kaveh Vakili

#
Thanks for the link Dirk. Actually, your link induced me to try to reproduce the error on a different computer and i could not. 

For some reason, the code bugs (repeatedly) on a small atom-based net-book i use to program but not on my other computers (although they all run ubuntu 10.04& R2.12). Since i do not intend to actually run the code on the netbook, i don't consider this an issue.

Thanks again,

PS: For full reference i post below the error message i get on the netbook

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file4279b57c.cpp: In function ?SEXPREC* file4279b57c(SEXPREC*)?:
file4279b57c.cpp:36: error: no match for ?operator+? in ?tmp + Rcpp::Matrix<RTYPE>::column(int) [with int RTYPE = 14](i)?
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/sugar/operators/plus.h:209: note: candidates are: Rcpp::sugar::Plus_Vector_Primitive<RTYPE, NA, T> operator+(const Rcpp::VectorBase<RTYPE, LHS_NA, LHS_T>&, typename Rcpp::traits::storage_type<RTYPE>::type) [with int RTYPE = 14, bool NA = true, T = Rcpp::Vector<14>]
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/complex.h:26: note:                 Rcomplex operator+(const Rcomplex&, const Rcomplex&)
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/string_proxy.h:228: note:                 std::string Rcpp::internal::operator+(const std::string&, const Rcpp::internal::string_proxy<16>&)
make: *** [file4279b57c.o] Error 1


require( Rcpp )
require( inline )

f.Rcpp <- cxxfunction( signature( x = "matrix" ), '

     NumericMatrix input( x ) ;
     NumericMatrix output  = clone<NumericMatrix>( input ) ;

     int nr = input.nrow(), nc = input.ncol() ;
     NumericVector tmp( nr );
     for( int i=0; i<nc; i++){
         tmp = tmp + input.column(i) ;
         NumericMatrix::Column target( output, i ) ;
         std::copy( tmp.begin(), tmp.end(), target.begin() ) ;
     }
     return output ;

', plugin = "Rcpp" )

f.R <- function( x ){
     t(apply(probs, 1, cumsum)) #SLOOOW!
}