Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-15 Thread JJ Allaire
It's because several instances of your object will be created (via the splitting constructor) and then joined together using the join method. If all instances share an output variable then they will overwrite each others' output, giving them their own allows the split/join logic to work correctly.

Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-15 Thread Vaidas Zemlys
Hi, I’ve finally managed to produce code that works. I hope. The key was to leave output variable out of constructor: #include using namespace Rcpp; // [[Rcpp::depends(RcppParallel)]] #include using namespace RcppParallel; struct SumsInGroups5: public Worker { const RVector v; const RV