search for: mathlib_standalone

Displaying 20 results from an estimated 24 matches for "mathlib_standalone".

2012 Jan 27
2
The following code (using rgamma) hangs
...ith the R math library hangs. Note that set_seed is defined as taking two unsigned int arguments, so 0's are valid arguments. I'm guessing that since 0 is as low as an unsigned integer can go, it represents some kind of edge case. ################################################ #define MATHLIB_STANDALONE #include <Rmath.h> int main(void) { set_seed(0, 0); rgamma(1, 1); } ################################################ If I add the definitions of `get_seed` and `set_seed` from `src/nmath/standalone/sunif.c` to my code, then the hang disappears. ######################################...
2004 Apr 14
2
again question about nmath/standalone
...test1.c:18: warning: previous implicit declaration of `Allocate_Memory_2D' test1.c:55: warning: `Allocate_Memory_2D' was previously implicitly declared to return `int' /usr/bin/ld: cannot find -lRmath collect2: ld returned 1 exit status "test1.c" code is as follow: #define MATHLIB_STANDALONE #include <math.h> #include <stdlib.h> #include <stdio.h> #include </usr/local/lib/R/include/Rmath.h> main() { double **x, **y, **x1, **y1, valin; int i,j,I,J; I=3; J=3; x=Allocate_Memory_2D( I, J, x1); y=Allocate_Memory_2D( I, J, y1); FILE *in_file;...
2006 Mar 03
1
Fwd: Re: calling R's library using C
...bud:/tmp> tail -6 nmtest.c > > main() > > { > > /* something to force the library to be included */ > > qnorm(0.7, 0.0, 1.0, 0, 0); > > return 0; > > } > > edd at basebud:/tmp> > > > > The key is the > > #define MATHLIB_STANDALONE 1 > > in the R example. Once you add that before the #include for Rmath.h, you're > > fine: > > edd at basebud:/tmp> gcc -o globetrotter globetrotter.c -lm -lRmath > > edd at basebud:/tmp> ./globetrotter > > 0.040160 > > 0.040160 > > edd at baseb...
2004 Apr 14
1
question about /nmath/standalone
...7 [Numerical analysis subroutines], page 61 as fromthat header file.) The library is not built automatically when R is installed, but can be built in the directory 'src/nmath/standalone? in the R sources: see the file 'README? there. To use thecode in your own C program include #define MATHLIB_STANDALONE #include <Rmath.h> and link against '-lRmath?. There is an example file 'test.c?." Have I to do: gcc -lRmath test.c ? In this case I receive this message: > /usr/bin/ld: cannot find -lRmath > collect2: ld returned 1 exit status " what should I do? or I do somethi...
2004 Mar 19
1
R_qsort_int_I() error
Hi, I want to use R_qsort_int_I() in my C function, but getting the following error. It looks like there is a conflict between Rmath.h, which I use to generate random numbers, and R_ext/Boolean.h I would appreciate any help to fix this problem. gcc -ansi -g -o Gibbs gibbs.c subroutines.o rand.o vector.o -lm -lRmath -llapack -lblas -lfrtbegin -lg2c -lm -shared-libgcc In file included from
2006 Mar 02
1
calling R's library using C
Hi, Thanks, everyone for all the help! So, here is my calling function in C (called test.c): #include<stdio.h> #include<stdlib.h> #include<Rmath.h> int main(void) { printf("%f \n",pchisq(2.,7., 1, 0)); printf("%f \n",pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } I compile using: gcc test.c -I/usr/lib/R/include
2005 Aug 11
1
include C functions from nmath in my own C functions
...port D_LIBRARY_PATH=$LD_LIBRARY_PATH:$/home/zhliu/Backup/R-2.0.1/src/nmath/standalon e " However, when I try to run the following codes by the command "gcc test.c -lRmath" on Linux Fedora Core 2, /***********************************************/ /* file name test.c */ #define MATHLIB_STANDALONE 1 #include <Rmath.h> int main() { /* something to force the library to be included */ qnorm(0.7, 0.0, 1.0, 0, 0); return 0; } /**************************************************/ the compiler gives me the following error message. It seems definitions of some R functions can...
2005 Aug 11
1
include C functions from nmath in my own C functions
...I also add the directories containg libRmath.so to LD_LIBRARY_PATH by using command "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$/home/zhliu/Backup/R-2.0.1/src/nmath/standalon e " However, when I try to run the following codes. /***********************************************/ #define MATHLIB_STANDALONE 1 #include <Rmath.h> int main() { /* something to force the library to be included */ qnorm(0.7, 0.0, 1.0, 0, 0); return 0; } /**************************************************/ It gives me the following error message. It seems definitions of some R functions can not be found in t...
2005 Feb 11
1
Re: [R-SIG-Mac] Bug running pbinom() in R-GUI?
...s part of a sequence that may need user interaction). Index: src/nmath/pbeta.c =================================================================== --- src/nmath/pbeta.c (revision 33148) +++ src/nmath/pbeta.c (working copy) @@ -139,7 +139,8 @@ for(i= 1; i <= n; i++) { #ifndef MATHLIB_STANDALONE /* for now, at least allow this:*/ - R_CheckUserInterrupt(); + if ((i&1023)==1) + R_CheckUserInterrupt(); #endif if (p1 <= 1 && term / eps <= finsum) break; after this patch...
2002 Jan 14
1
trouble using R Mathlib as standalone
...yntax should be in this case? Thanks in advance. Please cc me; I'm not on the list. Sincerely, Faheem Mitha. ************************************************************************ #include "lattice.hh" #include "mh.hh" #define MATHLIB_STANDALONE #include <Rmath.h> /* random sample from proposal distribution q-gibbs */ double q_gibbs_rand(Cube& cube, double& beta, vector<double>::size_type& t) { vector<double> ctr = ((0.5)*(cube.down + cube.up)).coord; vector<double>::size_type hsize = ctr.size();...
2004 Apr 22
2
Urgent:again question about nmath/standalone
...implicit declaration test1.c:21: warning: previous implicit declaration of `Allocate_Memory_2D' test1.c:58: warning: `Allocate_Memory_2D' was previously implicitly declared to return `int' /usr/bin/ld: cannot find -lRmath collect2: ld returned 1 exit status "test1.c" #define MATHLIB_STANDALONE #include <math.h> #include <stdlib.h> #include <stdio.h> #include </usr/local/lib/R/include/Rmath.h> main() { double **x, **y, **x1, **y1, valin; int i,j,I,J; I=3; J=3; x=Allocate_Memory_2D( I, J, x1); y=Allocate_Memory_2D( I, J, y1); FILE *in_file;...
2020 Jun 02
0
R standalone Rmath library - missing log1pexp(), rnbeta()
...er file, and not in > ?libRmath.dylib?. > There is a comment in the header, '// <-- > ../nmath/plogis.c? next to log1pexp(). That file, > ?plogis.c? contains a function ?Rf_log1pexp?, which is how > the function would be named without '#define > MATHLIB_STANDALONE?. > The other function, 'rnbeta()? doesn?t appear in any of > the source files in the ?nmath? folder. Maybe a file is > missing. Incidentally (not being an Apple costumer), I've seen this; as I'm the one who had added log1pexp() (8 years ago), I've been intr...
2023 Feb 16
0
User-defined RNG with the standalone Rmath library
...ean that we cannot use a user-defined random number generator with "a shared library or DLL", which suggests using static linking. Question: are there any good examples of re-defining unif_rand() with the standalone Rmath library? As an example, we could set up a file test.c: #define MATHLIB_STANDALONE #include <Rmath.h> #include <stdio.h> double unif_rand(void) { return 0.5; } int main() { printf("%f\n", unif_rand()); printf("%f\n", runif(0, 1)); return 0; } If we compile using -static, then we get the correct result (two values of 0.5):...
2002 May 24
0
problem with R-mathlib standalone
...hin 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,...
2006 Mar 24
0
using R's optimization routines from C
...is that right? I also wanted to use some of the functions in the Rmath library in the same program. However, when I use it, I get an error in the header files. which says essentially that there are some redeclarations in the header (specifically, Rboolean, TRUE and FALSE). I have defined #define MATHLIB_STANDALONE 1 is there anyother preprocessor directive I should give and define other things needed? Btw, I am using FC-4 and RHEl-4 and I do have the latest versions of R Version 2.2.1 (2005-12-20 r36812). I am happy to provide my test programs that I am using to test my usage of the above optimization r...
2008 Oct 31
0
R help for invoking nmmin()
My code is as follows: #include <iostream> #include <cmath> using namespace std; #define MATHLIB_STANDALONE 1 extern "C" { #include "R_ext/Applic.h" } typedef struct TT{ double ** tempX; double * tempY; int tempN; } TT, *MM; double fn(int N, double * beta, void * ex){ double total = 0; int i = 0,j = 0; double * betaFn = new double[N]; MM tmp = (MM)ex; for(i = 0; i < N;...
2008 Jan 02
1
setting the seed in standalone code using Rlib
...et.seed", R_GlobalEnv)?) Thanks much. -- David Faden, dfaden at iastate.edu AIM: pitulx -- #include <assert.h> #include <R.h> #include <Rinternals.h> #include <R_ext/Parse.h> #include <Rmath.h> #include <stdio.h> void setSeed(unsigned int seed) { #ifndef MATHLIB_STANDALONE /** * Following the example in Writing R Extensions 5.10 */ char cmd[256]; SEXP cmdSexp; SEXP cmdExp; ParseStatus status; sprintf(cmd, "set.seed(%u)", seed); PROTECT(cmdSexp = allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, mkChar(cmd)); cmdExp = PROTECT(R_...
2000 Dec 08
1
nmath bug (PR#762)
...1, Redhat 7 i386), and have detected a problem with rpois. Basically, the rejection step in rpois can result in an infinite loop. The simplest thing I can come up with that reproduces the problem is the following. #include <stdio.h> #include <math.h> #include <time.h> #define MATHLIB_STANDALONE #include "Mathlib.h" int main() { double d; set_seed(976259805U,2968367341U); for(long k=0; k<10; k++) { for(long k=0; k<10000; k++) d = rpois(4500); for(long k=0; k<250000; k++) d = rpois(100); printf("."); fflush(stdout); } } Fro me this pr...
2006 Dec 18
1
Rmath: R libraries from C on Mac OS X
...rhaps to a step by step guide for a _beginner_ on how to install this and then how to compile the C code) would be most appreciated.For completeness, here is my C code (adapted from code that works fine on Linux): #include<string.h> #include<stdio.h> #include<stdlib.h> #define MATHLIB_STANDALONE 1 #include "/Library/Frameworks/R.framework/Versions/2.3/Resources/include/i386/Rmath.h" int main(int argc, char *argv[]) { printf("hello world\n"); printf("%lf\n",rnorm(5,2)); return(0); } Many thanks in advance. Murali
2004 Jun 22
1
R mathlib
Hello, dear R experts! I run R on Debian 'sarge' platform. There is 'r-mathlib' package in Debian distribution, which is described as: $ dpkg --status r-mathlib ... This packages provides the libRmath shared and static libraries which can be called from standalone C or C++ code. Well, I use runif() function in test_runif.c: #include <Rmath.h> main() { // ...