-
-
Notifications
You must be signed in to change notification settings - Fork 655
Open
Description
I have a 3-polytoe in R4 where R is some special algebraic field (see below). When trying to compute the volume(measure='induced')
, the following error appears:
sage: F2.volume(measure='induced')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
...
AttributeError: 'sage.rings.number_field.number_field_morphisms.NumberFieldEmbedding' object has no attribute 'im_gens'
To reproduce the error:
sage: x = var('x')
....: R2.<sqrt2> = NumberField(x^2 - 2, embedding=AA(2).sqrt())
....: R3.<sqrt3> = NumberField(x^2 - 3, embedding=AA(3).sqrt())
....: R5.<sqrt5> = NumberField(x^2 - 5, embedding=AA(5).sqrt())
....: R = R2.composite_fields(R3)[0].composite_fields(R5)[0]
....: R.rename('special algebraic field')
....: R.random_element().sqrt()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
...
AttributeError: 'sage.rings.number_field.number_field_morphisms.NumberFieldEmbedding' object has no attribute 'im_gens'
So it is not a bug in Polyhedron. However, to avoid this error in Polyhedron, I suggest the following changes in Polyhedron.volume(measure='induced')
Adet = (A.matrix().transpose() * A.matrix()).det()
- return self.affine_hull_projection(orthogonal=True).volume(measure='ambient', engine=engine, **kwds) / sqrt(Adet)
+ try:
+ return self.affine_hull_projection(orthogonal=True).volume(measure='ambient', engine=engine, **kwds) / sqrt(Adet)
+ except:
+ return self.affine_hull_projection(orthogonal=True).volume(measure='ambient', engine=engine, **kwds) / sqrt(AA(Adet))
elif measure == 'induced_rational':
Depends on #3889
CC: @jplab @kliem @videlec @tscrim @mkoeppe
Component: geometry
Keywords: polytope, volume, square root, sqrt
Issue created by migration from https://trac.sagemath.org/ticket/30772