rcpp

ld: warning: text-based stub file are out of sync. Falling back to library file for linking

风格不统一 提交于 2019-12-20 08:35:51
问题 When I am trying to sourceCpp , it gives a warning: ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking. But the function actually works. Just wondering how to solve this warning. 回答1: I had this problem while compiling Go code on my Mac too. The tld files were out of sync in /System/Library

Rcpp causes segfault RcppArmadillo does not

假装没事ソ 提交于 2019-12-20 07:40:01
问题 I'm currently trying to parallelize an existing hierarchical MCMC sampling scheme. The majority of my (by now sequential) source code is written in RcppArmadillo, so I'd like to stick with this framework for parallelization, too. Before starting with parallelizing my code I have read a couple of blog posts on Rcpp/Openmp. In the majority of these blog posts (e.g. Drew Schmidt, wrathematics) the authors warn about the issue of thread safety, R/Rcpp data structures and Openmp. The bottom line

Rcpp causes segfault RcppArmadillo does not

两盒软妹~` 提交于 2019-12-20 07:39:21
问题 I'm currently trying to parallelize an existing hierarchical MCMC sampling scheme. The majority of my (by now sequential) source code is written in RcppArmadillo, so I'd like to stick with this framework for parallelization, too. Before starting with parallelizing my code I have read a couple of blog posts on Rcpp/Openmp. In the majority of these blog posts (e.g. Drew Schmidt, wrathematics) the authors warn about the issue of thread safety, R/Rcpp data structures and Openmp. The bottom line

Adding a new component to a DatetimeVector in Rcpp

梦想的初衷 提交于 2019-12-20 07:30:09
问题 I would appreciate if someone could help me in push_back a new component into DatetimeVector . A DatetimeVector only has begin, end, getDatetimes and size methods. 回答1: I'd say don't. For multiple reasons: All Rcpp types uses an underlying SEXP which requires contiguous memory. So adding a single element always requires copying all--expensive. The DatetimeVector class is pretty bad. I wrote it many years ago to pass data to QuantLib. These days we can do better via simple NumericVector

converting loop from R to C++ using Rcpp

六月ゝ 毕业季﹏ 提交于 2019-12-20 05:54:08
问题 I want to improve the speed of some of my R code using Rcpp. However, my knowledge of C++ is very little. So, I checked the documentation provided with Rcpp, and other documents provided at Dirk Eddelbuttel’s site. After reading all the stuff, I tried to execute a simple loop that I wrote in R. unfortunately, I was unable to do it. Here is the R function: Inverse Wishart beta = matrix(rnorm(15),ncol=3) a = rnorm(3) InW = function(beta,a) { n = nrow(beta) p = ncol(beta) I = diag(rep(1,times =

Transform a boost::array into NumericVector in Rcpp

久未见 提交于 2019-12-20 04:13:03
问题 In my C++ script (run in R using Rcpp), I defined : typedef boost::array< double ,3 > state_type; Now, I want to create a function to transform a state_type variable to a Rcpp::NumericVector variable, and another function that do the inverse. How can do that? I need to do that in order to use R function into C++. 回答1: How about Rcpp::NumericVector boost_array_to_nvec(state_type const& s) { Rcpp::NumericVector nvec(s.size()); for (size_t i = 0; i < s.size(); ++i) { nvec[i] = s[i]; } return

*.o: File format not recognized on Windows 7

£可爱£侵袭症+ 提交于 2019-12-20 03:24:05
问题 I wrote an R package called arbintools for some work-related data analysis and put it on Github. I wrote it and have been using it on my Mac for a while without issue; Today, I tried to install the dev-1 branch on a Windows 7 laptop and something related to compiling some Rcpp functions seems to go wrong: devtools::install_github("mjlacey/arbintools", ref = "dev1") I get this: Downloading GitHub repo mjlacey/arbintools@dev1 from URL https://api.github.com/repos/mjlacey/arbintools/zipball/dev1

Resolving unstated -llapack dependency issue on Solaris

限于喜欢 提交于 2019-12-20 03:00:45
问题 I have released an R package on CRAN which depends on the successful compilation of some RcppArmadillo code. The package built correctly and with no notes on all the test systems that I tried (CRAN comments here if interested), however, the CRAN checks fail on solaris-sparc and are unable to load a dependency on solaris-x86 . See here for CRAN checks. The reason for the error is given as ld: fatal: library -llapack: not found (from goldi-00install.html). In my Makevars and Makevars.win , I

Can't use Rcpp engine in R Markdown

微笑、不失礼 提交于 2019-12-19 17:46:20
问题 I tried to Knit HTML the following Rmd file: --- title: "Untitled" author: "Florian Privé" date: "12 septembre 2016" output: html_document --- ```{r fibCpp, engine='Rcpp'} #include <Rcpp.h> // [[Rcpp::export]] int fibonacci(const int x) { if (x == 0 || x == 1) return(x); return (fibonacci(x - 1)) + fibonacci(x - 2); } ``` I got the following error: Building shared library for Rcpp code chunk... Warning message: l'exécution de la commande 'make -f "C:/PROGRA~1/R/R-33~1.1/etc/x64/Makeconf" -f

Message error 'C:/Program' not found with Rcpp

心已入冬 提交于 2019-12-19 10:14:24
问题 I'm running a 64-bit Windows 7 platform. I have added to my installed programs/libraries: Rtools R (software) Rcpp (R package) inline (R package) I tried out a snippet found here ## now with Rcpp and C++ library(inline) # and define our version in C++ src <- "int n = as<int>(ns); double x = as<double>(xs); for (int i=0; i<n; i++) x=1/(1+x); return wrap(x); " l <- cxxfunction(signature(ns="integer", xs="numeric"), body=src, plugin="Rcpp") But that doesn't work (That is not a surprise to be