[Rd] The following code (using rgamma) hangs

Faheem Mitha faheem at faheem.info
Fri Jan 27 23:14:34 CET 2012



On Fri, 27 Jan 2012, Dirk Eddelbuettel wrote:

> | Dirk also pointed out (in the bug report) that you get the following
> |
> | ##########################################################
> | int main(void)
> | {
> |      set_seed(0, 0);
> |      cout << "one normal " << norm_rand() << endl;
> | }
> | ##########################################################
> |
> | edd at max:/tmp$ g++ -o faheem faheem.cpp -lRmath; ./faheem
> | one normal -inf
>
> Well I actually sent you a complete program of which you showed only an
> incomplete part.  A better quote would have shown all:
>
>  #define MATHLIB_STANDALONE
>  #include <Rmath.h>
>  #include <iostream>
>  using std::cout;
>  using std::endl;
>
>  int main(void) {
>      set_seed(0, 0);
>      cout << "one normal " << norm_rand() << endl;
>  }
>
>
> That does indeed return -Inf on my Ubuntu server.  It works with other seed
> values as does the rgamma which hangs only for value 0 and 0.

Yes, apologies for not including the complete code.

Btw, adding the definitions of `get_seed` and `set_seed` from
| `src/nmath/standalone/sunif.c` fixes the problem here as well.

faheem at orwell[default branch:rev 12]:~/corrmodel/bug$ ./edd one normal 
-1.26974

where previously it was giving -inf.
                                                        Regards, Faheem



More information about the R-devel mailing list