[R] trouble using R Mathlib as standalone
Faheem Mitha
faheem at email.unc.edu
Tue Jan 15 00:34:19 CET 2002
Hi Dirk,
Thanks for your reply. Also, thanks for taking the trouble to make the
standalone math library into a Debian package. Very thoughtful of you. I'm
willing to bet no other Linux distribution has this as a package.
On Mon, 14 Jan 2002, Dirk Eddelbuettel wrote:
> Faheem> I get two different errors.
> Faheem>
> Faheem> The first one I am completely mystified by.
>
> It is just a warning which goes away if you omit -pedantic. It seems to
> collide with the header from glibc:
OK, but what is the best way of making the warning go away? I would like
to keep -pedantic. Shall I comment out the declation of log1p in Rmath.h
Line 520)? Is that harmless? In any case, I think this qualifies as a
minor bug.
Line 520 is "double log1p(double); /* = log(1+x) {care for small x} */"
> Faheem> The second one clearly has to do with the usage of GetRNGstate() and
> Faheem> PutRNGstate() which are correct for use as entry points into the R
> Faheem> executable but no longer correct for standalone usage.
>
> They do not exist in Rmath.h -- meaning that you cannot call them.
>
> Faheem> The README in the standalone directory said something about using
> Faheem> the uniform random number generator, but gave no examples so I
> Faheem> didn't understand. Can someone tell me what the correct syntax
> Faheem> should be in this case?
>
> Not sure I understand your question. The set_seed() function allows to fix a
> seed so that that subsequent calls will always get the same sequence of
> random deviates. So a simple example which works is
I want my function (q_gibbs_rand) to return a random number with the
appropriate distribution every time I call it, and I don't want the burden
of having to set the seed myself.
I've decided to use u = runif(0,1); instead, which seems to work. It seems
to compile OK, though I haven't tested it. Is this a reasonable
alternative? I don't understand why I need to set the seed for unif_rand()
and not for runif(), though.
> edd at homebud:/tmp> cat fm.cc
> #include <iostream>
> #include <cstdlib>
> #include <cmath>
>
> #define MATHLIB_STANDALONE 1
> #include <Rmath.h>
>
> int main(void)
> {
> for (int i=0; i<3; i++) {
> set_seed(123,456); // no claims that these are good seeds
Don't want to have to do this step...
[snip]
Sincerely, Faheem Mitha.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list