Re: [Rcpp-devel] (Very) rare segfault

2014-08-21 Thread Matteo Fasiolo
Hi Romain and Gregor, maybe I am misunderstanding everything, but hasn't this problem been explained and solved here: http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-May/005838.html Best, Matteo On Thu, Aug 21, 2014 at 10:58 AM, Romain Francois wrote: > > Le 21 août 2014 à 11

Re: [Rcpp-devel] Segfault when attributes are not used

2014-08-10 Thread Matteo Fasiolo
M, JJ Allaire wrote: > Yes, there is a subtle bug in RNGScope which can cause this. The good news > is that you don't need RNGScope (since it's added, along with a workaround > for the bug, by Rcpp::export) > > > On Aug 10, 2014, at 10:37 AM, Matteo Fasiolo > wrote:

[Rcpp-devel] Segfault when attributes are not used

2014-08-10 Thread Matteo Fasiolo
Dear Rcpp developer, I have experienced intermittent crashes of some of my Rcpp function and I managed to reduce it to the following. I build a package using Rcpp.package.skeleton(), I delete all the files in the R and src folder, and I include in the src folder 2 files: ### exper.cpp #inc

Re: [Rcpp-devel] Comparison of R and rcpp for backsolve

2014-06-27 Thread Matteo Fasiolo
Hi Hao, from what I understand Armadillo doesn't have a forward or back-solver. In any case it's pretty easy to create one, for example you can have a look here: https://github.com/mfasiolo/mvnfast/blob/master/src/mahaCpp.cpp Have a nice weekend, Matteo On Sat, Jun 28, 2014 at 12:25 AM, Hao

Re: [Rcpp-devel] C++11 in Windows R package

2014-06-11 Thread Matteo Fasiolo
8.php which is much faster than the current version. Hopefully the package will now work on all platforms! Thanks, Matteo On Mon, Jun 9, 2014 at 8:02 PM, Dirk Eddelbuettel wrote: > > On 9 June 2014 at 17:45, Matteo Fasiolo wrote: > | Hi Dirk > | > | > | > | Saw t

Re: [Rcpp-devel] C++11 in Windows R package

2014-06-09 Thread Matteo Fasiolo
Hi Dirk > > Saw that -- mvnfast looks quite interesting with OpenMP-based RNG! > | > Yes, using a single header parallel RNG, which is compatible with C++11 random distributions made all the work much easier! The C++11 part is creating lots of problems, though. > > Yes. For the two (smaller)

Re: [Rcpp-devel] C++11 in Windows R package

2014-06-09 Thread Matteo Fasiolo
that the flag CXX_STD = CXX11 was not supported by this older windows release? Can I solve this issue by using Depends R(>= something) in Description? Many thanks, Matteo On Tue, Jun 3, 2014 at 6:09 PM, Matteo Fasiolo wrote: > Dirk, > > no problem, in any case I can always get the

Re: [Rcpp-devel] C++11 in Windows R package

2014-06-03 Thread Matteo Fasiolo
fused. Thanks for the clarification. Matteo On Tue, Jun 3, 2014 at 5:57 PM, Dirk Eddelbuettel wrote: > > Matteo, > > On 3 June 2014 at 17:24, Matteo Fasiolo wrote: > | could it be that yesterday the official RccpArmadillo version on CRAN > | was 0.4.300.7.0 (the one with

Re: [Rcpp-devel] C++11 in Windows R package

2014-06-03 Thread Matteo Fasiolo
t; > On 1 June 2014 at 15:37, Matteo Fasiolo wrote: > | Hi Dirk, > | > | thanks for the fix. Both the package created using > | RcppArmadillo.package.skeleton() and my original > | package work on Windows when the new flag is added and the new > RcppArmadillo > | version i

Re: [Rcpp-devel] C++11 in Windows R package

2014-06-01 Thread Matteo Fasiolo
Hi Dirk, thanks for the fix. Both the package created using RcppArmadillo.package.skeleton() and my original package work on Windows when the new flag is added and the new RcppArmadillo version is used. I was a bit surprised to see that they work also on win-builder, which (I guess) links agains

Re: [Rcpp-devel] C++11 in Windows R package

2014-05-29 Thread Matteo Fasiolo
May 2014 at 20:41, Matt D. wrote: > | On 5/28/2014 23:58, Matteo Fasiolo wrote: > | > | Dear Rcpp developers, > | > | I am working on a package which uses Rcpp/RcppArmadillo, OpenMP and > C++11. > | > | Everything works fine under Linux: the package p

Re: [Rcpp-devel] C++11 in Windows R package

2014-05-29 Thread Matteo Fasiolo
un...@lists.r-forge.r-project.org [mailto:rcpp-devel- > | boun...@lists.r-forge.r-project.org] On Behalf Of Dirk Eddelbuettel > | Sent: Thursday, May 29, 2014 9:32 AM > | To: Matteo Fasiolo > | Cc: rcpp-devel@lists.r-forge.r-project.org > | Subject: Re: [Rcpp-devel] C++11 in Wi

Re: [Rcpp-devel] C++11 in Windows R package

2014-05-29 Thread Matteo Fasiolo
Hi Dirk, many thanks for the explanation, it's nice to know what's the problem. I'll check whether there are other toggles I can use to get it to work under Windows. Best, Matteo On Thu, May 29, 2014 at 4:34 PM, Dirk Eddelbuettel wrote: > > Hi Matteo, > > On 2

Re: [Rcpp-devel] C++11 in Windows R package

2014-05-29 Thread Matteo Fasiolo
Hi Dirk, adding PKG_CPPFLAGS = -DWIN32 solved the problem, but I got another bunch of errors (see below). Maybe these are unsupported C++11 features? I think I was getting similar errors when I was compiling my package in Linux, but they were solved after installing gcc 4.8. Matteo * instal

Re: [Rcpp-devel] C++11 in Windows R package

2014-05-29 Thread Matteo Fasiolo
2014 at 1:31 PM, Dirk Eddelbuettel wrote: > > On 29 May 2014 at 12:42, Matteo Fasiolo wrote: > | Hello, > | > | I have tried win-builder on a basic package constructed > | with RcppArmadillo.package.skeleton() and > | adding the line: > | > | CXX_STD = CXX11 > | > | t

Re: [Rcpp-devel] C++11 in Windows R package

2014-05-29 Thread Matteo Fasiolo
such file or directory Does this help? Matteo On Wed, May 28, 2014 at 11:47 PM, Matteo Fasiolo wrote: > Hi Dirk, > > many thanks for the prompt reply. > > Tomorrow I will simplify the package to locate the origin of the bug > (which should > be caused by one of the

Re: [Rcpp-devel] C++11 in Windows R package

2014-05-28 Thread Matteo Fasiolo
Hi Dirk, many thanks for the prompt reply. Tomorrow I will simplify the package to locate the origin of the bug (which should be caused by one of the dependencies I guess). Matteo On Wed, May 28, 2014 at 11:23 PM, Dirk Eddelbuettel wrote: > > Matteo, > > I may have found it. It is not as br

[Rcpp-devel] C++11 in Windows R package

2014-05-28 Thread Matteo Fasiolo
Dear Rcpp developers, I am working on a package which uses Rcpp/RcppArmadillo, OpenMP and C++11. Everything works fine under Linux: the package passes R CMD check --as-cran, while tests and vignettes work fine. I uploaded the package on win-builder, but I k

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-30 Thread Matteo Fasiolo
Hi Mark, many thanks for all the info, I will certainly have a detailed look at what you are doing. I think it would be nice to have a package that uses C++ level parallelism (OpenMP or not) to speed up random number generation at R level. For example: > library("microbenchmark") > library("mvtn

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-28 Thread Matteo Fasiolo
eal, but it might give reasonable and reproducible results. Thanks, Matteo On Mon, Apr 28, 2014 at 9:39 AM, Matt D. wrote: > On 4/28/2014 01:30, Matteo Fasiolo wrote: > >> [...] >> >> >> As I understand, doing things such as: >> >> NumericMatrix out

[Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-27 Thread Matteo Fasiolo
Dear Rcpp developers, I am working on a small package (here ) that should provide efficient tools for the multivariate normal distribution using Rcpp/RcppArmadillo and OpenMP. Creating functions that evaluate the multivariate normal density efficiently was fairly

Re: [Rcpp-devel] Issue with Matrices and Iterators

2013-10-14 Thread Matteo Fasiolo
Hi Ale, maybe I'm wrong but mat(0,_) is not a NumericVector, but a Rcpp::MatrixRow. So your function sum() is being called with arguments of the wront type (the error message is saying that). If instead you select a column mat( _, 0) you have a conversion to a NumericVector. I've encountered the

Re: [Rcpp-devel] Struggling with cppFunction() and clusterExport()

2013-09-26 Thread Matteo Fasiolo
: > > > fun <- auto_function(' double inner_Cpp(double a){ return 1; } ' ) > # this takes a while the first time > > fun( 2 ) > [1] 1 > # this is instant thanks to caching of sourceCpp > > fun( 2 ) > [1] 1 > > Romain > > Le 26/09/13 18:57, Matteo

[Rcpp-devel] Struggling with cppFunction() and clusterExport()

2013-09-26 Thread Matteo Fasiolo
Dear Rcpp developers, I'm trying to parallelize some of my algorithms but I have encountered the following problem: # I have a cppFunction cppFunction(' double inner_Cpp(double a){ return 1; } ') # And an R wrapper around it wrapper_R<- function(input) { inner_Cpp(input) } # And I want to c

Re: [Rcpp-devel] Default value for Rcpp List

2013-08-14 Thread Matteo Fasiolo
The lack of a > default argument definition is then what caused the subsequent error. > > Best, > > J.J. > > On Wed, Aug 14, 2013 at 3:42 AM, Matteo Fasiolo > wrote: > >> Dear Rcpp users, >> >> a very simple question: I have a function that has a R

[Rcpp-devel] Default value for Rcpp List

2013-08-14 Thread Matteo Fasiolo
Dear Rcpp users, a very simple question: I have a function that has a Rcpp::List among its arguments, and I would like to set a default values for that List. Unfortunately this code: cppFunction( ' List myList(List x = List::create(_["a"] = 1, _["b"] = 2)) { return x; } ' ) raises the

[Rcpp-devel] Setting R seed from Cpp (continued)

2013-06-10 Thread Matteo Fasiolo
Hi all, I continued experimenting with setting the R seed from an Rcpp function. While this code works: cppFunction(' List myFun(int n, Function foo) { RNGScope scope; Environment g = Environment::global_env(); Environment::Binding RandomSeed = g[".Random.seed"]; IntegerVector

Re: [Rcpp-devel] Setting the R random seed from Rcpp

2013-06-07 Thread Matteo Fasiolo
Dirk, you are right, intuitively I see that the way I'm doing things doesn't seem very save. The motivation behind my experimentation is that I'm trying to move things from R to C++ in order to avoid that segfault problem that we observed a couple of weeks ago. Probably I'm clinging a bit too muc

Re: [Rcpp-devel] Setting the R random seed from Rcpp

2013-06-07 Thread Matteo Fasiolo
that .Random.Seed is an IntegerVector. Thanks a lot! Matteo On Fri, Jun 7, 2013 at 4:29 PM, Matteo Fasiolo wrote: > Thanks for you replies. > > I need to seed the seed because I'm estimating the likelihood > function in an MCMC algorithm, and I need to use the same random numbers > in

Re: [Rcpp-devel] Setting the R random seed from Rcpp

2013-06-07 Thread Matteo Fasiolo
omeVariable ; > > The Environment::Binding class acts a a proxy class. > > Romain > > > Le 7 juin 2013 à 16:22, Matteo Fasiolo a écrit > : > > > Dear Rcpp experts, > > > > I would like to be able to store the R random seed from a Rcpp > &g

[Rcpp-devel] Setting the R random seed from Rcpp

2013-06-07 Thread Matteo Fasiolo
Dear Rcpp experts, I would like to be able to store the R random seed from a Rcpp function and then reset it. In other words I would like to replicate the following code in Rcpp: savedSeed <- .Random.seed x <- Rfunction(parameters1); .Random.seed <- savedSeed x1 <- Rfunction(parameters2); wher

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-17 Thread Matteo Fasiolo
a CRAN package). I'll email you to ask you the package you where talking about. On Fri, May 17, 2013 at 11:32 AM, Matteo Fasiolo wrote: > Sorry yesterday evening by mistake I sent a message only to Dirk: > > Thanks, you are right I'll try cxxfunction and/or I'll see whether I

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-17 Thread Matteo Fasiolo
Sorry yesterday evening by mistake I sent a message only to Dirk: Thanks, you are right I'll try cxxfunction and/or I'll see whether I can move avoid doing so many calls to C++. For the sake of minimality: this code is enough to have a segfault or to make R stall (at least on my computer): libra

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-16 Thread Matteo Fasiolo
So the error appears when we are creating a RNGScope object AND we are allocating memory repeatedly? So that something like this: library(Rcpp) myFun <- cppFunction('void myFun(){ RNGScope scope; }') N <- 1e6 for (j in 1:N) { res <- myFun( ) } doesn't crash because we are not allocating mem

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-16 Thread Matteo Fasiolo
t; On Thu, May 16, 2013 at 12:38 PM, Kevin Ushey wrote: >> >>> FWIW, I can reproduce the segfault with this example, whether running R >>> as vanilla or not. >>> >>> > sessionInfo() >>> R version 3.0.0 (2013-04-03) >>> Platform: x86_64-app

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-16 Thread Matteo Fasiolo
Thanks for your reply Dirk. Maybe I have found something. Hopefully this is reproducible and simple enough: /* * C++ file "b.cpp" * Just copying the input matrix into A and returning A. */ #include using namespace Rcpp; // [[Rcpp::export]] NumericMatrix myFun(NumericMatrix input, int n){ Num

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-16 Thread Matteo Fasiolo
:: namespace > R::rpois( phi * currState); > > since you don't need the (wonderful!) sugar vectorization. > > On Mon, May 6, 2013 at 2:47 PM, Matteo Fasiolo > wrote: > > Ok, I'll do exactly this and I'll report if I still encounter this > > problem in

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-06 Thread Matteo Fasiolo
Ok, I'll do exactly this and I'll report if I still encounter this problem in simpler programs. Thanks. On Mon, May 6, 2013 at 7:39 PM, Dirk Eddelbuettel wrote: > > On 6 May 2013 at 19:03, Matteo Fasiolo wrote: > | Sorry for the silly question, but since I'm using sour

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-06 Thread Matteo Fasiolo
Thanks for the quick replies! I'm using log() and then exp() on the parameters because this function goes within an optimization routine, so I need it keep the parameters positive. Sorry for the silly question, but since I'm using sourceCpp() too I should't call getRNGstate/putRNGstate, right? I

[Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-06 Thread Matteo Fasiolo
Hi All, I am trying to simulate from the following model: Y_t = Pois( phi * N_t ); N_t = r * N_{t-1} * exp( -N_{t-1}^theta + e_t ) e_t ~ Norm(0, sigma) so I have written a Rcpp function with prototype: genRickerCpp(int days, int nSimul, int nBurn, NumericMatrix params) where: days = length o