[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[R] problem with R-mathlib standalone (?)



Hi,

Short story: could somebody with r-mathlib installed on their system
compile and let me know of the output of the tiny C code at the end
of this message please..

Long story: I'm trying to use pgamma() within my C application but 
I'm getting strange results. I have r-mathlib 1.4.1-1, libc6 2.2.4-5,
and gcc 2:2.95.4-9.

Example: here are 3 arbitrary pgamma() calls executed by R:

$ cat gamma.R
pgamma(98, 100, 1)
pgamma(21, 100, 5)
pgamma(2, 100, 69)


$ 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 
--- please have a look at the code and/or try it out; 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);
}


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: