Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,17 @@
from copy import copy
from warnings import warn

from sage.misc.lazy_import import lazy_import
lazy_import('sage.combinat.posets.posets', 'FinitePoset')
from sage.arith.misc import GCD as gcd
from sage.arith.functions import lcm
from sage.combinat.posets.posets import FinitePoset
from sage.geometry.point_collection import PointCollection
from sage.geometry.polyhedron.constructor import Polyhedron
from sage.geometry.hasse_diagram import lattice_from_incidences
lazy_import('sage.geometry.hasse_diagram', 'lattice_from_incidences')
from sage.geometry.toric_lattice import (ToricLattice, is_ToricLattice,
is_ToricLatticeQuotient)
from sage.geometry.toric_plotter import ToricPlotter, label_list
lazy_import('sage.geometry.toric_plotter', ['ToricPlotter', 'label_list'])
from sage.geometry.relative_interior import RelativeInterior
from sage.graphs.digraph import DiGraph
from sage.matrix.constructor import matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.special import column_matrix
Expand All @@ -229,11 +229,10 @@
from sage.rings.rational_field import QQ
from sage.structure.all import SageObject, parent
from sage.structure.richcmp import richcmp_method, richcmp
from sage.geometry.integral_points import parallelotope_points
lazy_import('sage.geometry.integral_points', 'parallelotope_points')
from sage.geometry.convex_set import ConvexSet_closed
import sage.geometry.abc

from sage.misc.lazy_import import lazy_import
from sage.features import PythonModule
lazy_import('ppl', ['C_Polyhedron', 'Generator_System', 'Constraint_System',
'Linear_Expression', 'Poly_Con_Relation'],
Expand Down Expand Up @@ -627,10 +626,21 @@ def try_base_extend(ring):
# If we don't have a lattice element, try successively
# less-desirable ambient spaces until (as a last resort) we
# attempt a numerical representation.
from sage.rings.qqbar import AA
from sage.rings.real_mpfr import RR
rings = [QQ]
try:
from sage.rings.qqbar import AA
except ImportError:
pass
else:
rings.append(AA)
try:
from sage.rings.real_mpfr import RR
except ImportError:
pass
else:
rings.append(RR)

for ring in [QQ, AA, RR]:
for ring in rings:
p = try_base_extend(ring)
if p is not None:
return p
Expand Down Expand Up @@ -1103,7 +1113,7 @@ def plot(self, **options):
EXAMPLES::

sage: quadrant = Cone([(1,0), (0,1)])
sage: quadrant.plot() # needs sage.plot
sage: quadrant.plot() # needs sage.plot sage.symbolic
Graphics object consisting of 9 graphics primitives
"""
tp = ToricPlotter(options, self.lattice().degree(), self.rays())
Expand Down Expand Up @@ -2618,6 +2628,7 @@ def ConeFace(atoms, facets):
else:
# Get face lattice as a sublattice of the ambient one
allowed_indices = frozenset(self._ambient_ray_indices)
from sage.graphs.digraph import DiGraph
L = DiGraph()
origin = \
self._ambient._face_lattice_function().bottom()
Expand Down Expand Up @@ -3270,11 +3281,12 @@ def is_isomorphic(self, other):

We check that :issue:`18613` is fixed::

sage: # needs sage.graphs sage.groups
sage: K = cones.trivial(0)
sage: K.is_isomorphic(K) # needs sage.graphs
sage: K.is_isomorphic(K)
True
sage: K = cones.trivial(1)
sage: K.is_isomorphic(K) # needs sage.graphs
sage: K.is_isomorphic(K)
True
sage: K = cones.trivial(2)
sage: K.is_isomorphic(K)
Expand Down Expand Up @@ -3498,7 +3510,7 @@ def plot(self, **options):
EXAMPLES::

sage: quadrant = Cone([(1,0), (0,1)])
sage: quadrant.plot() # needs sage.plot
sage: quadrant.plot() # needs sage.plot sage.symbolic
Graphics object consisting of 9 graphics primitives
"""
# What to do with 3-d cones in 5-d? Use some projection method?
Expand Down
15 changes: 8 additions & 7 deletions src/sage/geometry/fan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.graphs sage.combinat
# sage.doctest: needs sage.graphs sage.combinat
r"""
Rational polyhedral fans

Expand Down Expand Up @@ -241,18 +241,18 @@
import sage.geometry.abc

from sage.structure.richcmp import richcmp_method, richcmp
from sage.combinat.combination import Combinations
from sage.combinat.posets.posets import FinitePoset
from sage.misc.lazy_import import lazy_import
lazy_import('sage.combinat.combination', 'Combinations')
lazy_import('sage.combinat.posets.posets', 'FinitePoset')
from sage.geometry.cone import (_ambient_space_point,
Cone,
ConvexRationalPolyhedralCone,
IntegralRayCollection,
normalize_rays)
from sage.geometry.hasse_diagram import lattice_from_incidences
lazy_import('sage.geometry.hasse_diagram', 'lattice_from_incidences')
from sage.geometry.point_collection import PointCollection
from sage.geometry.toric_lattice import ToricLattice, is_ToricLattice
from sage.geometry.toric_plotter import ToricPlotter
from sage.graphs.digraph import DiGraph
lazy_import('sage.geometry.toric_plotter', 'ToricPlotter')
from sage.matrix.constructor import matrix
from sage.misc.cachefunc import cached_method
from sage.misc.timing import walltime
Expand Down Expand Up @@ -1397,7 +1397,7 @@ def _compute_cone_lattice(self):
not even need to check if it is complete::

sage: fan = toric_varieties.P1xP1().fan() # needs palp
sage: fan.cone_lattice() # indirect doctest # needs palp
sage: fan.cone_lattice() # indirect doctest # needs palp
Finite lattice containing 10 elements with distinguished linear extension

These 10 elements are: 1 origin, 4 rays, 4 generating cones, 1 fan.
Expand Down Expand Up @@ -1467,6 +1467,7 @@ def FanFace(rays, cones):
else:
# For general fans we will "merge" face lattices of generating
# cones.
from sage.graphs.digraph import DiGraph
L = DiGraph()
face_to_rays = {} # face |---> (indices of fan rays)
rays_to_index = {} # (indices of fan rays) |---> face index
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/fan_morphism.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.graphs, sage.combinat
# sage.doctest: needs sage.combinat sage.graphs
r"""
Morphisms between toric lattices compatible with fans

Expand Down Expand Up @@ -85,8 +85,6 @@
from sage.matrix.special import identity_matrix
from sage.structure.element import is_Matrix
from sage.misc.cachefunc import cached_method
from sage.misc.latex import latex
from sage.misc.misc import walltime
from sage.misc.misc_c import prod
from sage.modules.free_module_morphism import FreeModuleMorphism
from sage.rings.infinity import Infinity
Expand Down Expand Up @@ -505,6 +503,7 @@ def _latex_(self):
0 & 1
\end{array}\right) : \Sigma^{2} \to \Sigma^{2}
"""
from sage.misc.latex import latex
return (r"%s : %s \to %s" % (latex(self.matrix()),
latex(self.domain_fan()), latex(self.codomain_fan())))

Expand Down
24 changes: 14 additions & 10 deletions src/sage/geometry/hyperplane_arrangement/arrangement.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,10 +1009,10 @@ def cocharacteristic_polynomial(self):
EXAMPLES::

sage: A = hyperplane_arrangements.coordinate(2)
sage: A.cocharacteristic_polynomial()
sage: A.cocharacteristic_polynomial() # needs sage.graphs
z^2 + 2*z + 1
sage: B = hyperplane_arrangements.braid(3)
sage: B.cocharacteristic_polynomial()
sage: B.cocharacteristic_polynomial() # needs sage.graphs
2*z^3 + 3*z^2 + z

TESTS::
Expand Down Expand Up @@ -1059,26 +1059,26 @@ def primitive_eulerian_polynomial(self):
EXAMPLES::

sage: A = hyperplane_arrangements.coordinate(2)
sage: A.primitive_eulerian_polynomial()
sage: A.primitive_eulerian_polynomial() # needs sage.graphs
z^2
sage: B = hyperplane_arrangements.braid(3)
sage: B.primitive_eulerian_polynomial()
sage: B.primitive_eulerian_polynomial() # needs sage.graphs
z^2 + z

sage: H = hyperplane_arrangements.Shi(['B',2]).cone()
sage: H.is_simplicial()
False
sage: H.primitive_eulerian_polynomial()
sage: H.primitive_eulerian_polynomial() # needs sage.graphs
z^3 + 11*z^2 + 4*z

sage: H = hyperplane_arrangements.graphical(graphs.CycleGraph(4))
sage: H.primitive_eulerian_polynomial()
sage: H.primitive_eulerian_polynomial() # needs sage.graphs
z^3 + 3*z^2 - z

We verify Example 2.4 in [BHS2023]_ for `k = 2,3,4,5`::

sage: R.<x,y> = HyperplaneArrangements(QQ)
sage: for k in range(2,6):
sage: for k in range(2,6): # needs sage.graphs
....: H = R([x+j*y for j in range(k)])
....: H.primitive_eulerian_polynomial()
z^2
Expand All @@ -1088,6 +1088,7 @@ def primitive_eulerian_polynomial(self):

We verify Equation (4) in [BHS2023]_ on some examples::

sage: # needs sage.graphs
sage: R.<x> = ZZ[]
sage: Arr = [hyperplane_arrangements.braid(n) for n in range(2,6)]
sage: all(R(A.cocharacteristic_polynomial()(1/(x-1)) * (x-1)^A.dimension())
Expand All @@ -1096,18 +1097,19 @@ def primitive_eulerian_polynomial(self):

We compute types `H_3` and `F_4` in Table 1 of [BHS2023]_::

sage: # needs sage.libs.gap
sage: W = CoxeterGroup(['H',3], implementation="matrix")
sage: A = HyperplaneArrangements(W.base_ring(), tuple(f'x{s}' for s in range(W.rank())))
sage: H = A([[0] + list(r) for r in W.positive_roots()])
sage: H.is_simplicial()
sage: H.is_simplicial() # needs sage.graphs
True
sage: H.primitive_eulerian_polynomial()
z^3 + 28*z^2 + 16*z

sage: W = CoxeterGroup(['F',4], implementation="permutation")
sage: A = HyperplaneArrangements(QQ, tuple(f'x{s}' for s in range(W.rank())))
sage: H = A([[0] + list(r) for r in W.positive_roots()])
sage: H.primitive_eulerian_polynomial() # long time
sage: H.primitive_eulerian_polynomial() # long time # needs sage.graphs
z^4 + 116*z^3 + 220*z^2 + 48*z

We verify Proposition 2.5 in [BHS2023]_ on the braid arrangement
Expand All @@ -1116,14 +1118,16 @@ def primitive_eulerian_polynomial(self):
sage: B = [hyperplane_arrangements.braid(k) for k in range(2,6)]
sage: all(H.is_simplicial() for H in B)
True
sage: all(c > 0 for H in B for c in H.primitive_eulerian_polynomial().coefficients())
sage: all(c > 0 for H in B # needs sage.graphs
....: for c in H.primitive_eulerian_polynomial().coefficients())
True

We verify Example 9.4 in [BHS2023]_ showing a hyperplane arrangement
whose primitive Eulerian polynomial does not have real roots (in
general, the graphical arrangement of a cycle graph corresponds
to the arrangements in Example 9.4)::

sage: # needs sage.graphs
sage: H = hyperplane_arrangements.graphical(graphs.CycleGraph(5))
sage: pep = H.primitive_eulerian_polynomial(); pep
z^4 + 6*z^3 - 4*z^2 + z
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperplane_arrangement/check_freeness.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.libs.singular
# sage.doctest: needs sage.libs.singular
r"""
Helper Functions For Freeness Of Hyperplane Arrangements

Expand Down
35 changes: 21 additions & 14 deletions src/sage/geometry/hyperplane_arrangement/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.graphs.graph_generators import graphs
from sage.arith.misc import binomial
from sage.geometry.hyperplane_arrangement.arrangement import HyperplaneArrangements
from sage.matrix.constructor import matrix, random_matrix
from sage.misc.misc_c import prod
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring import polygen
from sage.rings.rational_field import QQ
from sage.rings.semirings.non_negative_integer_semiring import NN
from sage.misc.misc_c import prod

from sage.combinat.combinat import stirling_number2
from sage.combinat.root_system.cartan_type import CartanType
from sage.combinat.root_system.root_system import RootSystem
from sage.arith.misc import binomial
from sage.rings.polynomial.polynomial_ring import polygen

from sage.geometry.hyperplane_arrangement.arrangement import HyperplaneArrangements


def make_parent(base_ring, dimension, names=None):
Expand Down Expand Up @@ -93,9 +87,11 @@ def braid(self, n, K=QQ, names=None):
sage: hyperplane_arrangements.braid(4) # needs sage.graphs
Arrangement of 6 hyperplanes of dimension 4 and rank 3
"""
from sage.graphs.graph_generators import graphs

x = polygen(QQ, 'x')
A = self.graphical(graphs.CompleteGraph(n), K, names=names)
charpoly = prod(x-i for i in range(n))
charpoly = prod(x - i for i in range(n))
A.characteristic_polynomial.set_cache(charpoly)
return A

Expand Down Expand Up @@ -278,10 +274,11 @@ def Coxeter(self, data, K=QQ, names=None):
If the Cartan type is not crystallographic, the Coxeter arrangement
is not implemented yet::

sage: hyperplane_arrangements.Coxeter("H3")
sage: hyperplane_arrangements.Coxeter("H3") # needs sage.libs.gap
Traceback (most recent call last):
...
NotImplementedError: Coxeter arrangements are not implemented for non crystallographic Cartan types
NotImplementedError: Coxeter arrangements are not implemented
for non crystallographic Cartan types

The characteristic polynomial is pre-computed using the results
of Terao, see [Ath2000]_::
Expand All @@ -290,7 +287,10 @@ def Coxeter(self, data, K=QQ, names=None):
sage: hyperplane_arrangements.Coxeter("A3").characteristic_polynomial()
x^3 - 6*x^2 + 11*x - 6
"""
from sage.combinat.root_system.cartan_type import CartanType
from sage.combinat.root_system.root_system import RootSystem
from sage.combinat.root_system.weyl_group import WeylGroup

if data in NN:
cartan_type = CartanType(["A", data - 1])
else:
Expand Down Expand Up @@ -492,6 +492,8 @@ def Ish(self, n, K=QQ, names=None):

- [AR2012]_
"""
from sage.combinat.combinat import stirling_number2

H = make_parent(K, n, names)
x = H.gens()
hyperplanes = []
Expand Down Expand Up @@ -541,7 +543,7 @@ def IshB(self, n, K=QQ, names=None):
Hyperplane t0 + 0*t1 + 0,
Hyperplane t0 + 0*t1 + 1,
Hyperplane t0 + t1 + 0)
sage: a.cone().is_free()
sage: a.cone().is_free() # needs sage.libs.singular
True

.. PLOT::
Expand Down Expand Up @@ -664,6 +666,8 @@ def semiorder(self, n, K=QQ, names=None):
sage: h.characteristic_polynomial() # long time
x^5 - 20*x^4 + 180*x^3 - 790*x^2 + 1380*x
"""
from sage.combinat.combinat import stirling_number2

H = make_parent(K, n, names)
x = H.gens()
hyperplanes = []
Expand Down Expand Up @@ -778,6 +782,9 @@ def Shi(self, data, K=QQ, names=None, m=1):
sage: h.characteristic_polynomial()
x^3 - 54*x^2 + 972*x - 5832
"""
from sage.combinat.root_system.cartan_type import CartanType
from sage.combinat.root_system.root_system import RootSystem

if data in NN:
cartan_type = CartanType(["A", data - 1])
else:
Expand Down
3 changes: 2 additions & 1 deletion src/sage/geometry/hyperplane_arrangement/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
lazy_import("sage.plot.text", "text")
lazy_import("sage.plot.point", "point")
lazy_import("sage.plot.plot", "parametric_plot")
from sage.symbolic.ring import SR


def plot(hyperplane_arrangement, **kwds):
Expand Down Expand Up @@ -423,6 +422,7 @@ def plot_hyperplane(hyperplane, **kwds):
elif hyperplane.dimension() == 1: # a line in the plane
pnt = hyperplane.point()
w = hyperplane.linear_part().matrix()
from sage.symbolic.ring import SR
t = SR.var('t')
if ranges_set:
if isinstance(ranges, (list, tuple)):
Expand All @@ -443,6 +443,7 @@ def plot_hyperplane(hyperplane, **kwds):
elif hyperplane.dimension() == 2: # a plane in 3-space
pnt = hyperplane.point()
w = hyperplane.linear_part().matrix()
from sage.symbolic.ring import SR
s, t = SR.var('s t')
if ranges_set:
if isinstance(ranges, (list, tuple)):
Expand Down
Loading