[R] Segmentation fault using integrate()
Ben Bolker
ben at zoo.ufl.edu
Wed Jan 19 15:40:58 CET 2000
I'm not sure what's going on, but I have had a similar problem, and a
workaround. The following code will fairly reliably crash R:
library(integrate)
besfun <- function(v,minx=1e-99) {
if (all(v==0))
besfun(minx,minx)
else
besselK(sqrt(sum(v^2)),0)
}
sqval <- function(lim) {
print(lim)
4/(2*pi)*adapt(ndim=2,lower=c(0,0),upper=c(lim,lim),minpts=200,maxpts=NULL,functn=besfun,eps=1e-4)$value
#gc()
}
xvec <- seq(0,10,length=101)
sqvec <- sapply(xvec,sqval)
## crashes R
sqvec <- sapply(xvec,sqval)
I think the problem may have to do with cleanup on return from an error:
if I exclude 0 from xvec above, so that I don't get the following warning
messages
Warning message:
Ifail=2, lenwrk was too small. -- fix adapt() !
Check the returned relerr! in: adapt(ndim = 2, lower = c(0, 0), upper
then I don't get the crashes.
The workaround is to call gc() every time after you call integrate() ...
you can see if it works for you.
Ben Bolker
On Tue, 18 Jan 2000, Hubert Wong wrote:
> Hi all,
>
> Running R 0.90.1 on a RH 6.1 system. Installation of the
> integrate_2.1-2 package went smoothly. My code contains a loop
> in which integrate() is called several times in each pass.
> I get a segmentation fault after what seems to be a random number
> of calls to integrate(). Debug output shows:
>
> Program received signal SIGSEGV, Segmentation fault.
> promiseArgs (el=0x40276414, rho=0x402977a4) at eval.c:1018
> 1018 eval.c: No such file or directory.
>
> Does anyone have any idea what's going on? Thanks.
>
> Hubert
>
> ======================================================================
> Hubert Wong Department of Statistics
> E-mail: hubert at stat.ubc.ca University of British Columbia
> ======================================================================
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
>
--
Ben Bolker bolker at zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
318 Carr Hall/Box 118525 tel: (352) 392-5697
Gainesville, FL 32611-8525 fax: (352) 392-3704
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list