I'm not sure what causes the error on the netbook. Is this a recent enough version of Rcpp ?

Also, for the record the code below can now (well with the svn version) be written in a more sugary way (See also slide 25 of http://slidesha.re/cDIfp0)

SEXP foo( SEXP x ){
  NumericMatrix input( x );
  int nr = input.nrow(), nc = input.ncol();
  NumericMatrix output = clone<NumericMatrix>(input);
  for( int i=1; i<nc; i++)
    output.column(i) =
        output.column(i-1) + input.column(i);
  return output;
}

Romain

Le 31/10/10 23:23, Kaveh Vakili a écrit :
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!
}




On 31 October 2010 at 20:03, Kaveh Vakili wrote:
| Hi,
|
| i tried to inline the code for f.Rcpp found here:
|
| http://article.gmane.org/gmane.comp.lang.r.rcpp/851/match=matrix+inline
|
| I get a mysterious bug. I'l not sure what's wrong with the code, can anyone 
comment ?

May I suggest that you read something like

       http://www.catb.org/esr/faqs/smart-questions.html

as you

  - did not show what commands you executed did,

  - did not say what you expected,

  - did not detail what you got instead,

  - and generally did not offer anything here, in particular no information
    on which operating system, g++ version, R version, Rcpp version, etc pp.

Thanks, Dirk

--
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com




_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/czHPM7 : Rcpp Google tech talk on youtube
|- http://bit.ly/9P0eF9 : Google slides
`- http://bit.ly/cVPjPe : Chicago R Meetup slides


_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to