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