[Rcpp-devel] Rcpp bug with rgamma

Dirk Eddelbuettel edd at debian.org
Sun Oct 3 16:36:28 CEST 2010


A standalone program linked against libRmath (the R stats functions compiled
into their own library) works:

#define MATHLIB_STANDALONE 1
#include <Rmath.h>

int
main(int argc, char** argv)
{
    int i;
    set_seed(123, 456);
    for (i=0; i<10; i++) {
	printf(" %d rgamma(1,1) %f\n", i, rgamma(1,1));
    }
    return 0;
}

edd at max:~$ gcc -o /tmp/colin /tmp/colin.c -lRmath -lm
edd at max:~$ /tmp/colin 
 0 rgamma(1,1) 0.314001
 1 rgamma(1,1) 1.498724
 2 rgamma(1,1) 0.154940
 3 rgamma(1,1) 0.053388
 4 rgamma(1,1) 0.404130
 5 rgamma(1,1) 0.167460
 6 rgamma(1,1) 0.260743
 7 rgamma(1,1) 3.204146
 8 rgamma(1,1) 0.271189
 9 rgamma(1,1) 1.129695
edd at max:~$ 

So the ball in our court.  Rcpp must be defining something that upsets the
inner loops in rgamma.

Dirk

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


More information about the Rcpp-devel mailing list