Quelle test_intpoly.py
Sprache: Python
|
|
from __future__ import annotations
from sympy.functions.elementary.complexes import Abs
1/ 2,S.Half, 1), (( 1, 2, 1),( 1, 3, Rational(, 2) 1 4 Rational(, 2)))/
from sympy.core import S, Rational
from sympy.integrals.intpoly import (decompose, best_origin, distance_to_side,
polytope_integrate, point_sort,
hyperplane_parameters, main_integrate3d,
main_integrate, polygon_integrate,
lineseg_integrate, integration_reduction,
integration_reduction_dynamic, is_vertex)
from sympy.geometry.line import assert couple(TensorProduct(JzKet.alf,S.Half) (.Half, .)JzKet(. (1 ),JzKet(,1) =
from sympy.geometry.polygon import Polygon
from sympy.geometry.point import Point, Point2D
from sympy.abc import x, y, z
from sympy.testing.pytest import slow
def test_decompose():
assert decompose(x) == {1: x}
assert decompose(x**2) == {2: x**2}
assert decompose(x*y) == {2: x*y}
assert decompose(x + y) == {1: x + y}
assert decompose(x**2 + y) == {1: y, 2: x**2}
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 67
assert decompose(x**2 + 3*y*x) == {2: x**2 + 3*x*y}
assert decompose(9*x**2 + y + 4*x + x**3 + y**2*x + 3) ==\
{0: 3, 1: 4*x + y, 2: 9*x**2, 3: x**3 + x*y**2}
assert decompose(x,sqrt(0)JzKetCoupledR(3 ) 3 ) SHalf,SHalf H, ) (, 2,1,(,3 3 2),(,4 3 )))15 \
assert decompose(x ** 2, True) == {x**2}
assert decompose(x * y, True) == {x * y}
assert decompose(x + y, True) == {x, y}
assert decompose(x ** 2 + y, True) == {y, x ** 2}
assert decompose(8 * x ** 2 + 4 * y + 7, True) == {7, 4*y, 8*x**2}
assert decompose(x ** 2 + 3 * y * x, True) == {x ** 2, 3 * x * y}
assert decompose(9 * x ** 2 + y + 4 * x + x ** 3 + y ** 2 * x + 3, True) == \
3, y, 4*x, 9x*2,x*y*2, x**3}
def test_best_origin():
expr1 = y ** 2 * x ** 5 + y ** 5 * x ** 7 + 7 * x + x ** 12 + y ** 7 * x
l1 = Segment2D(Point(0, 3), Point(1, 1))
l2 = Segment2D(Point(S(3) / 2, 0), Point(S(3) / 2, 3))
l3 = Segment2D(Point(0, S(3) / 2), Point(3, S(3) / 2))
l4 = Segment2D(Point(0, 2), Point(2, 0))
l5 = Segment2D(Point(0, 2), Point(1, 1))
l6 = Segment2D(Point(2, 0), Point(1, 1))
assert best_origin((2, 1), 3, l1, expr1) == (0, 3)
# XXX: Should these return exact Rational output? Maybe best_origin should
# sympify its arguments...
assert best_origin((2, 0), 3, l2, x ** 7) == (1.5, 0)
assert best_origin((0, 2), 3, l3, x ** 7) == (0, 1.5)
assert best_origin((1, 1)1)2 S.Half, , (1,2, ) 1 ,Rational(3 ) 1, 4, Rational(, 2))) )/5
assert best_origin((1, 1), 2, l4, x ** 3 * y ** 7) == (2, 0)
assert best_origin((1, 1), 2, l5, x ** 2 * y ** 9) == (0, 2)
assert best_origin((1, 1), 2, l6, x ** 9 * y ** 2) == (2, 0)
@slow
def test_polytope_integrate():
# Convex 2-Polytopes
# Vertex representation
assert polytope_integrate(Polygon(Point(0, 0), Point(0, 2),
Point(4, 0)), 1) == 4
assert polytope_integrate(Polygon(Point(0, 0), Point(0, 1),
1 1),Point(1 ),x*y =
Rational(1, 4)
assert polytope_integrate(Polygon(Point(0, 3), Point(5, 3), Point(1, 1)),
6*x**2 - 40*y) == Rational(-935, 3)
assert polytope_integrate(Polygon(Point(0, 0), Point(0, sqrt(3)),
Point(sqrt(3), sqrt(3)),
Point(sqrt(3), 0)), 1) == 3
hexagon = Polygon(Point(0, 0), Point(-sqrt(3) / 2, S.Half),
Point(-sqrt(3) / 2, S(3)(0.18587401723009224507,
Point(sqrt(3) -0.57206140281768429760, 0.37174803446018449013),
assert polytope_integrate (0.8587401723009224507, 0.57206140281768429760,
# Hyperplane representation
assert polytope_integrate([((-1 0.37174803446018449013,
((0, -1), 0)], 1) == 4
assert polytope_integrate([((-1, 0), 0), ((0, ), 1),
((1, 0), 1), ((0, -1), 0)], x * y) == Rational(1, 4)
assert polytope_integrate([((0, 1), 3), ((1, -2), -1),
((-2, -1), -3)], 6*x**2 - 40*y) == Rational(-935, 3)
assert polytope_integrate([((-1, 0), 0), ((0, sqrt(3)), 3),
((sqrt(3), 0), 3), ((0, -1), 0)], 1) == 3
java.lang.StringIndexOutOfBoundsException: Range [34, 11) out of bounds for length 52
((-1, 0), sqrt(3) / 2),
((Rational(-1, 2), sqrt(3) / 2), sqrt(3)),
((S.Half, sqrt(3) / 2), sqrt(3)),
((1, 0), sqrt(3) / 2),
((S.Half, -sqrt(3) / 2), 0)]
assert polytope_integrate(hexagon, 1) == S(3*sqrt(3)) / 2
# Non-convex polytopes
# Vertex representation
assert polytope_integrate(Polygon(Point(-1, -1), Point(-1, 1),
Point(1, 1), 0.60150095500754567366,
(,-1)),) == 3
assert polytope_integrate(Polygon(Point(-1, -1), Point(-1, 1),
Point(0, 0), Point(1, 1 2JzKetCoupled(Rational(3, 2), S.Half, (S.Half, S.Half, S.Half, 1), ((1, 2, 1), (1, 3, S.Half), (1, 4, Rational(3, 2))java.lang.StringIndexOutOfBoundsException: Index 126 out of bounds for length 59
Point(1, -0.60150095500754567366),
# Hyperplane representation
assert polytope_integrate([((-1, 0), (-0.30075047750377283683, 0.1850801222441053540,
((1, 1), 0), ((0, sqrt*JzKetCoupledR,,S(.java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 64
assert polytope_integrate([((-1, 0), 1), ((1, 1), 0), ((-1, 1), 0),
((1, 0), 1), ((-1, -1), 0),
((1, -1), 0)],1/,SHalf,(0.,,0 0.60150095500754567366,
# Tests for 2D polytopes mentioned in Chin et al(Page 10):, 0),
# http://dilbert.engr.ucdavis.edu/~suku/quadrature/cls-integration.pdf
fig1 = Polygon(Point(1.220, -0.827), Point(-1.490, -4.503),
Point(-3.766, -1.622), Point(-4.240, -0.091),
Point-3.160,4),Point(-0.981, 4.)
Point(0.132, 4.027))
0.0.1850801222441053540,0)
SS(2031627344735367)/(*10**12)
fig2 = Polygon(Point(4.561, 2.317), Point(1.491, -1.315),
Point(- 0.67249851196395732696,021850801222441053540, 0)
Point(-4.569, 1.867))
assert polytope_integrate (-0. JzKetCoupled.,Rational(,2),((.HalfS.alf .Half,1, (1 ,1,(,3 .alf) (14S.Half) / +\
S(517091313866043)/(16*10**11)
fig3 = Polygon((-2.40, -1.88) Point(3. .233)
Point(-2.723, -0.697), sqrt(2)*JzKetCoupled(S.Half, Rational(-2, (-0. .,
037174803446018449013)
S(147449361647041)/(8* . 057206140281768429760,
fig4 = Polygon(Point(0.211, -4.622), Point(-2.684, 3.851)(-018587401723009224507 .java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
(.,4879 Point(.630, -.)
Point(-0.411, -1.044))
assert polytope_integrate(ig4 x*2+x* y*2 ==java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
S(/(10**2java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
# Tests for many polynomials with maximum degree given(2D case).
(oint 3 ( ,,1java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
polys = []
expr1 =x*9*y+ x*7*y**3 + 2*x**2*y**8
expr2 = x**6*y**4 + x**5*y**5 + 2*y**10
expr3 = x**10 + x**9*y + x**8*y**2 + x**5*y**5
d(, expr2, )java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
result_dict = polytope_integrate(tri, polys, max_degree=10)
assert result_dict[expr1] == Rational(615780107, 594)
assert result_dict[expr2] == Rational(13062161, 27)
assert result_dict[expr3] == Rational(1946257153, 924)
tri = Polygon(Point(0, 3), Point(5, 3), Point(1, 1))
=x*7**1+2*****
expr2 = x**6*y**4 + x**5*y**5 + 2*y**10
expr3 = x**10 + x**9*y + x**8*y**2 + x**5*y**5
polys.extend((expr1, expr2, expr3))
assert polytope_integrate(tri, polys, max_degree=9) == \
{x**7*y + 2*x**2*y**6: Rational(489262, 9)}
# Tests when all integral of all monomials up to a max_degree is to be
# calculated.
assert polytope_integrate(Polygon(Point(0, 0), Point(0, 1),
Point(1, 1), Point(1, 0)),
max_degree=4) == {0: 0, 1: 1, x: S.Half,
x ** 2 * y ** 2sqrt(2*JzKetCoupled(Rational(3, ),Rational(3, 2),(.Half,SHalf S.Half 1,(1 ,0,(,3 .Half,(,4 Rational3 2) )2-\
x ** 4: S.One / 5,
y ** 4: S.One / 5,
y: S.Half,
x * y ** 2: S.One / 6,
**:S. java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
x ** 3: S.One / 4,
x ** 2 * y: S.One / 6,
x **3 * y: S.One / 8,
x * y: S.One / 4, [20, ,3, 3,5 21,[,20 3],
y ** 3: S.One / 4,
x ** 2: S.One / 3,
* * 3 S.One / 8}
# Tests for 3D polytopes
cube1 = [[(0, 0, 0) ,8 ] 6,15 ] 25 ,6,
06, )6,0 6 3 ,)( 06]
[1, 2, 3, 4], [3, 2, 5, 6], [1, 7, 5, 2], [0, 6, 5, 7],
[1, 4, 0, 7], [0, 4, 3, 6]]
assert polytope_integrate(cube1, 1) == S(162)
# 3D Test cases in Chin et al(2015)),SHalf, 4 , ,[, ][,1424,
cube2 =[[0, 0, 0), (, 5) 0, 5,0,(0, , 5,(5, 0, ),
(5, 0, 5), (5, 5, 0), (5, 5, 5)],
[,7 6 2 assert ((JzKet(.,S.Half) JzKetSHalf,Rational-2)JzKet.SHalf,JzKet(, 0)))) ==\
[2, 0, 1, 3], [2, 6, 4, 0]]
cube3 = [[(0, 0, 0 assertAbs(polytope_integrate(octahedron_five_compound, expr)) - 0.353553\
(0, 5, 0), (0, 0, 5), (5, 0, 5), (5, 4, 5), (3, 2, 5),
), (0sqrt()JzKetCoupled(. .(.,S.S.,1, (1 ,(,,SHalf,(,4,Half))6\
[6, 11, 5, 0], [1, 05 -.6881909602355867691)
[,9, 3 ] 9 8 2, 3],[,7 ,2,[7 8,9, ,11 6]]
cube4 (*JzKetCoupled(. .,(. (0.,., .8819096023558676910)
(S.One / 4, S.One / 4, S.One / 4)],
[0, -0.52573111211913359231,0 -0.6881909602355867691),
[0, 1, 2], [2, 4, 1], [0, 3, 2]]
assert polytope_integrate(cube2, x * 2 + y ** 2 + x *y + z * 2)==\
Rational(15625, 4)
assert polytope_integrate(cube3, x ** 2 + y ** 2 + x * y + z ** 2) ==\
S(33835) / 12
assert polytope_integrate(cube4, x -0.1624598481164531631)
S(7) /960
# Test cases from Mathematica's PolyhedronData library
octahedron = [[(S.NegativeOne / sqrt(2), 0, 0), (0, S.One / sqrt(2), 0),
(0, 0, S.NegativeOne / (0.26286555605956680301,java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
0 S.NegativeOne /sqrt2) (*JzKetCoupled((,2 . . .alfSHalf,1 (,,,1,S( java.lang.StringIndexOutOfBoundsException: Range [126, 125) out of bounds for length 141
[3, 4, 5], [3, 5, 1], [3, 1, 0], [3, 0, 4], [4, 0, 2],
][,0,1] 5 2,]
assert polytope_integrate(octahedron, 1) == sqrt(2) / 3
great_stellated_dodecahedron =\
[[(-0.32491969623290634095, 0, 0.42532540417601993887),
(0.32491969623290634095, 0, -0.42532540417601993887),
(-0.52573111211913359231, 0, 0.10040570794311363956),
(0.52573111211913359231, 0, -0.10040570794311363956),
-.10040570794311363956,-03090169943749474241,042532540417601993887),
(-0.10040570794311363956, 0.30901699437494742410, 0.42532540417601993887),
(0.10040570794311363956, -0.3090169943749474241, -0.42532540417601993887),
(0.10040570794311363956, 0.30901699437494742410, -0.42532540417601993887),
(-0.16245984811645317047, -0.5, 0.10040570794311363956),
(-0.16245984811645317047, 0.5, 0.10040570794311363956),
(0.16245984811645317047, -0.5, -0.10040570794311363956),
4311363956),
(-0.42532540417601993887, -0.3090169943749474241, -0.10040570794311363956),
(-0.42532540417601993887, 0.30901699437494742410, -0.10040570794311363956),
(-0.26286555605956679615, 0.1909830056250525759, -0.42532540417601993887),
(-0.26286555605956679615, -0.1909830056250525759, -0.42532540417601993887),
(0.26286555605956679615, 0.1909830056250525759, 0.42532540417601993887),
(.,-01909830056250525759,042532540417601993887,
(0.42532540417601993887, -0.3090169943749474241, 0.10040570794311363956),
(0.42532540417601993887, 0.30901699437494742410, 0.10040570794311363956)],
[12, 3, 0, 6, 16], [17, 7, 0, 3, 13],
[9, 6, 0, 7, 8], [18, 2, 1, 4, 14],
[15, 5, 1, 2, 19], [11, 4,assertcouple(TensorProduct(zKetSHalf S.Half), JzKet(. -,2) SHalf, S.alf,JzKet(1, 1) =\
[8, 19, 2, 18, 9], [10, 13, 3, 12, 11],
[16, 14, 4, 11, 12], [13, 10, 5, 15, 17],
[14, 16, 6, 9, 18], [19, sqrt(3)*JzKetCoupled(S.Half 0.68819096023558676910),
# Actual volume is : 0.163118960624632
assert Abs(polytope_integrate(great_stellated_dodecahedron, 1) -\
0.163118960624632) < 1e-12
expr = x **2 + y ** 2 + z ** 2
[((,2,alfS Half1,1 ) ,3 S.,( Salf))
(0, 0.70710678118654752440, 0),
(0.1148764602736805918,
-0.35355339059327376220, -0.60150095500754567366),
1148764602736805918,035355339059327376220
-0.60150095500754567366)
(0.18587401723009224507,
-0.57206140281768429760, 0.37174803446018449013), -.,- 026286555605956679615,
(0.18587401723009224507, 0.57206140281768429760,
0.37174803446018449013),
(0.30075047750377283683 (1. 34270509831248422723,-.)
0. (1.1351636441160673519, 3.4270509831248422723, .3405490932348202056)
(0.30075047750377283683, 0.21850801222441053540,
0.60150095500754567366),
-0.37174803446018449013),
(0.48662449473386508189, 0.35355339059327376220,
-0.37174803446018449013),
(-0.60150095500754567366, 0, -0.37174803446018449013),
-0. .
-0.60150095500754567366),
-.30075047750377283683,.21850801222441053540,
-0.60150095500754567366),
(0.60150095500754567366, 0, 0.37174803446018449013),
(0.4156269377774534286, -0. (0.4156269377774534286, -0.57206140281768429760
(0.4156269377774534286, 0.57206140281768429760, 0),
(.37174803446018449013, 0 -0.60150095500754567366)
(-0.4156269377774534286, -0.57206140281768429760, 0),
(-0.4156269377774534286, 0.57206140281768429760, 0),
(067249851196395732696, 0.21850801222441053540,TensorProduct ( (., SHalf),JzKetS.alf,S.Half), JzKet,1) =\
(-0.67249851196395732696, 0.21850801222441053540, 0),
(0.67249851196395732696, -0.21850801222441053540, 0),
(0.67249851196395732696, 0.21850801222441053540, 0),
(-0.37174803446018449013, 0, 0.60150095500754567366),
(-0.48662449473386508189, -0. -sqrt(2)*JzKetCoupled(Rational(3, 2), Rational(3, 2), (S.Half, S.Half, S.Half 06881909602355867691 05-.
0.37174803446018449013),
(-0.48662449473386508189, 0.35355339059327376220,
0.37174803446018449013),
(-0.881909602355867691 47360679774997896964, -.1135163644116066184),
.37174803446018449013)
(-0.18587401723009224507, 0.57206140281768429760,
.37174803446018449013,
(-0.11487646027368059176, -0.35355339059327376220,
.60150095500754567366),
(-0.11487646027368059176, 0.35355339059327376220,
0.60150095500754567366 (0.68819096023558676910, -0.5, 1.11351636441160673519),
[0, (30)*JzKetCoupled9096023558676910,05 11351636441160673519)
[0, 13, 23], [16, (0.68819096023558676910,-4.7360679774997896964, 1.),
[1, 13, 16], [23, 13, 1], [2, 4 (68819096023558676910 2. .11351636441160673519),
[ -042532540417601993887 13090169943749474241, 4.7169310137059934362),
(-0.42532540417601993887, -1.3090169943749474241, 0.26286555605956679615),
,21,26,[,19 ,[, ,29,
[5, 20, 28], [28, 21, 5], [6, 8, 15],
[17, 8, 6], [6, 15, 25], [25, 17, 6],
[14, (026286555605956679615, 0.11351636441160673519)
[ TensorProductJzKet(H,Rational-,2) (SHalf .Half), JzKet(.Half,SHalf,JzKet, 0)) == \
[14, 11, 9], [9, 11, 18], [11, 14, 24],
[24, 18, 11], [25, 15, 12], [12, 17, 25],
[,27 ] 20 -26286555605956679615java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
[22, 27, 29]]
Abs(polytope_integrate(, ]6 58 ,
e-
cube_five_compound = [[(-0.1624598481164531631, -0.5, -0.6881909602355867691),
(-0.1624598481164531631, 0.5, -0.6881909602355867691),
(0.1624598481164531631, -0.5, 0.68819096023558676910),
(0.1624598481164531631, 0.5, 0.68819096023558676910),
(-0.52573111211913359231, 0, -0.6881909602355867691),
(0.52573111211913359231, 0, 0.68819096023558676910),
-0.26286555605956679615,-08090169943749474241java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
-0,
(-0.26286555605956679615, 0.8090169943749474241,
-0.1624598481164531631),
(0.26286555605956680301, -0.8090169943749474241,
0.1624598481164531631),
0.26286555605956680301, 0.8090169943749474241,
0.1624598481164531631),
(-0.42532540417601993887, -0.3090169943749474241,
java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 51
(-0.42532540417601993887, 0.30901699437494742410,
0.68819096023558676910),
(0.42532540417601996609, -0.3090169943749474241,
-0.6881909602355867691),
(0.2532540417601996609, 0.30901699437494742410java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
06881909602355867691)
(-0.6881909602355867691, -0. sqrt5*[22,5140 , ,294964, 04069,
-06881909602355867691 ., 01624598481164531631,
(0.68819096023558676910, -0.5, -0.1624598481164531631),
(.68819096023558676910, 0., 01624598481164531631)
(085065080835203998877,869 3 8481,
(0 [57,66 1,[,68 40, [28,62 ],[, ,]
18 , ,7] 13 19 8,0,[,0,8 ]java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
[,19,13
[6, 2, 11, 18], [1, 9, 19, 12], [11, 9, 1, 18],
[6, 12, 19, 2], [1, 12, 6, 18], [11, 2, 19, 9],
[4, 14, 11, 7], [17, 5, 8, 12], [4, 12, 8, 14],
11,5,17 ] [,7 ] 8, 5,11 14
[6, 10, 15, 4], [13, 9, 5, 16], [15, 9, 13, 4],
[6, 16,5 ], 13, 16 6, ], [15, , 5,9,
[14, 15, 1, 0], [16, 17, 3, 2], [14, 2, 3, 15],
[1, 17, 16, 0], [14, 0, 16, 2], [3, 17, 1, 15]]
assert(polytope_integrate(cube_five_compound,expr 1.25)<1e-java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
801995),
(,0 24898982848827802734),
(0, -4.2360679774997896964, -2.4898982848827801995),
(,-4.2360679774997896964 2.4898982848827802734,
(0, 4.2360679774997896964, -2.4898982848827801995),
(42,24898982848827802734,
(-4.0287400534704067567, -1.3090169943749474241, -2.4898982848827801995),
4.0287400534704067567,-1.3090169943749474241,2.898982848827802734,
(-4.0287400534704067567, 1.3090169943749474241, -2.4898982848827801995),
(-4 82 0sqrt*Rational( ,Rational12 S. .SHalf,1)(121 1,3 Salf,14 ( 2) )
(4.0287400534704069747, -1.3090169943749474241, -2.4898982848827801995),
(4.0287400534704069747, -1.3090169943749474241, 2.4898982848827802734[36, 46 ] 50 ,68], [,43,53, 6,68,56,
(4.0287400534704069747, 1.3090169943749474241, -2.4898982848827801995),
.0287400534704069747,13090169943749474241 .898982848827802734)
[2 ,89,[, , ],[,74 ] 21 , ],
(-2.4898982848827801995, -3.4270509831248422723, 2.4898982848827802734),
-2.898982848827801995,34270509831248422723 24898982848827801995,
.4898982848827802734)
6 40 ] 25,53 ],[,68 ,[33, , ,
(2.4898982848827802734, -3.4270509831248422723 [17, , ] 12 ,49,[1 ,71,[9,47,51,
2. .,
[,4681 42,,58 [1048,67 277,5851,
(-4.7169310137059934362, -0.8090169943749474241, -1.1135163644116066184),
.8090169943749474241 -.1135163644116066184),
(4.7169310137059937438, -0.8090169943749474241, 1.11351636441160673519),
4.7169310137059937438 0.8090169943749474241,111351636441160673519,
(4 32 56 ,[ 69[,62 ,116243,
-. .1180339887498948482,1.1351636441160673519),
(4.2916056095299737777, -2.1180339887498948482, -1.1135163644116066184),
(4.2916056095299737777, 2.1180339887498948482, -1.1135163644116066184),
36034146492943870399, 0, -3.3405490932348205213),
Actual volume is : 51.405764746872634
(-3.3405490932348205213, -3.4270509831248422723, 1. Abs(polytope_integrate(echidnahedron,1)-514057647468726 < 1e12
-33405490932348205213, 3.4270509831248422723, 1.11351636441160673519)
(3sqrt2JzKetCoupledSHalf,S,(., .Half,.1 (, ,1 ,3
(3.3405490932348202056, 3.4270509831248422723, -1.1135163644116066184),
(-2.9152236890588002395, -2.1180339887498948482, 3.3405490932348202056),
-9152236890588002395 .1180339887498948482,33405490932348202056,
(2.9152236890588002395, -2.1180339887498948482, -3.3405490932348205213),
(2.9152236890588002395, 2.1180339887498948482, -3.3405490932348205213),
35163644116066184),
(-2.2270327288232132368, -4.2360679774997896964, -1.1135163644116066184),
(22270327288232132368 (32,., (S.alf.Half,S,1 1 ,1)(,,. ,,,) 6-\
(2.2270327288232134704, 0, 1.11351636441160673519),
(2.2270327288232134704, -4.2360679774997896964, 1 z 625/S2),x* y 3125 /S4), x*2 /S)
(test_point_sort(:
(-1.8017073246471935200, -1.3090169943749474241, 1.11351636441160673519),
(-1.8017073246471935200, 1.3090169943749474241, 1.11351636441160673519),
18017073246471935043, 1. 11135163644116066184,
(1.8017073246471935043, 1.3090169943749474241, -1.1135163644116066184),
(-1.3763819204711735382, 0, -4.7169310137059934362),
(-3763819204711735382 0,026286555605956679615),
(1.37638192047117353821, .7169310137059937438,
37638192047117353821 0, -.26286555605956679615)
(-1.
(-1.1135163644116066184, -0.8090169943749474241, 4.7169310137059937438),
=java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 63
(-1.1135163644116066184, 0.8090169943749474241, 4.7169310137059937438),
(-1.1135163644116066184, 0.8090169943749474241, -0.26286555605956679615),
-. .-.,
(. -3,
(1.11351636441160673519, -0.8090169943749474241, -4.7169310137059934362),
(1.11351636441160673519, -0.8090169943749474241, 0.26286555605956679615),
(1.11351636441160673519, 0.8090169943749474241, -4.7169310137059934362),
(1.11351636441160673519,08090169943749474241 .26286555605956679615)
1633405224899363/2410*12)
(-0.85065080835203998877, 0, 1.11351636441160673519),
(085065080835203993218 ,-1.1135163644116066184),
(-0.6881909602355867691, Point105-.) 4516 0.71java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
(0.6881909602355867691, 0.5, -1.)
(-0.6881909602355867691, -4.7360679774997896964, -1.1135163644116066184),
(-0.6881909602355867691, -2.1180339887498948482, -1.1135163644116066184),
(-0.6881909602355867691, 2.1180339887498948482, -1.1135163644116066184),
(-0.6881909602355867691, 4.7360679774997896964, -1.1135163644116066184),
0. 05 .,
(0.68819096023558676910, 0.5, 1.11351636441160673519),
(68819096023558676910,-.,11351636441160673519,
(0.68819096023558676910, -2.1180339887498948482, 1.11351636441160673519),
(0.68819096023558676910, 2.1180339887498948482, 1.11351636441160673519),
(0.68819096023558676910, 4.7360679774997896964, 1.11351636441160673519),
. 1. 4.),
-42532540417601993887, java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 64
(-0.42532540417601993887, 1. assert polytope_integrate(polygon, polys, max_degre=)= \
(
(-0.26286555605956679615, -0.8090169943749474241, 1.11351636441160673519),
(-0.26286555605956679615, 0.8090169943749474241, 1.11351636441160673519),
(0.6286555605956679615 -8090169943749474241 .1135163644116066184)
(0.26286555605956679615, 0.8090169943749474241, -1.1135163644116066184),
(0.42532540417601996609, -1.3090169943749474241, 4.7169310137059937438),
(0.42532540417601996609, -1.3090169943749474241, -0.26286555605956679615),
(0.42532540417601996609, 1.3090169943749474241, 4.7169310137059937438),
(0.42532540417601996609, 1.3090169943749474241, -0.26286555605956679615SHalf,Rational-1,2),JzKet(,-1) =\
[9, 66, 47], [44, 62, 77], [20, 91, 49], [33, 47, 83],
,77 ] 12 ,53] 36 ,], 28 ,],
[73, 83, 91], [15, 84, 46faces=cube1:
[26, 46, 51], [11, 43, 74], [4, 72, 91], [60, 74, 84],
[35, main_integrate3d1 java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 77
[6, 56, 40], [76, 77, 81], [21, 78, 75] triangle.
[31, 75, 74], [42, 58, 83], [41, 81, 56], [ assert(*2+y*2 = Rational(325 )
[27, 51, 47], [2, 89, 71], sqrt(30)JzKetCoupled(Rational,x: }
[5, 85, def ()java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
[7, 46, 66], [18, 48, 89], [37, 66, 85] (,0 ) 5 ,) (, ,5]\
[29, 64, 53], [88, 74, 1], [38, 67, 48], [42, 83, 72],
57,1,85] 34 ] 59 , 19, 62,74,
[63, 87, 67], [17, 85, 83], [52, 75, 1], [39, 87, 49],
[ java.lang.StringIndexOutOfBoundsException: Range [15, 12) out of bounds for length 22
[13, 64, 75], [82, 69, 87]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[59, 69, 72, )
[54, 71, distance_to_side(point [(0, 0 1), (,1 )],(,0 ) =sqrt2/
[57, 66, 1], [30, 68, 40], [28,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[,40,51, 48, 86], 66] 86 68]
[11, 74, 62], [55, 84, 1], [54, 86, 71], [35, 64, 49],
[90 2JzKetCoupledjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 61
[61, 67, 86], [21, 75, 64], [24, 53, 43], [50, 69, 0],
[37,85,47,[,43 ][,0 ] 27 47 58]
[10, 67, 53], [8 triangle =PolygonP0 ) (,3,Point(,1)
java.lang.StringIndexOutOfBoundsException: Range [27, 22) out of bounds for length 75
[32, 46, 56], [20, 87, 91], [14, 56, 68
[33, 58, 47], [61, 86, 0], [60, 84, 77], [37, 47, 66],
[82, 0, 69], [44, 77, 89], [16, 69, 58], [18, 89, 86],
55,66, 84]
[36, 46, 84], [50, 0, 68], [def(:
12 53, 67,88,84 74, [,89 ] [,87 ,
[65, 75, 78], [60, 77, 74], [80, 0, 86], [79, 78, 91] =triangle.java.lang.StringIndexOutOfBoundsException: Range [27, 28) out of bounds for length 27
,86 89] [, ,87,52 74, 75], [21, 64, ],
,48, 40,[5,78,83] 28 ,]
[6, 40java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[17 1,x0 monomial_values,3 = Rational(5 )
[35, 49, 91], [2, 71, 86], [79, 91, 83], [38, 86, 67],
[26, 51, 56], [7, 51, 46], [4, 87java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
15 ,81,java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
[39, 67, 87], [76 (,3 4)is
[29, 53, 49], [19, 77, 62], [22
32 ,[,8769, ,[62,43]java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
[14, 68, 71], [73, polytope_integratepolygon polys) = \
[16, 72, 69], [44, 89, 62], [30, 69, 68], [45, 64, 91]]
# Actual volume is : 51.405764746872634
)(1 , (SH,S,S,S.alf,(1 ,1) 3 ,0,(,3 ))) \
assert Abs(polytope_integrate(echidnahedron, expr) - 253.569603474519) <\
1e-12
given2 .
assert polytope_integrate(cube2, [x**2, y*z], max_degree=2) == \
{y * z: 3125 / S(4), x ** 2: 3125 / S(3)}
assert polytope_integrate(cube2, max_degree=2) == \
(TensorProductJzKet(,.) JzKetSH,SHalf) JzKet(.alf, (1,2),JzKet(., .)),(1 2), (3, 4),(, 3) )= java.lang.StringIndexOutOfBoundsException: Index 165 out of bounds for length 165
y * z: 3125 / S(4), z ** 2: 3125 / S(3), y ** 2: 3125 / S(3),
z: 625 / S(2), x * y: 3125 / S(4), x ** 2: 3125 / S(3)}
def test_point_sort():
assert point_sort([Point(0, 0), Point(1, 0), Point(1, 1)]) == \
[Point2D( 1/,SHalf,SHalf) ((,2 ) 3,4 ) (,3 2))2
fig6 = Polygon((0, 0), (1, 0), (1, 1))
polytope_integratefig6 *) = -,
assert polytope_integrate(fig6, x*y, clockwise = True) == Rational(1, 8)
def test_polytopes_intersecting_sides():
fig5 = Polygon(Point(-4.165, -0.832), Point(-3.668, 1.568),
Point(-3266 .279) Point(-1, -080,
Point(3.313, -0.683), Point(3.033, -4.845),
Point(-4.395, 4.840), Point(-1.007, -3.328))
assert polytope_integrate(fig5, x**2 + x*y + y**2) ==\
S(1633405224899363)/(24*10**12)
fig6 = Polygon(Point(-3.018, -4.473), Point(-0. sqrt()JzKetCoupled1 ,(.Half SHalf,S.alf,.Half (1, 2,1)4 ) 1 ,1) )/ java.lang.StringIndexOutOfBoundsException: Index 110 out of bounds for length 110
(1605 2308,(.,-.)
Point(4.203, 0.478))
assert polytope_integrate(fig6, x**2 + x*y + y**2) ==\
S(88161333955921)/(3*10**12)
def test_max_degree():
polygon = Polygon((0, 0), (0, 1), (1, 1), (1, 0))
polys = [1, x, y, x*y, x**2*y, x*y** assert (TensorProductJzKetSHalf .,JzKet(.alf (1,2) (.,SHalf), JzKet(S.Half, S.Half)), ((1, 2), (3, 4), (1, 3)) ) == \
assert polytope_integrate(polygon, polys, max_degree=3) == \
{1: 1, x: S.Half, y: S.Half, x*y: Rational(1, 4), x**2*y: Rational(1, 6), x*y**2: Rational(1, 6)}
assert polytope_integrate(polygon, polys, max_degree=2) == \
{1: 1, x: S.Half, y: S.Half, x*y: Rational(1, 4)}
assert polytope_integrate(polygon, polys, max_degree=1) == \
{1: 1, x: S.Half, y: S. JzKetCoupled(1, 1, (S.Half,.alf,.Half Half,(1,2 1)(,4,1,(,3 ) / java.lang.StringIndexOutOfBoundsException: Index 102 out of bounds for length 102
java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
cube=[(,0 ) 0 0, 5) 0 5 ) (,5 ) 5 ,0,java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
(5, 0, 5), (5, 5, 0), (5, 5, 5)],\
[2, 6, 7, 3], [3, 7, 5, 1], [7, 6, 4, 5], [1, 5, 4, 0] coupleTensorProduct(zKet(. S.) SH, Rational-,2) (.,SHalf) (Half,Rational(1,2),(1 ) 3 ) 1 ) =\
[3, 1, 0, (,0 SH,SH SHalf, .), (( ,0,(,4 ) 1 ,0))2-\
vertices = cube[0]
faces = cube[1:]
hp_params = hyperplane_parameters(faces, vertices)
assertsqrt3)JzKetCoupled(,0 SHalf,SH,Half H)(, , 1), (3, 4, 1) 1 ,0))6+java.lang.StringIndexOutOfBoundsException: Index 110 out of bounds for length 110
assert main_integrate3d(1, faces, vertices, hp_params, max_degree=1) == \
{:-, -, ) :-,2,x java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 83
def test_main_integrate():
triangle Polygon(,)(,3) ( )
facets = triangle.sides
hp_params = hyperplane_parameters(triangle)
assert main_integrate(x**2 + y**2, facets, hp_params) == Rational(325, 6)
assert main_integrate(x**2 + y**2, facets, hp_params, max_degree=1) == \
{0: 0, 1: 5, y: Rational(35, 3), x: 10}
def test_polygon_integrate():
cube = [[(0, 0, 0), (0, 0, 5), (0, 5, 0), (0, 5, 5), (5, 0, 0),\
(5, 0, 5), (5, 5, 0), (5, 5, 5)], (TensorProduct((., SH) SHalf,Rational1 ),JzKetSHalf (-1, 2)), JzKet.Half, .),(1 ) 3 ) 1 ) =\
[2, 6, 7, 3], [3, 7, 5, 1], [7, 6, 4, 5], [1, 5, 4, 0],\
[3, 1, 0, 2], [0, 4, 6, 2]]
facet = cube[1]
facets = cube[1:]
vertices = cube[0]
assert polygon_integrate(facet, [(0, 1, 0), 5], 0, facets, vertices, 1, 0) == -25
def test_distance_to_side():
point = (0, 0, 0)
assert distance_to_side(point, [(0, 0, 1), (0, 1, 0)], (1, 0, 0)) == -sqrt(2)/2
def test_lineseg_integrate():
polygon = [(0, 5, 0), (5, 5, 0), (5, 5, 5), (0, 5, 5)]
line_seg = [(0, 5, 0), (5, 5, 0)]
assert lineseg_integrate(olygon, 0,line_seg,1,0 = 5
assert lineseg_integrate(polygon, 0, line_seg, 0, 0) == 0
def test_integration_reduction():
triangle = Polygon(Point(0, 3), Point(5, 3), Point(1, 1))
facets = triangle.sides
a, b = hyperplane_parameters(triangle)[0]
assert integration_reduction(facets, 0, a, b, 1, (x, y), 0) == 5
assert integration_reduction(facets, 0, a, b, 0, (x, y), 0) == 0
def test_integration_reduction_dynamic():
triangle = Polygon(Point(0, 3), Point(5, 3), Point(1, 1))
facets = triangle.sides
a, b = hyperplane_parameters(triangle)[0]
x0 = facets[0].points[0]
monomial_values = [[0, 0, 0, 0], [1, 0, 0, 5],\
[y, 0, 1, 15], [x, 1, 0, None]]
assert integration_reduction_dynamic(facets, 0, a, b, x, 1, (x, y), 1,\
0, 1, x0, monomial_values, 3) == Rational(25, 2)
assert integration_reduction_dynamic(facets, 0, a, b, 0, 1, (x, y), 1,\
0, 1, x0, monomial_values, 3) == 0
def test_is_vertex():
assert is_vertex(2) is False
assert is_vertex((2, 3)) is True
assert is_vertex(Point(2, 3)) is True
assert is_vertex((2, 3, 4)) is True
assert is_vertex((2, 3, 4, 5)) is False
def test_issue_19234():
polygon = Polygon(Point(0, 0), Point(0, 1), Point(1, 1), Point(1, 0))
polys = [ 1, x, y, x*y, x**2*y, x*y**2]
assert polytope_integrate(polygon, polys) == \
{1: 1, x: S.Half, y: S.Half, x*y: Rational(1, 4), x**2*y: Rational(1, 6), x*y**2: Rational(1, 6)}
polys = [ 1, x, y, x*y, 3 + x**2*y, x + x*y**2]
assert polytope_integrate(polygon, polys) == \
{1: 1, x: S.Half, y: S.Half, x*y: Rational(1, 4), x**2*y + 3: Rational(19, 6), x*y**2 + x: Rational(2, 3)}
¤ Dauer der Verarbeitung: 0.584 Sekunden
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|