sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 481 forks source link

Changing brick polytopes of subword complexes to brick polyhedra #32681

Open DennisJahn opened 3 years ago

DennisJahn commented 3 years ago

generalize the method brick_polytope() of sage.combinat.subword_complex.py to brick_polyhedron() as done in

https://arxiv.org/abs/2103.03715

Depends on #32669

CC: @stumpc5 @jplab @kliem

Component: combinatorics

Keywords: subword complex, brick vector, brick polyhedron, brick polytope

Author: Dennis Jahn

Branch/Commit: u/gh-DennisJahn/changing_brick_polytopes_of_subword_complexes_to_brick_polyhedra @ b3abcc9

Issue created by migration from https://trac.sagemath.org/ticket/32681

DennisJahn commented 3 years ago

Branch: u/gh-DennisJahn/changing_brick_polytopes_of_subword_complexes_to_brick_polyhedra

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

f3b834ere-added brick_polytope() as deprecated method. Examples for brick_polehedron() fixed
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Commit: f3b834e

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from f3b834e to e658d9b

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

e658d9bReplaced brick polytope by brick polyhedron in documentaion. Methods to be changed/rewritten: kappa_preimage() of facets, is_vertex() of facets, brick_fan of subword complex, minkowski_summand of subword complex.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

996a180method is_vertex() for facets rewritten
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from e658d9b to 996a180

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 996a180 to f625039

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

f625039Doc for minkowski_summand() of subword complex and kappa_preimage() of facets
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

24ae7derewritten brick_fan() for subword comlexes. Now correct and generalized to coincide with the normal fan of brick_polyhedron()
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from f625039 to 24ae7de

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 24ae7de to 167f102

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

167f102more details in the doc of upper_root_configuration
mkoeppe commented 3 years ago
comment:9
+        from warnings import warn
+        warn("brick_polytope() is deprecated; brick_polyhedron() is used instead; results are different for non-spherical subword complexes", DeprecationWarning)

better to use deprecation from sage.misc.superseded for this

mkoeppe commented 3 years ago
comment:10

if you install the optional package pynormaliz, you can also do exact computations over number fields, this should probably be a user option

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

12cb089updated files from 32669
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 167f102 to 12cb089

DennisJahn commented 3 years ago
comment:12

Replying to @mkoeppe:

if you install the optional package pynormaliz, you can also do exact computations over number fields, this should probably be a user option

I did install it but keep getting problems with vertices over the universal cyclotomic field:

1.618033988749895? of type <class 'sage.rings.qqbar.AlgebraicReal'> not valid to initialize an element of the universal cyclotomic field

Is there a way to work around this?

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 12cb089 to e011ef5

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

e011ef5used deprecated_function_alias for brick_polytope instead of warn
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

3a5fca1corrected the deprecation number
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from e011ef5 to 3a5fca1

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 3a5fca1 to 6e6864c

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

6e6864cadded missing 'optional - gap 3' flags
kliem commented 3 years ago
comment:17
diff --git a/src/sage/combinat/root_system/reflection_group_real.py b/src/sage/combinat/root_system/reflection_group_real.py
index 91333f0ca5..1fbf87496e 100644
--- a/src/sage/combinat/root_system/reflection_group_real.py
+++ b/src/sage/combinat/root_system/reflection_group_real.py
@@ -706,8 +706,8 @@ class RealReflectionGroup(ComplexReflectionGroup):
             [0, 1, 2]
         """
         return self._index_set_inverse[i]
-    
-    def bruhat_cone(self, x, y, side = 'upper'):
+
+    def bruhat_cone(self, x, y, side='upper', backend='cdd'):
         r"""
         Return the polyhedral cone generated by the set of positive roots ``beta`` where ``s_beta`` is the reflection corresponding to ``beta`` and:

@@ -744,12 +744,16 @@ class RealReflectionGroup(ComplexReflectionGroup):
             raise ValueError("side must be either 'upper' or 'lower'")
         from sage.geometry.polyhedron.constructor import Polyhedron
         if self.is_crystallographic():
-            return Polyhedron(vertices = [[0]*self.rank()], rays = roots, ambient_dim = self.rank())
+            return Polyhedron(vertices = [[0]*self.rank()], rays=roots, ambient_dim=self.rank(), backend=backend)
         else:
-            from warnings import warn
-            warn("Using floating point numbers for roots of unity. This might cause numerical errors!")
-            from sage.rings.real_double import RDF
-            return Polyhedron(vertices = [[0]*self.rank()], rays = roots, ambient_dim = self.rank(), base_ring = RDF)
+            if backend == 'cdd':
+                from warnings import warn
+                warn("Using floating point numbers for roots of unity. This might cause numerical errors!")
+                from sage.rings.real_double import RDF as base_ring
+                backend = 'cdd'
+            else:
+                from sage.rings.qqbar import AA as base_ring
+            return Polyhedron(vertices = [[0]*self.rank()], rays=roots, ambient_dim=self.rank(), base_ring=base_ring, backend=backend)

     class Element(RealReflectionGroupElement, ComplexReflectionGroup.Element):

diff --git a/src/sage/combinat/subword_complex.py b/src/sage/combinat/subword_complex.py
index bbf750b56d..dc64b5882c 100644
--- a/src/sage/combinat/subword_complex.py
+++ b/src/sage/combinat/subword_complex.py
@@ -638,9 +638,9 @@ class SubwordComplexFacet(Simplex, Element):

         - ``coefficients`` -- (optional) a list of coefficients used to
           scale the fundamental weights
-        
+
         - ``sign`` -- (default: ``'positive'``) must be one of the following:
-        
+
           * ``'positive'`` - entries of the extended weight configuration are summed up as they are
           * ``'negative'`` - entries of the extended weight configuration are summed up with a negative sign

@@ -1660,9 +1660,9 @@ class SubwordComplex(UniqueRepresentation, SimplicialComplex):

         - coefficients -- (optional) a list of coefficients used to
           scale the fundamental weights
-        
+
         - ``sign`` -- (default: ``'positive'``) must be one of the following:
-        
+
           * ``'positive'`` - for brick vectors, entries of the extended weight configuration are summed up as they are
           * ``'negative'`` - for brick vectors, entries of the extended weight configuration are summed up with a negative sign

@@ -1690,7 +1690,7 @@ class SubwordComplex(UniqueRepresentation, SimplicialComplex):

     def minkowski_summand(self, i):
         r"""
-        Return the `i` th Minkowski summand of ``self``. The brick polyhedron of ``self`` is the 
+        Return the `i` th Minkowski summand of ``self``. The brick polyhedron of ``self`` is the
         Minkowski sum of its associated Bruhat cone and all Minkowski summands.

         INPUT:
@@ -1720,7 +1720,7 @@ class SubwordComplex(UniqueRepresentation, SimplicialComplex):
             min_sum = [[QQ(CC(v)) for v in F.extended_weight_configuration()[i]] for F in self]
         return Polyhedron(min_sum)

-    def brick_polyhedron(self, coefficients=None, sign='positive'):
+    def brick_polyhedron(self, coefficients=None, sign='positive', backend='cdd'):
         r"""
         Return the brick polyhedron of ``self``.

@@ -1731,9 +1731,9 @@ class SubwordComplex(UniqueRepresentation, SimplicialComplex):

         - coefficients -- (optional) a list of coefficients used to
           scale the fundamental weights
-        
+
         - ``sign`` -- (default: ``'positive'``) must be one of the following:
-        
+
           * ``'positive'`` - entries of the extended weight configuration are summed up as they are.
             The Bruhat cone is taken with a negative sign.
           * ``'negative'`` - entries of the extended weight configuration are summed up with a negative sign.
@@ -1762,29 +1762,32 @@ class SubwordComplex(UniqueRepresentation, SimplicialComplex):
             sage: SC = SubwordComplex(Q,W.w0)                           # optional - gap3
             sage: SC.brick_polyhedron()                                 # optional - gap3
             A 3-dimensional polyhedron in RDF^3 defined as the convex hull of 32 vertices
-            
+
             sage: W = ReflectionGroup(['B',2])                          # optional - gap3
             sage: Q = W.w0.reduced_word()                               # optional - gap3
             sage: SC = SubwordComplex(Q, W.from_reduced_word([1]))      # optional - gap3
             sage: SC.brick_polyhedron()                                 # optional - gap3
             A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices and 2 rays
-            
+
         REFERENCES: [JahStu]_
         """
         BV = self.brick_vectors(coefficients=coefficients, sign=sign)
         G = self.group()
         if sign == 'positive':
-            BC = -G.bruhat_cone(self.pi(), G.demazure_product(self.word()))
+            BC = -G.bruhat_cone(self.pi(), G.demazure_product(self.word()), backend=backend)
         elif sign == 'negative':
-            BC = G.bruhat_cone(self.pi(), G.demazure_product(self.word()))
+            BC = G.bruhat_cone(self.pi(), G.demazure_product(self.word()), backend=backend)
         else:
             raise ValueError("sign must be either 'positive' or 'negative'")
         if G.coxeter_matrix().is_crystallographic():
-            return Polyhedron(BV, ambient_dim = G.rank()) + BC
+            return Polyhedron(BV, ambient_dim=G.rank(), backend=backend) + BC
         else:
-            from sage.rings.real_double import RDF
-            return Polyhedron(BV, ambient_dim = G.rank(), base_ring = RDF) + BC
-    
+            if backend == 'cdd':
+                from sage.rings.real_double import RDF as base_ring
+            else:
+                from sage.rings.qqbar import AA as base_ring
+            return Polyhedron(BV, ambient_dim=G.rank(), base_ring=base_ring, backend=backend) + BC
+
     from sage.misc.superseded import deprecated_function_alias
     brick_polytope = deprecated_function_alias(32681, brick_polyhedron)

The backend keyword is missing anyway and should be added.

In can be documented similar to what is done in src/sage/geometry/polyhedron/library.py.

A general remark: A keyword assignment should not have spaces guarding =: Polyhedron(backend='cdd').

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

fb266bcre-added brick_polytope() as deprecated method. Examples for brick_polehedron() fixed
77e4e6eReplaced brick polytope by brick polyhedron in documentaion. Methods to be changed/rewritten: kappa_preimage() of facets, is_vertex() of facets, brick_fan of subword complex, minkowski_summand of subword complex.
5339265method is_vertex() for facets rewritten
93177deDoc for minkowski_summand() of subword complex and kappa_preimage() of facets
9425104rewritten brick_fan() for subword comlexes. Now correct and generalized to coincide with the normal fan of brick_polyhedron()
01bf6b8more details in the doc of upper_root_configuration
0ad8eb4used deprecated_function_alias for brick_polytope instead of warn
e918ccecorrected the deprecation number
2407df9added missing 'optional - gap 3' flags
5191ab7Merge branch 'u/gh-DennisJahn/changing_brick_polytopes_of_subword_complexes_to_brick_polyhedra' of trac.sagemath.org:sage into t/32681/changing_brick_polytopes_of_subword_complexes_to_brick_polyhedra
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 6e6864c to 5191ab7

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

c52f434style changes of 32669 as mentioned by gh-kliem
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 5191ab7 to c52f434

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

39b0d6bpart 2 of style changes as mentioned by gh-kliem
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from c52f434 to 39b0d6b

kliem commented 3 years ago
comment:21
-        - ``backend`` -- string (default: ``'ccd'``) -- The backend to use to create the polyhedron.
+        - ``backend`` -- string (default: ``'cdd'``); the backend to use to create the polyhedron

and

-        - ``backend`` -- string (default: ``'cdd'``) The backend to use to create the polyhedron.
+        - ``backend`` -- string (default: ``'cdd'``); the backend to use to create the polyhedron
kliem commented 3 years ago
comment:22

The above comment was edited to also remove the trailing period.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

9a9421bdouble d's are doubly confusing
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 39b0d6b to 9a9421b

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

f127591lazy import for better startup time
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 9a9421b to f127591

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

e46af36LazyImport didn't work, corrected real_double to qqbar for import of AA, backend normaliz does work now
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from f127591 to e46af36

mkoeppe commented 2 years ago
comment:26

Stalled in needs_review or needs_info; likely won't make it into Sage 9.5.

mkoeppe commented 2 years ago
comment:27

merge conflict (red branch) => needs work

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from e46af36 to 08202bc

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 08202bc to 8164229

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

9ca2b2fadded Knutson Miller 2004 and Pilaud Stump 2015 to master reference file
8164229replacing brick polytopes by brick polyhedra, marked brick polytope as deprecated function, extended brick vectors with a sign for choice of convention, generalized brick fan for brick polyhedra, switched references for master reference file
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

679d177minor doc change
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 8164229 to 679d177

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 679d177 to 620abf6

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

620abf6doc intro rewritten for brick polyhedra
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 620abf6 to 436a8ba