From faheem at faheem.info  Fri Jan 27 23:14:34 2012
From: faheem at faheem.info (Faheem Mitha)
Date: Sat, 28 Jan 2012 03:44:34 +0530 (IST)
Subject: [Rd] The following code (using rgamma) hangs
In-Reply-To: <20259.5072.790261.193341@max.nulle.part>
References: <alpine.DEB.2.00.1201280141080.18502@orwell.homelinux.org>
	<20259.5072.790261.193341@max.nulle.part>
Message-ID: <alpine.DEB.2.00.1201280341430.18502@orwell.homelinux.org>



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



[Rd] The following code (using rgamma) hangs
Faheem Mitha