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
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
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
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
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
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)
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