Skip to content

Commit 70df8ae

Browse files
committed
first commit
1 parent 25e0452 commit 70df8ae

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed

.Rbuildignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
^PolyhedralCubature\.Rproj$
2+
^\.Rproj\.user$
3+
^inst/essais$

DESCRIPTION

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Package: PolyhedralCubature
2+
Title: Integration Over Convex Polyhedra
3+
Version: 0.0.0.9000
4+
Authors@R:
5+
person("Stéphane", "Laurent", , "laurent_step@outlook.fr", role = c("aut", "cre"))
6+
Description: What the package does (one paragraph).
7+
License: GPL-3
8+
URL: https://github.com/stla/PolyhedralCubature
9+
BugReports: https://github.com/stla/PolyhedralCubature/issues
10+
Imports:
11+
gmp,
12+
rcdd,
13+
SimplicialCubature,
14+
tessellation
15+
Encoding: UTF-8
16+
RoxygenNote: 7.2.3

NAMESPACE

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated by roxygen2: do not edit by hand
2+

PolyhedralCubature.Rproj

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: No
4+
SaveWorkspace: No
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
14+
15+
AutoAppendNewline: Yes
16+
StripTrailingWhitespace: Yes
17+
LineEndingConversion: Posix
18+
19+
BuildType: Package
20+
PackageUseDevtools: Yes
21+
PackageInstallArgs: --no-multiarch --with-keep.source
22+
PackageRoxygenize: rd,collate,namespace

inst/essais/essai01.R

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
library(rcdd)
2+
library(tessellation)
3+
library(SimplicialCubature)
4+
5+
#' @importFrom rcdd makeH validcdd scdd
6+
#' @importFrom tessellation delaunay getDelaunaySimplicies
7+
#' @importFrom SimplicialCubature adaptIntegrateSimplex
8+
9+
A <- rbind(
10+
c(-1, 0, 0), # -x
11+
c( 1, 0, 0), # x
12+
c( 0,-1, 0), # -y
13+
c( 1, 1, 0), # x+y
14+
c( 0, 0,-1), # -z
15+
c( 1, 1, 1) # x+y+z
16+
)
17+
b <- c(5, 4, 5, 3, 10, 6)
18+
19+
H <- makeH(A, b)
20+
. <- validcdd(H)
21+
22+
V <- scdd(H)[["output"]]
23+
if(any(V[, 1L] != 0) || any(V[, 2L] != 1)) {
24+
stop("Invalid input.")
25+
}
26+
vertices <- V[, -c(1L, 2L)]
27+
28+
dlny <- delaunay(vertices)
29+
simplices <- getDelaunaySimplicies(dlny)
30+
nsimplices <- length(simplices)
31+
32+
# union of simplicies
33+
d <- ncol(A)
34+
S <- array(NA_real_, dim=c(d, d+1L, nsimplices))
35+
for(i in seq_len(nsimplices)) {
36+
S[, , i] <- t(simplices[[i]])
37+
}
38+
39+
# integration
40+
f <- function(x, y, z) {
41+
x + y*z
42+
}
43+
stopifnot(length(formals(f)) == d)
44+
g <- function(v) NULL
45+
bdy <- sprintf(
46+
"f(%s)", paste0(sprintf("v[%d]", 1:d), collapse = ",")
47+
)
48+
body(g) <- parse(text = bdy)
49+
50+
adaptIntegrateSimplex(g, S)
51+
52+

0 commit comments

Comments
 (0)