https://github.com/bastistician/polycub
An R package for numerical integration over polygonal domains
https://github.com/bastistician/polycub
numerical-integration polygons r
Last synced: 3 months ago
JSON representation
An R package for numerical integration over polygonal domains
- Host: GitHub
- URL: https://github.com/bastistician/polycub
- Owner: bastistician
- License: gpl-2.0
- Created: 2013-05-07T19:54:39.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2026-02-02T10:14:25.000Z (4 months ago)
- Last Synced: 2026-02-10T10:16:43.882Z (4 months ago)
- Topics: numerical-integration, polygons, r
- Language: R
- Homepage: https://CRAN.R-project.org/package=polyCub
- Size: 577 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
README
# polyCub 
The [R](https://www.R-project.org/) package **polyCub** implements
*cubature* (numerical integration) over *polygonal* domains.
It solves the problem of integrating a continuously differentiable
function f(x,y) over simple closed polygons.
For the special case of a rectangular domain along the axes, the
[**cubature**](https://CRAN.R-project.org/package=cubature)
package is more appropriate (cf.
[`CRAN Task View: Numerical Mathematics`](https://CRAN.R-project.org/view=NumericalMathematics)).
## Installation
You can install
[polyCub from CRAN](https://CRAN.R-project.org/package=polyCub)
via:
```R
install.packages("polyCub")
```
To install the development version from the
[GitHub repository](https://github.com/bastistician/polyCub), use:
```R
## install.packages("remotes")
remotes::install_github("bastistician/polyCub")
```
## Usage
The basic usage is:
```r
library("polyCub")
polyCub(polyregion, f)
```
* `polyregion` represents the integration domain as an object of class
`"owin"` (from **spatstat.geom**), `"gpc.poly"` (from **gpclib**),
`"SpatialPolygons"` (from **sp**), or `"(MULTI)POLYGON"` (from **sf**),
or even as a plain list of lists of vertex coordinates (`"xylist"`).
* `f` is the integrand and needs to take a two-column coordinate matrix
as its first argument.
The `polyCub()` function wraps the implemented cubature methods and
by default calls `polyCub.SV()`, a C-implementation of *product Gauss cubature*.
Directly calling the desired cubature function is preferable,
see the list below.
### Implemented cubature methods
1. `polyCub.SV()`:
General-purpose **product Gauss cubature**
(Sommariva and Vianello, 2007, *BIT Numerical Mathematics*,
)
2. `polyCub.midpoint()`:
Simple **two-dimensional midpoint rule** based on
[**spatstat.geom**](https://CRAN.R-project.org/package=spatstat.geom)`::as.im.function()`
3. `polyCub.iso()`:
Adaptive **cubature for radially symmetric functions**
via line `integrate()` along the polygon boundary
(Meyer and Held, 2014, *The Annals of Applied Statistics*,
, Supplement B, Section 2.4)
For details and illustrations see the `vignette("polyCub")`
in the installed package or
[on CRAN](https://CRAN.R-project.org/package=polyCub/vignettes/polyCub.html).
## Applications
The **polyCub** package evolved from the need to integrate
so-called spatial interaction functions (Gaussian or power-law kernels)
over the observation region of a spatio-temporal point process.
Such epidemic models are implemented in
[**surveillance**](https://CRAN.R-project.org/package=surveillance).
## Feedback
Contributions are welcome!
Please submit suggestions or report bugs at
or via e-mail to `maintainer("polyCub")`.
## License
The **polyCub** package is free and open source software, licensed under the GPLv2.