Redding, Matthew
2008-Sep-16 23:37 UTC
[R] lsoda( linking to GMP for big numbers from C code)
Hi R used with C-code experts, I had a look at the archives and did not find anything on this, so hopefully I am not doubling up. I have previously used the following approach where I needed some very small/large numbers (using Brobdingnag): surfacewithdiff <- function(t, y, p) { const=p["const"] kay =p["kay"] psii=p["psii"] m1=p["m1"] m2=p["m2"] M=p["M"] N=p["N"] T=p["T"] bexp<-as.brob((const*(psii-m1*y[1]-m2*M/N))/T) yd1<-as.numeric((kay*exp(bexp))/(kay*t*exp(bexp)+1)- (kay^2*t*exp(2*bexp))/(kay*t*exp(bexp)+1)^2) list(c(yd1)) } Now I guess this could be done with gmp. Now I use this stuff in the function that odesolve's lsoda refers to, and I have found that my approach using pure R code is not fast enough, so I need to convert my function to C code. This is all on a windows system. Is it possible to access gmp or Brobdingnag dll's from the C code? Or do I need to install and compile the gmp library itself? I see that the gmp library for R contains the dll. How do I access this from the C-code? I see that according to the manual on extending R, there are a heap of header file available for R functionality, but since gmp is a contrib package, I guess it is not amongst them. Kind regards, Matt Redding ********************************DISCLAIMER******************...{{dropped:12}}