rcpp

Rcpparmadillo: can't call Fortran routine “dgebal”?

折月煮酒 提交于 2019-12-19 04:07:20
问题 I need to use a Fortran routine called dgebal (documentation here) in my Rcpparmadillo code. I have included the following headers: # include <RcppArmadillo.h> # include <math.h> However, when I try to compile my code using sourceCpp() I get the following error: error: 'dgebal_' was not declared in this scope If I further include <R_ext/Lapack.h> and <R_ext/BLAS.h> , the code compiles without error and runs fine. However the compiler throws a bunch of warnings like this: C:/PROGRA~1/R/R-32~1

using rinside with qt in windows

守給你的承諾、 提交于 2019-12-19 04:04:32
问题 I am beginning using rinside and rcpp within c++. I just want to start from zero so my QT project has nothing but the creation of a RInside instance and I have a problem I cannot solve. I have only one dialog form in the project. My project file: QT += core gui TARGET = rcpp-rinside TEMPLATE = app SOURCES += main.cpp\ dialog.cpp HEADERS += dialog.h FORMS += dialog.ui INCLUDEPATH += C:\R\R-2.15.1\include INCLUDEPATH += C:\R\R-2.15.1\library\Rcpp\include INCLUDEPATH += C:\R\R-2.15.1\library

Slice a string at consecutive indices with R / Rcpp?

旧城冷巷雨未停 提交于 2019-12-19 03:36:39
问题 I want to write a function that slices a 'string' into a vector, sequentially, at a given index. I have a fairly adequate R solution for it; however, I figure that writing the code in C/C++ would likely be faster. For example, I'd like to be able to write a function 'strslice' that operates as follows: x <- "abcdef" strslice( x, 2 ) ## should return c("ab", "cd", "ef") However, I'm not sure how to handle treating elements of the 'CharacterVector' passed around in the Rcpp code as strings.

How do I share C++ functions in Rcpp-based libraries between R packages?

点点圈 提交于 2019-12-19 03:21:26
问题 I'm developing a simple library in Rcpp that builds Huffman trees. It has a working R interface I can call from other packages, but I'd also like to call the C++ functions directly from C++ code in other Rcpp-based packages I'm developing. I've figured out how to put the header for the first package in the inst/include directory so that it is available in the second package. However, when useDynLib is called in the second package's NAMESPACE file to load it's C++ code that calls a function in

Rcpp NumericMatrix - how to erase a row / column?

家住魔仙堡 提交于 2019-12-18 23:39:12
问题 A novice question as I learn the Rcpp classes / data structures: Is there a member function to erase a row / column for an object of class Rcpp::NumericMatrix ? (Or other types of type **Matrix -- I'm assuming it's a template class)? library(Rcpp) cppFunction(' NumericMatrix sub1 {NumericMatrix x, int& rowID, int& colID) { // let's assume separate functions for rowID or colID // but for the example case here x.row(rowID).erase(); // ??? does this type of member function exist? x.col(colID)

Rcpp: Returning C array as NumericMatrix to R

丶灬走出姿态 提交于 2019-12-18 18:02:11
问题 #include <Rcpp.h> #include <vector> extern "C" { #include "cheader.h" } using namespace Rcpp; // [[Rcpp::export]] NumericVector cppfunction(NumericVector inputR){ double const* input = inputR.begin(); size_t N = inputR.size(); double output[10*N]; cfunction(input, N, output); std::vector<double> outputR(output, output + sizeof(output) / sizeof(double)); return wrap(outputR); } This works except I have to manually convert the vector outputR to matrix in R. I could of course also make outputR

RcppArmadillo sample on armadillo vector classes

蓝咒 提交于 2019-12-18 09:47:16
问题 We have been using the sample function from RcppArmadillo to randomly sample a NumericVector object. However, we have noticed that it isn't possible to use the same function on Armadillo types ( vec or uvec ). We have looked at the function definitions from the sample.h file and it looks like a templated function that should be able to work with these types, but we haven't been able to figure out how to make it work with Armadillo classes without doing a lot of conversions to and from the

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

Using Rcpp functions inside of R's par*apply functions from the parallel package

强颜欢笑 提交于 2019-12-18 09:22:12
问题 I'm trying to understand what is happening behind the Rcpp::sourceCpp() call on a parallelized environment. Recently, this was partially addressed in the question: Using Rcpp function in parLapply on Windows. Within this post, Dirk said, "You need to run the sourceCpp() call in each spawned process, or else get them your code." This was in response to questioner's use of distributing the Rcpp function to the worker processes. The questioner was sending the Rcpp function via: clusterExport(cl

How can I use qnorm on Rcpp?

隐身守侯 提交于 2019-12-18 08:48:23
问题 require(inline) func <- cxxfunction(, 'return Rcpp::wrap( qnorm(0.95,0.0,1.0) );' ,plugin="Rcpp") error: no matching function for call to ‘qnorm5(double, int, int)’ require(inline) func <- cxxfunction(, 'return Rcpp::wrap( qnorm(0.95, 0.0, 1.0, 1, 0) );' ,plugin="Rcpp") error: no matching function for call to ‘qnorm5(double, double, double, int, int)’ require(inline) code <-' double a = qnorm(0.95, 0.0, 1.0); return Rcpp::wrap( a ); ' func <- cxxfunction(, code ,plugin="Rcpp") func() error: