rcpp

Calling a Rcpp function from another Rcpp function while building an R package

帅比萌擦擦* 提交于 2020-12-29 03:05:06
问题 I took this example from a different question. I am building an R package with Rcpp. I have a function like fun1 (below) that I want to put into its own .cpp file. Then I want to call fun1 with other functions (like fun() does below). I want fun1 in a separate file because I am going to call it from several Rcpp functions that are in different .cpp files. Are there certain include statements and things I need to do to make the fun1 function accessible in the .cpp where fun() is located? Thank

Calling a Rcpp function from another Rcpp function while building an R package

你离开我真会死。 提交于 2020-12-29 03:04:39
问题 I took this example from a different question. I am building an R package with Rcpp. I have a function like fun1 (below) that I want to put into its own .cpp file. Then I want to call fun1 with other functions (like fun() does below). I want fun1 in a separate file because I am going to call it from several Rcpp functions that are in different .cpp files. Are there certain include statements and things I need to do to make the fun1 function accessible in the .cpp where fun() is located? Thank

Fix memory leak in for loop

∥☆過路亽.° 提交于 2020-12-15 04:28:43
问题 I have issues with memory leaks on a C++ function that I have sourced into R through Rcpp. This result in a sudden abortion of my R session. Sometimes I do get the following error message: GC encountered a node (0x111e25820) with an unknown SEXP type: 11 at memory.c:1748 What is weird to me is that if in function_test I move double lower =1; and double upper = value2; inside the for loop and edited them by also adding 'i': double lower =1 + i; and double upper = value2 + i; the function works

vectorized exponent for pow in Rcpp

大憨熊 提交于 2020-12-11 10:08:17
问题 Rcpp allows to vectorize some operations, which is great. But for pow only the base number can be a vector, not the exponent. Typically, on compilation: #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] NumericVector puissancedCpp(NumericVector base, double exp){ return pow(base,exp); } works but not: #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] NumericVector puissancedCpp(NumericVector base, NumericVector exp){ return pow(base,exp); } What would be the recommended