[Rcpp-devel] Rcpp bug with rgamma

Dirk Eddelbuettel edd at debian.org
Sun Oct 3 16:22:45 CEST 2010


On 2 October 2010 at 22:17, Colin Rundel wrote:
| I am working on a project using RcppArmadillo and I've run into an issue with the rgamma function in Rcpp. When calling rgamma the function pegs R's cpu utilization and the process continues to churn forcing me to kill it. I've let things run for around 5 mins with no end in sight.
| 
| I can replicate the problem with the following code:
| 
| library(Rcpp)
| library(inline)
| 
| foo = "return(rgamma(1,1,1));"
| cxxfunction(signature(), foo, plugin = "Rcpp" )()

I can confirm this on Ubuntu 10.04. 

The code for rgamma is pretty simple -- if all args are well we call R's
rgamma n time with argument a and scale:

	return NumericVector( n, ::Rf_rgamma, a, scale ) ;

Changing your test program to 

        foo <- "return(Rcpp::wrap(Rf_rgamma(1,1)));"

so that it calls the function directly also goes astray.  There must now be
something we define or set that sends the R engine over the edge here.

I'll try to take another peak.  Thanks for the bug report! 

Dirk
 

| Other r* functions seem to work with out issue (ie rnorm, rbeta, etc).
| 
| I am using of Rcpp 0.86 on OSX with R 2.11.1. I have not taken the time to look at the Rcpp code to see what the issue might be, but hopefully this is something that is an easy fix.
| 
| -Colin
| 
| 
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list