Dear R users, i would like to transform the following function from R-code to C-code and call it from R in order to speed up the computation because in my other functions this function is called many times.
`dgcpois` <- function(z, lambda1, lambda2) { `f1` <- function(alpha, lambda1, lambda2) return(exp(log(lambda1) * (alpha - 1) - lambda2 * lgamma(alpha))) `f2` <- function(lambda1, lambda2) return(integrate(f1, lower=1, upper=Inf, lambda1=lambda1, lambda2=lambda2)$value) return(exp(log(lambda1) * z - lambda2 * lgamma(z + 1) - log(f2(lambda1=lambda1, lambda2=lambda2)))) } In order to do this i read for example dgamma.c or dpois.c but for my it seems rather cryptic and so i would like get some advice in writing the c-function. First of all i think i cannot call the integrate r-function from c so i have to use the internal c-function of integrate here? Thanks, Andreas -- ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.