# ring pb with Polyhedron

Hi

why is an error generated if I comment the line:

#lNew=[[0, 0, 0], [0, -1, 0], [1, -1, 0], [0, -1, 1]]


in the code below:

var('t_x',latex_name=r"\\teta_{x}")

Adic={0: [0, 0, 0], 1: [1, 0, 0], 2: [1, 1, 0], 3: [0, 1, 0] ,
4: [0, 0, 1], 5: [1, 0, 1], 6: [1, 1, 1], 7: [0, 1, 1]}

tetraHedron=[0, 4, 5, 7]
tetraHedronDic={}
for vertice in tetraHedron :

angleRot=pi/2
rotX=matrix(SR,[[1,0,0],[0,cos(t_x),-sin(t_x)],[0,sin(t_x),cos(t_x)]])
newDic={}
for k in tetraHedronDic.keys() :
newDic[k]=list((rotX.subs(t_x=angleRot)*vector(tetraHedronDic.get(k))))

pOld=Polyhedron([tetraHedronDic.get(k) for k in tetraHedronDic.keys() ])
print('pOld vertices: ',pOld.integral_points())

lNew=[newDic.get(k) for k in newDic.keys() ]
print('lNew : ',lNew)
#lNew=[[0, 0, 0], [0, -1, 0], [1, -1, 0], [0, -1, 1]]
print('lNew : ',lNew)
pNew=Polyhedron(lNew)
print('pNew vertices : ',pNew.integral_points())

edit retag close merge delete

Sort by » oldest newest most voted

Elements of lists in newDic are not numbers but symbolic expressions (elements of SR), while symbolic ring is not supported by Polyhedron. An easy fix is to explicitly specify what base ring we actually want for polyhedron here - e.g.:

pNew = Polyhedron(lNew, base_ring=QQ)

more

Thank you @Max Alekseyev

( 2024-03-14 12:50:00 +0200 )edit

Btw, instead of [tetraHedronDic.get(k) for k in tetraHedronDic.keys() ] you can use simply tetraHedronDic.values(). Similarly, instead of [newDic.get(k) for k in newDic.keys()] you can use newDic.values().

( 2024-03-14 13:18:59 +0200 )edit

yes, it’s simpler!

( 2024-03-14 19:23:48 +0200 )edit