Re: [Rcpp-devel] Call by reference

2015-07-28 Thread Rguy
Soren, Thanks for the insight. For other readers possibly struggling with call by reference, the following code works as expected, i.e., x is changed to c(1, 2). #include using namespace Rcpp; // [[Rcpp::export]] void absC(NumericVector & x) { int n = x.size(); for (int i = 0; i < n; ++i) { if

Re: [Rcpp-devel] Call by reference

2015-07-28 Thread Søren Højsgaard
Just a follow up on "copying": If you copying": If you do #include using namespace Rcpp; // [[Rcpp::export]] void absC(NumericVector & x) { if (x[0] < 0) x = -x; } /*** R y <- -1L absC(y) y */ you'll get > y <- -1L > absC(y) > y [1] -1 and that is because an IntegerVector is provided but

[Rcpp-devel] [ANN] Rcpp 0.12.0

2015-07-28 Thread Dirk Eddelbuettel
Rcpp 0.12.0 came out on Saturday, and I wrote a short blog which I expected to be mostly ignored on the weekend. I then forgot to mention this here. A short blog post about it is at http://dirk.eddelbuettel.com/blog/ http://dirk.eddelbuettel.com/blog/2015/07/25#rcpp_0.12.0 and includ

Re: [Rcpp-devel] Call by reference

2015-07-28 Thread Dirk Eddelbuettel
On 28 July 2015 at 17:53, Rguy wrote: | I attempted to implement the call by reference example on page 200 of Seamless | R and C++, as follows: | | #include | using namespace Rcpp; | | // [[Rcpp::export]] | void absC(double & x) { | if (x < 0) x = -x; | } | | /*** R | x = -1 | absC(x) | x | */

[Rcpp-devel] Call by reference

2015-07-28 Thread Rguy
I attempted to implement the call by reference example on page 200 of Seamless R and C++, as follows: #include using namespace Rcpp; // [[Rcpp::export]] void absC(double & x) { if (x < 0) x = -x; } /*** R x = -1 absC(x) x */ Unfortunately, x remains equal to -1. Platforms: Windows 7, "R versi

Re: [Rcpp-devel] correct way of making custom as and wrap functions available to other packages

2015-07-28 Thread Simon Barthelmé
Dear list, As a follow-up to last week's discussion, the simplest solution is indeed inlining. You can define your wrapper functions in a header, myPackage.h, containing inline function definitions rather than declarations: namespace Rcpp { template <> inline myClass as(SEXP foo){ /

Re: [Rcpp-devel] Compile RcppEigen with low memory

2015-07-28 Thread Felix Schönbrodt
Wow - that is of course the best solution! Thanks for the detailed instructions - worked like a charm. I was not aware of these PPAs, but they are really helpful for my small, outdated, and virtual server ;-) Cheers, Felix On 27 Jul 2015, at 19:37, Dirk Eddelbuettel wrote: On 27 July 2015