You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this blog post, using R, I calculate an integral on a polyhedron by decomposing this polyhedron into simplices.
The Julia code below is my attempt to reproduce this R example with the help of your package. But I don't find the same result. However, using another method for the calculation of the integrals, I find the same result as R.
So I believe there's a mistake or a bug in your package, or there's something bad in my code but I don't see what.
using Polyhedra
using MiniQhull # to use delaunay()using GrundmannMoeller
# define the polyhedron Ax <= b and get its vertices# see https://laustep.github.io/stlahblog/posts/integralPolyhedron.html
A = [
-100;
100;
0-10;
110;
00-1;
111.0
]
b = [5; 4; 5; 3; 10; 6.0]
H =hrep(A, b)
P =polyhedron(H)
pts =points(P)
vertices =collect(pts)
# decompose the polyhedron into simplices (tetrahedra)
indices =delaunay(hcat(vertices...))
_, ntetrahedra =size(indices)
tetrahedra =Vector{Vector{Vector{Float64}}}(undef, ntetrahedra)
for j in1:ntetrahedra
ids =vec(indices[:, j])
tetrahedra[j] = vertices[ids]
end# function to be integratedfunctionf(x)
return x[1] + x[2]*x[3]
end# integral is sum of integrals over the tetrahedra
scheme =grundmann_moeller(Float64, Val(3), 5)
integral =0for i in1:ntetrahedra
global integral = integral +integrate(f, scheme, tetrahedra[i])
end
integral
# -11879.7# should be -5358.3
The text was updated successfully, but these errors were encountered:
Hello,
In this blog post, using R, I calculate an integral on a polyhedron by decomposing this polyhedron into simplices.
The Julia code below is my attempt to reproduce this R example with the help of your package. But I don't find the same result. However, using another method for the calculation of the integrals, I find the same result as R.
So I believe there's a mistake or a bug in your package, or there's something bad in my code but I don't see what.
The text was updated successfully, but these errors were encountered: