expint/ 0000755 0001762 0000144 00000000000 14326736253 011574 5 ustar ligges users expint/NAMESPACE 0000644 0001762 0000144 00000000233 14220225222 012767 0 ustar ligges users ### C code
useDynLib(expint, .registration = TRUE, .fixes = "C_")
### Exports
export(expint, expint_E1, expint_E2, expint_En, expint_Ei)
export(gammainc)
expint/man/ 0000755 0001762 0000144 00000000000 14220225222 012325 5 ustar ligges users expint/man/gammainc.Rd 0000644 0001762 0000144 00000003521 14220225222 014371 0 ustar ligges users \name{gammainc}
\alias{gammainc}
\alias{gamma_inc}
\alias{IncompleteGammaFunction}
\title{Incomplete Gamma Function}
\description{
The incomplete gamma function \eqn{\Gamma(a, x)}{G(a, x)}.
}
\usage{
gammainc(a, x)
}
\arguments{
\item{a}{vector of real numbers.}
\item{x}{vector of non-negative real numbers.}
}
\details{
As defined in 6.5.3 of Abramowitz and Stegun (1972), the incomplete
gamma function is
\deqn{
\Gamma(a, x) = \int_x^\infty t^{a-1} e^{-t}\, dt}{%
G(a, x) = int_x^Inf t^(a - 1) exp(-t) dt}
for \eqn{a} real and \eqn{x \ge 0}.
For non-negative values of \eqn{a}, we have
\deqn{
\Gamma(a, x) = \Gamma(a) (1 - P(a, x)),}{%
G(a, x) = Gamma(a) (1 - P(a, x)),}
where \eqn{\Gamma(a)}{Gamma(a)} is the function implemented
by \R's \code{\link{gamma}()} and \eqn{P(a, x)}{P(a, x)} is the
cumulative distribution function of the gamma distribution (with scale
equal to one) implemented by \R's \code{\link{pgamma}()}.
Also, \eqn{\Gamma(0, x) = E_1(x)}{G(0, x) = E_1(x)}, \eqn{x > 0},
where \eqn{E_1(x)} is the exponential integral implemented in
\code{\link{expint}}.
}
\value{
The value of the incomplete gamma function.
Invalid arguments will result in return value \code{NaN}, with a warning.
}
\note{
The C implementation is based on code from the GNU Software Library
\url{https://www.gnu.org/software/gsl/}.
}
\references{
Abramowitz, M. and Stegun, I. A. (1972), \emph{Handbook of Mathematical
Functions}, Dover.
}
\seealso{
\code{\link{expint}}
}
\author{
Vincent Goulet \email{vincent.goulet@act.ulaval.ca}
}
\examples{
## a > 0
x <- c(0.2, 2.5, 5, 8, 10)
a <- 1.2
gammainc(a, x)
gamma(a) * pgamma(x, a, 1, lower = FALSE) # same
## a = 0
a <- 0
gammainc(a, x)
expint(x) # same
## a < 0
a <- c(-0.25, -1.2, -2)
sapply(a, gammainc, x = x)
}
\keyword{math}
expint/man/expint-package.Rd 0000644 0001762 0000144 00000003006 14220225222 015513 0 ustar ligges users \name{expint-package}
\alias{expint-package}
\docType{package}
\title{
\packageTitle{expint}
}
\description{
The exponential integrals \eqn{E_1(x)}, \eqn{E_2(x)}, \eqn{E_n(x)} and
\eqn{Ei(x)}, and the incomplete gamma function \eqn{\Gamma(a, x)}{G(a,
x)} that is defined for negative values of its first argument.
}
\details{
The exponential integral
\deqn{
E_1(x) = \int_x^\infty \frac{e^{-t}}{t}\, dt}{%
E_1(x) = int_x^Inf exp(-t)/t dt}
and the incomplete gamma function
\deqn{
\Gamma(a, x) = \int_x^\infty t^{a-1} e^{-t}\, dt}{%
G(a, x) = int_x^Inf t^(a-1) exp(-t) dt}
are closely related functions that arise in various fields of
mathematics.
\pkg{expint} is a small package that provides \R functions to compute
the exponential integral and the incomplete gamma function.
Most conveniently for \R package developers, the package also gives
access to the underlying C workhorses through an API; see the package
vignette for instructions.
The C routines are adapted versions of those of the GNU Scientific
Library \url{https://www.gnu.org/software/gsl/}.
}
\seealso{
\code{\link{expint}} for the exponential integral family of functions.
\code{\link{gammainc}} for the incomplete gamma function.
\code{vignette("expint")} for a detailed presentation of the package.
}
\author{
Vincent Goulet \email{vincent.goulet@act.ulaval.ca}
}
\references{
Abramowitz, M. and Stegun, I. A. (1972), \emph{Handbook of Mathematical
Functions}, Dover.
}
\keyword{package}
\keyword{math}
expint/man/expint.Rd 0000644 0001762 0000144 00000006475 14220225222 014137 0 ustar ligges users \name{expint}
\alias{expint}
\alias{expint_E1}
\alias{expint_E2}
\alias{expint_En}
\alias{expint_Ei}
\alias{ExponentialIntegral}
\title{Exponential Integral}
\description{
The exponential integrals \eqn{E_1(x)}, \eqn{E_2(x)}, \eqn{E_n(x)} and
\eqn{Ei}.
}
\usage{
expint(x, order = 1L, scale = FALSE)
expint_E1(x, scale = FALSE)
expint_E2(x, scale = FALSE)
expint_En(x, order, scale = FALSE)
expint_Ei(x, scale = FALSE)
}
\arguments{
\item{x}{vector of real numbers.}
\item{order}{vector of non-negative integers; see Details.}
\item{scale}{logical; when \code{TRUE} the result will be scaled by
\eqn{e^x}{exp(x)}.}
}
\details{
Abramowitz and Stegun (1972) first define the exponential
integral as
\deqn{
E_1(x) = \int_x^\infty \frac{e^{-t}}{t}\, dt, \quad x \ne 0.}{%
E_1(x) = int_x^Inf exp(-t)/t dt, x != 0.}
An alternative definition (to be understood in terms of the Cauchy
principal value due to the singularity of the integrand at zero) is
\deqn{
\mathrm{Ei}(x) = - \int_{-x}^\infty \frac{e^{-t}}{t}\, dt
= - E_1(-x).}{%
Ei(x) = - int_{-x}^Inf exp(-t)/t dt = - E_1(-x).}
The exponential integral can also generalized to \code{order} \eqn{n} as
\deqn{
E_n(x) = \int_1^\infty \frac{e^{-xt}}{t^n}\, dt,}{%
E_n(x) = int_1^Inf exp(-xt)/t^n dt,}
for \eqn{n = 0, 1, 2, \dots}; \eqn{x} a real number (non-negative when
\eqn{n > 2}).
The following relation holds:
\deqn{
E_n(x) = x^{n - 1} \Gamma(1 - n, x),}{%
E_n(x) = x^(n-1) G(1-n, x),}
where \eqn{\Gamma(a, x)}{G(a, x)} is the incomplete gamma function
implemented in \code{\link{gammainc}}.
By definition, \eqn{E_0(x) = x^{-1} e^{-x}}{E_0(x) = exp(-x)/x},
\eqn{x \ne 0}{x != 0}.
Function \code{expint} is vectorized in both \code{x} and
\code{order}, whereas function \code{expint_En} expects a single value
for \code{order} and will only use the first value if \code{order} is
a vector.
Non-integer values of \code{order} will be silently coerced to
integers using truncation towards zero.
}
\value{
The value of the exponential integral.
Invalid arguments will result in return value \code{NaN}, with a warning.
}
\note{
The C implementation is based on code from the GNU Software Library
\url{https://www.gnu.org/software/gsl/}.
}
\references{
Abramowitz, M. and Stegun, I. A. (1972), \emph{Handbook of Mathematical
Functions}, Dover.
}
\seealso{
\code{\link{gammainc}}
}
\author{
Vincent Goulet \email{vincent.goulet@act.ulaval.ca}
}
\examples{
## See section 5.3 of Abramowitz and Stegun
expint(1.275, order = 1:10)
expint(10, order = 1:10) * 1e5
expint(c(1.275, 10), order = c(1, 2))
expint_E1(1.275) # same as above
expint_E2(10) # same as above
## Figure 5.1 of Abramowitz and Stegun
curve(expint_Ei, xlim = c(0, 1.6), ylim = c(-3.9, 3.9),
ylab = "y")
abline(h = 0)
curve(expint_E1, add = TRUE)
x <- 1.5
text(x, c(expint_Ei(x), expint_E1(x)),
expression(Ei(x), E[1](x)),
adj = c(0.5, -0.5))
## Figure 5.2 of Abramowitz and Stegun
plot(NA, xlim = c(-1.6, 1.6), ylim = c(0, 1),
xlab = "x", ylab = expression(E[n](x)))
n <- c(10, 5, 3, 2, 1, 0)
for (order in n)
curve(expint_En(x, order), add = TRUE)
x <- c(0.1, 0.15, 0.25, 0.35, 0.5, 0.7)
text(x, expint(x, n), paste("n =", n),
adj = c(-0.2, -0.5))
}
\keyword{math}
expint/DESCRIPTION 0000644 0001762 0000144 00000004247 14326736252 013310 0 ustar ligges users Package: expint
Type: Package
Title: Exponential Integral and Incomplete Gamma Function
Version: 0.1-8
Date: 2022-10-28
Authors@R: c(person("Vincent", "Goulet", role = c("cre", "aut"),
email = "vincent.goulet@act.ulaval.ca"),
person("Gerard", "Jungman", role = "aut",
email = "jungman@lanl.gov",
comment = "Original GSL code"),
person("Brian", "Gough", role = "aut",
email = "jungman@lanl.gov",
comment = "Original GSL code"),
person("Jeffrey A.", "Ryan", role = "aut",
email = "jeff.a.ryan@gmail.com",
comment = "Package API"),
person("Robert", "Gentleman", role = "aut",
comment = "Parts of the R to C interface"),
person("Ross", "Ihaka", role = "aut",
comment = "Parts of the R to C interface"),
person(family = "R Core Team", role = "aut",
comment = "Parts of the R to C interface"),
person(family = "R Foundation", role = "aut",
comment = "Parts of the R to C interface"))
Description: The exponential integrals E_1(x), E_2(x), E_n(x) and
Ei(x), and the incomplete gamma function G(a, x) defined for
negative values of its first argument. The package also gives easy
access to the underlying C routines through an API; see the package
vignette for details. A test package included in sub-directory
example_API provides an implementation. C routines derived from the
GNU Scientific Library .
Depends: R (>= 3.3.0)
License: GPL (>= 2)
URL: https://gitlab.com/vigou3/expint
BugReports: https://gitlab.com/vigou3/expint/-/issues
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2022-10-28 05:58:03 UTC; vincent
Author: Vincent Goulet [cre, aut],
Gerard Jungman [aut] (Original GSL code),
Brian Gough [aut] (Original GSL code),
Jeffrey A. Ryan [aut] (Package API),
Robert Gentleman [aut] (Parts of the R to C interface),
Ross Ihaka [aut] (Parts of the R to C interface),
R Core Team [aut] (Parts of the R to C interface),
R Foundation [aut] (Parts of the R to C interface)
Maintainer: Vincent Goulet
Repository: CRAN
Date/Publication: 2022-10-28 11:27:38 UTC
expint/build/ 0000755 0001762 0000144 00000000000 14326667553 012701 5 ustar ligges users expint/build/vignette.rds 0000644 0001762 0000144 00000000312 14326667553 015234 0 ustar ligges users b```b`abd`b2 1#'J(++G()&&[&3 a8DXԱ%ifwI-HK î?}ީE0=(jؠjX2sRad9.nP&c0Gq?gQ~n ݣ9JI,IK+ #4T expint/build/partial.rdb 0000644 0001762 0000144 00000007536 14326667546 015043 0 ustar ligges users kWFV6τd;0&4IM
%NBNItd42*Jrm~ݯ[iÞfg+{2ɽk;5Far@S)=wΆ\q|P4k!{B
şU%~gJk?i 1Éxo
oɊE9WIE}n?[x+`M%E&Jׄ:6}-TW~}h)Pok?,^9N뭍
aSʠD3K
Ci .$몄
t_,$:XTy@V
sD~jFiTꍗ?>+Uw*e"|qO(9/Ū-/
hP99Q$md/釹>uǥtnizܱo8B1.3F1NA:G%( /`Fצ0FF:&B?2Itq0`
~V'#Uip!Z!S6yJc;pdj>z-RtyjݪT7֫#
cл}c