Hi:
I am writing a C program which need a gamma random
number generator. I download the source file of R and
compile, make it myself. There is a "rgamma.c"
function in the installing directory of
R("/home/zhliu/Backup/R-2.0.1/src/nmath/rgamma.c"). My
question is how to call this function in my own
program which is in another directory. I can not copy
this "rgamma.c" to my working directory and use
#inclucde"rgamma.c" because in the file "rgamma.c", it
includes other header files. Or I can use makefile,
but I do not know how to edit my makefile to do this
job.
A related question is whether are similar .c files
contains the matrix functions(product, invert) in the
nmath library which I can use for my own C program?
Thanks a lot!
liu
Prof Brian Ripley
2005-Feb-22 20:03 UTC
[R] include C functions from nmath in my own C functions
On Tue, 22 Feb 2005, yyan liu wrote:> Hi: > I am writing a C program which need a gamma random > number generator. I download the source file of R and > compile, make it myself. There is a "rgamma.c" > function in the installing directory of > R("/home/zhliu/Backup/R-2.0.1/src/nmath/rgamma.c"). My > question is how to call this function in my own > program which is in another directory. I can not copy > this "rgamma.c" to my working directory and use > #inclucde"rgamma.c" because in the file "rgamma.c", it > includes other header files. Or I can use makefile, > but I do not know how to edit my makefile to do this > job.See src/nmath/standalone/README.> A related question is whether are similar .c files > contains the matrix functions(product, invert) in the > nmath library which I can use for my own C program?No. In general R uses LAPACK (or perhaps LINPACK) for such operations, and so can you. The API for nmath is described in the `Writing R Extensions' manual. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595