[R] problem with R-mathlib standalone

Berkan Eskikaya berkan at runtime-collective.com
Fri May 24 02:47:47 CEST 2002


Hi,

I'm trying to use pgamma() within my C application but I'm 
getting strange results. I have a Debian system with r-mathlib 
1.4.1-1 and gcc 2:2.95.4-9.

Here are 3 example pgamma() calls executed by R:

$ R -q --vanilla < gamma.R 
> pgamma(98, 100, 1)
[1] 0.4333105
> pgamma(21, 100, 5)
[1] 0.7002453
> pgamma(2, 100, 69)
[1] 0.9997046
> 

and here is what the small C program below produces with the 
same calls:

$ ./gtest
pgamma(98, 100, 1) = 0.433311
pgamma(21, 100, 5) = 0.000000
pgamma(2, 100, 69) = 0.000000

As you can see, pgamma(98, 100, 1) returns the same value as 
from within R, but not the other two calls.

Maybe I'm doing something extremely silly and not seeing it 
--- any suggestions greatly appreciated.

Cheers,

Berkan


Here's the C code:       

// gtest.c
// gcc -Wall -g gtest.c gtest -I/usr/lib/R/include -lRmath -lm
#include <stdio.h>
#define MATHLIB_STANDALONE
#include <Rmath.h>

int main (int argc, char *argv[])
{

  double res1, res2, res3;

  res1 = pgamma(98, 100, 1, 1, 0);
  res2 = pgamma(21, 100, 5, 1, 0);
  res3 = pgamma(2, 100, 69, 1, 0);

  printf ("pgamma(98, 100, 1) = %f\n\
           pgamma(21, 100, 5) = %f\n\
           pgamma(2, 100, 69) = %f\n", res1, res2, res3);

  exit(0);
}

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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