rcppparallel

Apply function to multiple groups using Rcpp and R function

倖福魔咒の 提交于 2019-12-25 03:22:56
问题 I'm trying to apply a function to multiple groups/id's in r using the foreach package. It's taking forever to run using parallel processing via %dopar% , so I was wondering if it's possible to run the apply or for loop portion in c++ via rcpp or other packages to make it faster. I'm not familiar with c++ or other packages that can do this so I'm hoping to learn if this is possible. The sample code is below. My actual function is longer with over 20 inputs and takes even longer to run than

Threadsafe function pointer with Rcpp and RcppParallel via std::shared_ptr

给你一囗甜甜゛ 提交于 2019-12-24 20:06:36
问题 I would like to use a threadsafe function pointer to be applied in an RcppPrallel worker. But I have already problems with this tiny example. No matter if I use it in a package and add SystemRequirements: C++11 in the DESCRIPTION file, or use it in a standard cpp file and add // [[Rcpp::plugins(cpp11)]] I get the same Errors: 'shared_ptr' is not a member of 'std' . Can anyone please help me? Thank you! #include <Rcpp.h> using namespace Rcpp; using namespace std; double f1 (double x, double y)

Calling 'mypackage' function within public worker

夙愿已清 提交于 2019-12-18 09:26:51
问题 I know the problem I have is a thread-safety issue. As the code I have now will execute with 'seThreadOptions(1)'. My question is what would be a good practice to overcome this. I know this: Threadsafe function pointer with Rcpp and RcppParallel via std::shared_ptr Will come into play somehow. And I have also been thinking/playing around with making the internal function part of the structure for the parallel worker. Realistically, I am calling two internal functions and I would like one to

Rcpp Parallel or openmp for matrixvector product

大兔子大兔子 提交于 2019-12-12 12:27:05
问题 I am trying to program the naive parallel version of Conjugate gradient, so I started with the simple Wikipedia algorithm, and I want to change the dot-products and MatrixVector products by their appropriate parallel version, The Rcppparallel documentation has the code for the dot-product using parallelReduce; I think I'm gonna use that version for my code, but I'm trying to make the MatrixVector multiplication, but I haven't achieved good results compared to R base (no parallel) Some

Parallel Worker in namespace

浪尽此生 提交于 2019-12-11 18:49:33
问题 This example is a follow up example from this earlier post. I am trying to move the Parallel Worker to its own cpp file and and declare it in the header file. Calling 'mypackage' function within public worker The two errors are as follows: 1) variable type 'ExampleInternal::PARALLEL_WORKER' is an abstract class and in my non-reproducible example: 2) error: expected unqualified-id on the 'ExampleInternal::PARALLEL_WORKER{' line in the Parallel_worker.cpp file. Right now the code looks like

R packages with Rcpp and nloptr

醉酒当歌 提交于 2019-12-11 05:17:54
问题 I have been building an r-package that runs RcppParallel and calls nloptr from the cpp in parallel. Currently, the package will not build as it can't find the 'nloptrAPI.h' file. The build log outputs: * checking dependencies in R code ... NOTE Namespaces in Imports field not imported from: ‘RcppArmadillo’ ‘nloptr’ My question is if there is a simple fix for this. Or if I would have to rewrite the function to call 'nlopt' from the cpp version and add a 'makevars' file to the package. The src

Calling 'mypackage' function within public worker

别来无恙 提交于 2019-11-29 16:26:09
I know the problem I have is a thread-safety issue. As the code I have now will execute with 'seThreadOptions(1)'. My question is what would be a good practice to overcome this. I know this: Threadsafe function pointer with Rcpp and RcppParallel via std::shared_ptr Will come into play somehow. And I have also been thinking/playing around with making the internal function part of the structure for the parallel worker. Realistically, I am calling two internal functions and I would like one to be variable and the other to be constant, this tends me to think that i will need 2 solutions. The error