Rev 31272 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
The Debian package r-mathlib provides the library of standalone mathematicalfunctions from the GNU R sources.Please consult the header file Rmath.h for the full list of availablefunctions, and see section "The R API", subection "Using these functions inyour own code" from the "Writing R Extensions" manual (available in pdf, htmland info in the r-doc-pdf, r-doc-html and r-doc-info packages, respectively)for their usage.A simple example is provided in the file test.c which, on a Debian system,can be built as$ gcc test.c -o test_mathlib -lRmath -lmRunning 'ldd test_mathlib' can verify that the library is linked dynamically.The full README for the source directory R-$VERSION/src/nmath/standalone isincluded below; you can safely ignore the part about building this library asit provided by the Debian r-mathlib package.-- Dirk Eddelbuettel <edd@debian.org> Thu, 13 Jun 2002 21:27:38 -0500----- file R-$VERSION/src/nmath/standalone/README below ---------------------If you have not yet made R, under Unix you must first configure R, andunder Windows you need to set up almost all the tools to make R andthen run (cd .../src/gnuwin32/fixed; make).Under Unix, making in this directory will make standalone librarieslibRmath.a and libRmath.so. `make static' and `make shared' makejust one of them.Under Windows, use make -f Makefile.win. This makes Rmath.dll withimport library libRmath.a.NB: certain compilers are unable to do compile-time IEEE-754arithmetic and so cannot compile mlutils.c. The known example isSun's cc. Use gcc for mlutils.c (or the whole library).To use the routines in your own C or C++ programs, include#define MATHLIB_STANDALONE#include <Rmath.h>and link against -lRmath. The example file test.c does nothinguseful, but is provided to test the process. Note that you willprobably not be able to run it unless you add the directory containinglibRmath.so to the LD_LIBRARY_PATH.A little care is needed to use the random-number routines. You willneed to supply the uniform random number generatordouble unif_rand(void)or use the one supplied (and with a shared library or DLL you willhave to use the one supplied, which is the Marsaglia-multicarry withan entry pointset_seed(unsigned int, unsigned int)to set its seeds).The facilties to change the normal random number generator areavailable through the constant N01_kind. This takes valuesfrom the enumeration typetypedef enum {KINDERMAN_RAMAGE,AHRENS_DIETER,BOX_MULLER} N01type;(and USER_NORM is not available).There is full access to R's handling of NaNs, Inf and -Inf via specialversions of the macros and functionsISNAN, R_FINITE, R_log, R_pow and R_pow_diand (extern) constants R_PosInf, R_NegInf and NA_REAL. Thesefacilities work best on IEEE 754 machines, but are available for all.There is no support for R's notion of missing values, in particularnot for NA_INTEGER nor the distinction between NA and NaN for doubles.