Re: [Rcpp-devel] inline plug-in linking

2012-11-17 Thread Ian Fellows
Thanks for the help. I just thought I should report back with the solution to my issues for posterity. It seems that the header only interface is the way to go for my purposes because I only have a few data structures which need to be shared across compilation units, and almost all of the code

Re: [Rcpp-devel] Struggling with Rcpp sugar

2012-11-17 Thread Romain Francois
Another, with mapply. But there we have to use rep since our mapply only works on vector expressions. inline double distance(double y, double x){ return pow( (y-x), 2.0 ) ; } // [[Rcpp::export]] NumericVector pdist6(double x, NumericVector ys) { return mapply( ys, rep(x,ys.size()), distance

Re: [Rcpp-devel] Struggling with Rcpp sugar

2012-11-17 Thread Romain Francois
Hi, While there, consider this version based on sapply: class Distance { public: typedef double result_type ; Distance( double x_ ) : x(x_){} inline double operator()(double y) const { return pow( (y-x), 2.0 ) ; } private: double x; } ; // [[Rcpp::export]] NumericVector pdist

Re: [Rcpp-devel] Working with strings

2012-11-17 Thread Romain Francois
Le 17/11/12 15:22, Hadley Wickham a écrit : Hi all, Am I doing something wrong with the functions below, or has this behaviour not yet been implemented in Rcpp? cppFunction('std::string first_char(const CharacterVector x) { return x[0]; }') Ah. > cppFunction('std::string

Re: [Rcpp-devel] Struggling with Rcpp sugar

2012-11-17 Thread Romain Francois
Le 17/11/12 14:42, Hadley Wickham a écrit : Hi all, I've included what seems to be a simple application of Rcpp sugar below, but I'm getting some very strange results. Any help would be much appreciate! Thanks, Hadley library(Rcpp) library(microbenchmark) # Compute distance between single p

[Rcpp-devel] Working with strings

2012-11-17 Thread Hadley Wickham
Hi all, Am I doing something wrong with the functions below, or has this behaviour not yet been implemented in Rcpp? cppFunction('std::string first_char(CharacterVector x) { return x[0]; }') cppFunction('CharacterVector miss_c() { return CharacterVector::create(NA_STRING)

[Rcpp-devel] Struggling with Rcpp sugar

2012-11-17 Thread Hadley Wickham
Hi all, I've included what seems to be a simple application of Rcpp sugar below, but I'm getting some very strange results. Any help would be much appreciate! Thanks, Hadley library(Rcpp) library(microbenchmark) # Compute distance between single point and vector of points pdist1 <- function(x