rcpp

R with C++ (QtCreator, Windows, Rcpp, RInside)

狂风中的少年 提交于 2019-12-11 04:54:50
问题 I have a problem when it comes to using R within the C++ code. I'd like to create UI in c++ and do all needed calculations in R. So i've found stuff like Rcpp and RInside and even though i've read a lot from Dirk Eddelbuettel's site, i'm not able to compile even the easiest program from examples attached to RInside. Obviously there is a problem with QtCreator config, I've been trying to make it right, but with no success. What i'm asking for would be step-by-step explanation of QT adjustment

How arguments are passed into a cppFunction

帅比萌擦擦* 提交于 2019-12-11 04:13:44
问题 I'm puzzled as to how arguments are passed into a cppFunction when we use Rcpp. In particular, I wonder if someone can explain the result of the following code. library(Rcpp) cppFunction("void test(double &x, NumericVector y) { x = 2016; y[0] = 2016; }") a = 1L b = 1L c = 1 d = 1 test(a,b) test(c,d) cat(a,b,c,d) #this prints "1 1 1 2016" 回答1: As stated before in other areas, Rcpp establishes convenient classes around R's SEXP objects. For the first parameter, the double type does not have a

RcppArmadillo “ReferenceInputParameter is not a template”

余生长醉 提交于 2019-12-11 04:04:26
问题 I am trying to build a user package that has been building fine on my colleague's windows box which has R 2.15.1 installed. My config is: R 2.15.3, RTools 3.0, Rcpp 0.10.4, RcppArmadillo 0.3.920.1, RStudio 0.97.551 This is the first compilation instance when I run "R CMD INSTALL mypackage". indfunForecast.cpp is one of the source files within the package. >g++ -m32 -I"D:/PROGRA~1/R/R-215~1.3/include" -DNDEBUG -I"D:/R/win-library/2.15/Rcpp/include" -I"D:/R/win-library/2.15/RcppArmadillo

How to use Rcpp to do numerical integration in C++ within R

≡放荡痞女 提交于 2019-12-11 03:56:03
问题 I was wondering how Rcpp could be used to perform numerical integration by calling C++ in R. My current setup takes a really long time and is highly error prone. I think I need something better than default R numerical integration package. Would doing numerical integration in C++ within R solve these problems? funk <- function(x,b) { 10^b * exp(-x/10) } lambda <- function(y,k) { exp(-k*y) } funk1 <- function(y,x,xb,b,k) { funk(x-xb-y,b) *exp(- integrate(lambda, lower=0, upper = y, k=k)$value)

RcppParallel: Converting CharacterMatrix to RMatrix<T>

余生颓废 提交于 2019-12-11 03:49:08
问题 Hello Dear Community, I am learning RcppParallel and have this issue while trying to convert a Rcpp::CharacterMatrix to RcppParallel::RMatrix using following codes: struct CharMatDist : RcppParallel::Worker { const RcppParallel::RMatrix<std::string> A; const RcppParallel::RMatrix<std::string> B; const NumericVector w; RcppParallel::RMatrix<double> ret; int n; CharMatDist(CharacterMatrix A, CharacterMatrix B, NumericVector w, NumericMatrix ret) : A(A), B(B), w(w), ret(ret) { n = B.nrow(); } ..

Rcpp inline package error in compileCode

主宰稳场 提交于 2019-12-11 03:09:03
问题 I have R installed along with these two packages Rcpp and inline. (I am doing a project that consists of speeding up a painfully slow program in R and I decided to use Rcpp)...I know I am doing something wrong...probably missing a step but i cannot figure it out. Props to Dirk if you're reading this! Thanks for Rcpp and the brand new inline package pdf but...it's still not running. Please note that I'm a newbie. As stated before I cleaned out all other packages and only R is installed with

Rcpp sourceCpp compiler settings

烈酒焚心 提交于 2019-12-11 03:08:53
问题 I am using Rcpp to speed up a function that gets called repeatedly in R (3.4, Windows7) and I was hoping to change the compiler settings. When I call: sourceCpp("scoreseq1.1.cc", verbose=TRUE) Part of the output reads: C:/RBuildTools/3.4/mingw_64/bin/g++ -I"C:/PROGRA~1/R/R-34~1.1/include" -O2 -Wall -mtune=core2 -c scoreseq1.1.cc -o scoreseq1.1.o I would like to change -mtune to haswell , and -O2 to -O3 in search of some performance improvements. Is there a way to do that through the sourceCpp

Rcpp: how to keep files generated by sourceCpp?

可紊 提交于 2019-12-11 02:24:58
问题 I use sourceCpp() from the Rcpp package to build a C++ file and call it from R. It seems to generate a temporary directory where it writes the source it compiles, but it removes that directory after building the code. I want to get access to the exact file it is compiling, so that I can see it in my debugger. How can I prevent sourceCpp() from deleting the file it compiles? 回答1: As Dirk said -- seriously, just use packages . Any other workflow you develop on top of sourceCpp is likely to be

Is it possible to use Alglib with Rcpp?

只愿长相守 提交于 2019-12-11 02:01:12
问题 I often use Rcpp code to incorporate C++ code into R. Through the BH-package I am also able to use the Boost-library. However, the Boost library lacks a function that I would like to use (to be precise, it only has Bessel function but I would like to get Log-Bessel immediately because of overflow). I know that Alglib does have this feature. Would it be possible to use Alglib with Rcpp, that is, use the log-bessel function from Alglib somehow? 回答1: I do not see a clear difference in

Use pnorm from Rmath.h with Rcpp

微笑、不失礼 提交于 2019-12-11 01:57:05
问题 I am trying to write a piece of C++ code with Rcpp using functions like pnorm and qnorm. I can use the Rcpp sugar versions of these for vectors as explained in https://stackoverflow.com/a/9738848/567015, but I don't need to do this on a vector but just on a double. If I understand correctly I can use the Rf_ prefix to get the scalar versions from Rmath.h. However, Rf_pnorm doesn't work: library("inline") Src <- ' double y = as<double>(x); double res = Rf_pnorm(y,0.0,1.0); return wrap(res) ; '