Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Chow ring ideal and Chow ring classes #38281

Open
wants to merge 178 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
d038b95
Created Chow Ring Ideal Class
25shriya Jun 9, 2024
1685022
Created class and defined groebner_basis() method
25shriya Jun 10, 2024
0ab73bb
Modified groebner_basis() method
25shriya Jun 10, 2024
237fdad
Added Augmented Chow Ring Ideal Class
25shriya Jun 18, 2024
d51bd1d
Modified ChowRingIdeal class
25shriya Jun 23, 2024
462ce6c
Created Chow Ring class
25shriya Jun 23, 2024
ad4c43c
Created Augmented Chow Ring class
25shriya Jun 23, 2024
cbf6db4
Edited __init__ and _repr_short funcs
25shriya Jun 25, 2024
873d9a7
Modified __init__() functions for both classes
25shriya Jun 26, 2024
529bb10
Debugged __init__() function of Chow ring class
25shriya Jun 26, 2024
6079e3d
Modified groebner_basis() method for both classes
25shriya Jun 28, 2024
3f466b9
Added Documentation to both classes
25shriya Jul 2, 2024
980c63f
Added Documentation to Chow ring class
25shriya Jul 2, 2024
ca4bdc4
Added Chow rings section in documentation
25shriya Jul 9, 2024
7953806
Split Augmented Chow ring ideal class into 3 classes
25shriya Jul 9, 2024
1d9210a
Edited Documentation
25shriya Jul 9, 2024
fb7c7ef
Merge branch 'sagemath:develop' into chow_ring
25shriya Jul 9, 2024
8073820
Edited Documentation
25shriya Jul 14, 2024
b3f9e31
Created a documentation block for chow rings
25shriya Jul 14, 2024
b867da5
Edited latex() method
25shriya Jul 15, 2024
cba41ab
Corrected Doctests
25shriya Jul 16, 2024
c90fe5b
Edited Doctests
25shriya Jul 17, 2024
cf83d97
Corrected Doctests
25shriya Jul 17, 2024
d892cdb
Edited abstract class - AugmentedChowRingIdeal
25shriya Jul 18, 2024
fdd0444
Split ChowRingIdeal into 4 classes
25shriya Jul 23, 2024
1d42f3a
Edited documentation
25shriya Jul 23, 2024
20fa80f
Debugged groebner_basis() method for ChowRingIdeal_nonaug
25shriya Jul 23, 2024
0ee932f
Added TestSuite.run() doctest to ChowRing class
25shriya Jul 23, 2024
470d69b
Added basis() method
25shriya Jul 29, 2024
a724173
Edited attribute names
25shriya Jul 29, 2024
7ab59ad
Modified chow_ring() method
25shriya Jul 29, 2024
92e6f41
Merge branch 'develop' into chow_ring
25shriya Jul 29, 2024
2ec5329
Modified basis() method
25shriya Jul 30, 2024
d9271fd
Debugged AugmentedChowRingIdeal_atom_free.__init__()
25shriya Jul 30, 2024
9ad2a0a
Merge branch 'sagemath:develop' into chow_ring
25shriya Aug 5, 2024
4d1097d
Added Element() class
25shriya Aug 5, 2024
d03c0e0
Written doctests for every method
25shriya Aug 5, 2024
c9a138f
Corrected Doctests for Element class
25shriya Aug 5, 2024
72a160d
Edited _repr_() method
25shriya Aug 5, 2024
4da26f3
Edited chow_ring() doctest
25shriya Aug 5, 2024
ca5ec9a
Wrote doctests for Element class
25shriya Aug 7, 2024
a90f02f
Edited chow_ring() doctest
25shriya Aug 7, 2024
9d6489a
Wrote doctests for _gens_constructor()
25shriya Aug 7, 2024
c7fa9ea
Changed ChowRing category
25shriya Aug 7, 2024
33aa1c0
Edited groebner_basis() method
25shriya Aug 7, 2024
8c71e82
Added references
25shriya Aug 10, 2024
6b6d0e1
Wrote mathematical definition of Chow ring
25shriya Aug 10, 2024
01ab04b
Wrote mathematical definition of Chow ring ideal
25shriya Aug 10, 2024
f7377c8
Modified chow_ring() doctest
25shriya Aug 10, 2024
e41edf8
Debugged basis() method
25shriya Aug 10, 2024
367225a
Wrote doctests for groebner_basis() methods
25shriya Aug 10, 2024
9ec9b18
Updated references
25shriya Aug 13, 2024
c63627a
Incorporated GitHub comments
25shriya Aug 13, 2024
434c860
Incorporated GitHub comments for ideal file
25shriya Aug 13, 2024
16ffe62
Modified basis() method
25shriya Aug 19, 2024
4fc0ac0
Modified ChowRingIdeal_nonaug.groebner_basis()
25shriya Aug 19, 2024
63a5e8d
Edited ChowRingIdeal_nonaug.groebner_basis() method
25shriya Aug 19, 2024
3763e59
Edited groebner_basis() lattice
25shriya Aug 27, 2024
73acafe
Edited basis() method
25shriya Aug 27, 2024
32b88fb
Merge branch 'sagemath:develop' into chow_ring
25shriya Aug 27, 2024
b32359c
Edited basis() method
25shriya Sep 6, 2024
1cede4b
Edited basis() method- added product func
25shriya Sep 10, 2024
dc8e380
Debugged groebner_basis() method
25shriya Sep 10, 2024
2c53ea5
Merge branch 'sagemath:develop' into chow_ring
25shriya Sep 10, 2024
5e6bf99
Debugged groebner_basis() method for ChowRingIdeal_nonaug
25shriya Sep 10, 2024
4ed084f
Edited max_powers
25shriya Sep 10, 2024
9e11b41
Debugged groebner_basis() method as per hand calculation
25shriya Sep 13, 2024
ec079dc
Added test case for empty subset
25shriya Sep 13, 2024
9ad9145
Added comments and edited doctests
25shriya Sep 17, 2024
86e2a9d
Merge branch 'sagemath:develop' into chow_ring
25shriya Sep 17, 2024
8b8ab5d
Edited basis() method for augmented ChowRing (fy presentation)
25shriya Sep 18, 2024
91a757a
Edited basis() method for augmented Chow Ring (atom-free presentation)
25shriya Sep 18, 2024
12c0d5f
Added 'algorithm' parameter to all groebner_basis() methods
25shriya Sep 18, 2024
4dd6155
Merge branch 'sagemath:develop' into chow_ring
25shriya Sep 23, 2024
369db7f
Edited and formatted doctests
25shriya Sep 23, 2024
5427630
Edited and formatted doctests for the Chow ring class
25shriya Sep 23, 2024
53ea5fc
Edited suggested changes to chow_ring.py
25shriya Sep 23, 2024
d631779
Edited suggested changes to chow_ring_ideal.py
25shriya Sep 23, 2024
6ddca26
Fixed doctest typos in chow_ring_ideal.py
25shriya Sep 23, 2024
80a8892
Fixed doctest typos in chow_ring_ideal.py
25shriya Sep 23, 2024
17b6287
Fixed doctest typos in chow_ring.py
25shriya Sep 23, 2024
7439ab9
Debugged all 3 basis() method cases
25shriya Sep 24, 2024
96a7dc8
Optimized groebner_basis() method
25shriya Sep 24, 2024
f01279a
Fixed typos in groebner_basis() method
25shriya Sep 24, 2024
d0fb2ba
Added LaTeX method for the ideals
25shriya Sep 24, 2024
3ed13fa
Edited definintions for augmented Chow ring ideal
25shriya Sep 24, 2024
db165d7
Fixed definitions of augmented Chow ring ideals
25shriya Sep 24, 2024
88b20fb
Edited groebner_basis() method for all 3 ideals
25shriya Sep 24, 2024
4669fd6
Edited chow_ring() function examples
25shriya Sep 25, 2024
a84a41d
Edited Doctests
25shriya Sep 25, 2024
e45f4b9
Edited doctests for ideals
25shriya Sep 25, 2024
ffd3fef
Edited basis() method for all 3 cases
25shriya Sep 30, 2024
e2faf65
Added hyperlinks to ideals definitions in chow_ring.py
25shriya Sep 30, 2024
8505fa7
Changed ChowRingIdeal_nonaug._gens_constructor()
25shriya Sep 30, 2024
9c928e2
Changed definition of the non aug ideal
25shriya Sep 30, 2024
03355c9
Edited documentation of ideals file
25shriya Sep 30, 2024
484013c
Merge branch 'sagemath:develop' into chow_ring
25shriya Oct 1, 2024
629baa2
Formatted doctests in chow_ring.py
25shriya Oct 3, 2024
cd3a3fc
Formatted doctests in the ideals file
25shriya Oct 3, 2024
bdfded8
Corrected doctest outputs
25shriya Oct 4, 2024
91bc8e0
Corrected linting errors for ideals file
25shriya Oct 5, 2024
b9556d8
Corrected linting errors in ideals file
25shriya Oct 5, 2024
cfb1fbb
Corrected doctest output
25shriya Oct 5, 2024
231cb1f
Corrected linting error
25shriya Oct 7, 2024
7b60d51
Resolved linting errors
25shriya Oct 7, 2024
12e8d93
Optimized basis() method for all 3 cases
25shriya Oct 7, 2024
6a72bd3
Corrected doctests for Element() subclass
25shriya Oct 7, 2024
31b7afb
Corrected linting errors in ideals file
25shriya Oct 7, 2024
e36e4ea
Corrected linting errors in chow_ring.py
25shriya Oct 7, 2024
9221947
Corrected linting errors in ideals file
25shriya Oct 7, 2024
4156022
Tested ideals file
25shriya Oct 7, 2024
35fd32b
Corrected basis() method
25shriya Oct 7, 2024
7710eb5
Fixed linting error in matroid.pyx
25shriya Oct 7, 2024
d15176e
Edited basis() method
25shriya Oct 9, 2024
7614be8
Edited definition of augmented Chow ring ideal for both presentations
25shriya Oct 9, 2024
d54f0cb
Changed defn of augmented Chow ring ideal FY presentation
25shriya Oct 13, 2024
d2720e3
Debugged basis() method for atom-free case
25shriya Oct 15, 2024
f296378
Optimized definition of atom-free presentation
25shriya Oct 15, 2024
ab57cd9
Debugged groebner_basis()
25shriya Oct 15, 2024
8b2d98f
Debugged basis()
25shriya Oct 15, 2024
5fea8af
Debugged groebner_basis() for all 3 ideals
25shriya Oct 17, 2024
283a45b
Corrected doctests
25shriya Oct 17, 2024
058252f
Debugged basis() for FY presentation of the augmented Chow ring
25shriya Oct 17, 2024
1922a1a
Debugged basis() for augmented Chow ring for both presentations
25shriya Oct 17, 2024
1d2e204
Corrected linting errors
25shriya Oct 17, 2024
49276c1
Corrected doctests
25shriya Oct 17, 2024
37ce1ae
Merge branch 'sagemath:develop' into chow_ring
25shriya Oct 17, 2024
94527d8
Corrected doctests in chow_ring() method
25shriya Oct 17, 2024
8fdd625
Corrected Doctests for chow_ring() method
25shriya Oct 17, 2024
193ca4e
Corrected doctests in chow_ring() method
25shriya Oct 17, 2024
719d270
Formatted docstrings
25shriya Oct 19, 2024
8caea48
Formatted docstrings
25shriya Oct 19, 2024
2abf2cc
Edited docstrings
25shriya Oct 19, 2024
ef0e1d6
Edited doctests
25shriya Oct 21, 2024
c9d4553
Edited references formatting
25shriya Oct 21, 2024
8f52723
Reformatted references file
25shriya Oct 21, 2024
cb6dcc6
Formatted definitions
25shriya Oct 21, 2024
5b79644
Changed index.rst for matroids
25shriya Oct 27, 2024
2a5f0ca
Changed Documentation for augmented Chow rings definition
25shriya Oct 27, 2024
5b7a29f
Edited inputs for Chow ring class
25shriya Oct 27, 2024
3c6a9e1
Edited _latex_() for ChowRing() class
25shriya Oct 27, 2024
c0ba0c6
Edited basis() method
25shriya Oct 27, 2024
aa11b06
Edited documentation
25shriya Oct 27, 2024
9c93b84
Resolved suggested changes
25shriya Oct 28, 2024
99d843f
Corrected linting errors in ideal file
25shriya Oct 28, 2024
6ef419f
Corrected doctests
25shriya Oct 29, 2024
f423738
Added normal_basis() method for all 3 classes
25shriya Oct 29, 2024
e4031ad
Added normal_basis() method doctests for all 3 classes
25shriya Oct 29, 2024
744fc93
Added input parameters for chow_ring() method
25shriya Oct 29, 2024
8468ff1
Edited augmented chow ring ideal definition for atom-free presentation
25shriya Oct 29, 2024
5070e36
Corrected linting errors
25shriya Oct 29, 2024
a022f89
Changed augmented chow ring ideal definition
25shriya Oct 29, 2024
3abd400
Corrected doctests
25shriya Oct 29, 2024
a6ecb2d
Removed flats_generator() method
25shriya Oct 29, 2024
ad966f0
Renamed lattice_flats() method
25shriya Oct 29, 2024
564ac20
Optimized PolynomialSequence returns
25shriya Oct 29, 2024
e91e600
Optimized groebner_basis() and _gens_constructor() for augmented chow…
25shriya Oct 29, 2024
0611846
Edited basis() method
25shriya Oct 29, 2024
77938e8
Corrected groebner_basis() for FY presentation
25shriya Oct 30, 2024
d85d312
Merge branch 'develop' into chow_ring
25shriya Oct 30, 2024
00535fe
Resolved PEP8 changes
25shriya Nov 4, 2024
de683a8
added multiplication table
25shriya Nov 4, 2024
0f85f74
Added computations
25shriya Nov 4, 2024
19c94b5
Merge branch 'sagemath:develop' into chow_ring
25shriya Nov 4, 2024
6ca02bb
Edited repr() doctests
25shriya Nov 4, 2024
a239339
Fixed linting error
25shriya Nov 4, 2024
71e09d0
Edited doctest
25shriya Nov 4, 2024
79f410b
Edited doctests
25shriya Nov 4, 2024
9c9f804
Incorporated changes
25shriya Nov 4, 2024
9abd55f
Corrected _latex_() doctest
25shriya Nov 5, 2024
ace86c1
Edited groebner_basis() for nonaug case
25shriya Nov 5, 2024
73d6e59
Edited doctests
25shriya Nov 5, 2024
c8936d1
Edited doctests
25shriya Nov 5, 2024
d841b58
Resolved PEP8 changes and added matroid() method
25shriya Nov 5, 2024
79d3371
Corrected doctests
25shriya Nov 5, 2024
eb20165
Edited matroid() method
25shriya Nov 5, 2024
51f66dd
Corrected _gens_constructor() doctest
25shriya Nov 11, 2024
a7eec7b
Formatted doctests
25shriya Nov 11, 2024
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
9 changes: 9 additions & 0 deletions src/doc/en/reference/matroids/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ Concrete implementations
sage/matroids/rank_matroid
sage/matroids/graphic_matroid

Chow rings of matroids
----------------------

.. toctree::
:maxdepth: 1

sage/matroids/chow_ring_ideal
sage/matroids/chow_ring

Abstract matroid classes
------------------------

Expand Down
6 changes: 6 additions & 0 deletions src/doc/en/reference/references/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ REFERENCES:
finite Drinfeld modules.* manuscripta mathematica 93, 1 (01 Aug 1997),
369–379. https://doi.org/10.1007/BF02677478

.. [ANR2023] Robert Angarone, Anastasia Nathanson, and Victor Reiner. *Chow rings of
matroids as permutation representations*, 2023. :arxiv:`2309.14312`.

.. [AP1986] \S. Arnborg, A. Proskurowski,
*Characterization and Recognition of Partial 3-Trees*,
SIAM Journal of Alg. and Discrete Methods,
Expand Down Expand Up @@ -4928,6 +4931,9 @@ REFERENCES:
.. [MM2015] \J. Matherne and \G. Muller, *Computing upper cluster algebras*,
Int. Math. Res. Not. IMRN, 2015, 3121-3149.

.. [MM2022] Matthew Mastroeni and Jason McCullough. *Chow rings of matroids are
Koszul*. Mathematische Annalen, 387(3-4):1819-1851, November 2022.

.. [MMRS2022] Ruslan G. Marzo, Rafael A. Melo, Celso C. Ribeiro and
Marcio C. Santos: *New formulations and branch-and-cut procedures
for the longest induced path problem*. Computers & Operations
Expand Down
339 changes: 339 additions & 0 deletions src/sage/matroids/chow_ring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
r"""
Chow rings of matroids

AUTHORS:

- Shriya M
"""

from sage.matroids.chow_ring_ideal import ChowRingIdeal_nonaug, AugmentedChowRingIdeal_fy, AugmentedChowRingIdeal_atom_free
from sage.rings.quotient_ring import QuotientRing_generic
from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis
from sage.categories.commutative_rings import CommutativeRings

class ChowRing(QuotientRing_generic):
r"""
The Chow ring of a matroid.

The *Chow ring of the matroid* `M` is defined as the quotient ring

.. MATH::

A^*(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / (I_M + J_M),

where `(I_M + J_M)` is the :class:`Chow ring ideal
<sage.matroids.chow_ring_ideal.ChowRingIdeal_nonaug>` of matroid `M`.

The *augmented Chow ring of matroid* `M` has two different presentations
as quotient rings:

The *Feitchner-Yuzvinsky presentation* is the quotient ring

.. MATH::

A(M)_R := R[y_{e_1}, \ldots, y_{e_n}, x_{F_1}, \ldots, x_{F_k}] / I_{FY}(M),

where `I_{FY}(M)` is the :class:`Feitchner-Yuzvinsky augmented Chow ring
ideal <sage.matroids.chow_ring_ideal.AugmentedChowRingIdeal_fy>`
of matroid `M`.

The *atom-free presentation* is the quotient ring

.. MATH::

A(M)_R := R[x_{F_1}, \ldots, x_{F_k}] / I_{af}(M),

where `I_{af}(M)` is the :class:`atom-free augmented Chow ring ideal
<sage.matroids.chow_ring_ideal.AugmentedChowRingIdeal_atom_free>`
of matroid `M`.

.. SEEALSO::

:mod:`sage.matroids.chow_ring_ideal`

INPUT:

- ``M`` -- matroid
- ``R`` -- commutative ring
- ``augmented`` -- boolean; when ``True``, this is the augmented
Chow ring and if ``False``, this is the non-augmented Chow ring
- ``presentation`` -- string (default: ``None``); one of the following
(ignored if ``augmented=False``)

* ``"fy"`` - the Feitchner-Yuzvinsky presentation
* ``"atom-free"`` - the atom-free presentation

REFERENCES:

- [FY2004]_
- [AHK2015]_

EXAMPLES::

sage: M1 = matroids.catalog.P8pp()
sage: ch = M1.chow_ring(QQ, False)
sage: ch
Chow ring of P8'': Matroid of rank 4 on 8 elements with 8 nonspanning circuits
over Rational Field
"""
def __init__(self, R, M, augmented, presentation=None):
r"""
Initialize ``self``.

EXAMPLES::

sage: ch = matroids.Wheel(3).chow_ring(QQ, False)
sage: TestSuite(ch).run()
"""
self._matroid = M
self._augmented = augmented
self._presentation = presentation
if augmented is True:
if presentation == 'fy':
self._ideal = AugmentedChowRingIdeal_fy(M, R)
elif presentation == 'atom-free':
self._ideal = AugmentedChowRingIdeal_atom_free(M, R)
else:
self._ideal = ChowRingIdeal_nonaug(M, R)
C = CommutativeRings().Quotients() & GradedAlgebrasWithBasis(R).FiniteDimensional()
QuotientRing_generic.__init__(self, R=self._ideal.ring(),
I=self._ideal,
names=self._ideal.ring().variable_names(),
category=C)

def _repr_(self):
r"""
EXAMPLES::

sage: M1 = matroids.catalog.Fano()
sage: ch = M1.chow_ring(QQ, False)
sage: ch
Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0)
over Rational Field
"""
output = "Chow ring of {}".format(self._matroid)
if self._augmented is True:
output = "Augmented " + output
if self._presentation == 'fy':
output += " in Feitchner-Yuzvinsky presentation"
elif self._presentation == 'atom-free':
output += " in atom-free presentation"
return output + " over " + repr(self.base_ring())

def _latex_(self):
r"""
Return the LaTeX output of the polynomial ring and Chow ring ideal.

EXAMPLES::

sage: M1 = matroids.Uniform(2,5)
sage: ch = M1.chow_ring(QQ, False)
sage: ch._latex_()
'A(\\begin{array}{l}\n\\text{\\texttt{U(2,{ }5):{ }Matroid{ }of{ }rank{ }2{ }on{ }5{ }elements{ }with{ }circuit{-}closures}}\\\\\n\\text{\\texttt{{\\char`\\{}2:{ }{\\char`\\{}{\\char`\\{}0,{ }1,{ }2,{ }3,{ }4{\\char`\\}}{\\char`\\}}{\\char`\\}}}}\n\\end{array})_{\\Bold{Q}}'
"""
from sage.misc.latex import latex
base = "A({})_{{{}}}"
if self._augmented:
base += "^*"

Check warning on line 137 in src/sage/matroids/chow_ring.py

View check run for this annotation

Codecov / codecov/patch

src/sage/matroids/chow_ring.py#L137

Added line #L137 was not covered by tests
return base.format(latex(self._matroid), latex(self.base_ring()))

def matroid(self):
r"""
Return the matroid of ``self``.

EXAMPLES::

sage: ch = matroids.Uniform(3,6).chow_ring(QQ, True, 'fy')
sage: ch.matroid()
U(3, 6): Matroid of rank 3 on 6 elements with circuit-closures
{3: {{0, 1, 2, 3, 4, 5}}}
"""
return self._matroid

def _coerce_map_from_base_ring(self):
r"""
Disable the coercion from the base ring from the category.

TESTS::

sage: ch = matroids.Wheel(3).chow_ring(QQ, False)
sage: ch._coerce_map_from_base_ring() is None
True
"""
return None # don't need anything special

def basis(self):
r"""
Return the monomial basis of the given Chow ring.

EXAMPLES::

sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, True, 'fy')
sage: ch.basis()
Family (1, B1, B1*B012345, B0, B0*B012345, B01, B01^2, B2,
B2*B012345, B02, B02^2, B12, B12^2, B3, B3*B012345, B03, B03^2,
B13, B13^2, B23, B23^2, B4, B4*B012345, B04, B04^2, B14, B14^2,
B24, B24^2, B34, B34^2, B5, B5*B012345, B05, B05^2, B15, B15^2,
B25, B25^2, B35, B35^2, B45, B45^2, B012345, B012345^2, B012345^3)
sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis())
True
sage: ch = matroids.catalog.Fano().chow_ring(QQ, False)
sage: ch.basis()
Family (1, Abcd, Aace, Aabf, Adef, Aadg, Abeg, Acfg, Aabcdefg,
Aabcdefg^2)
sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis())
True
sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free')
sage: ch.basis()
Family (1, A0, A0*A012345, A2, A2*A012345, A3, A3*A012345, A23,
A23^2, A1, A1*A012345, A013, A013^2, A4, A4*A012345, A04, A04^2,
A124, A124^2, A5, A5*A012345, A025, A025^2, A15, A15^2, A345,
A345^2, A012345, A012345^2, A012345^3)
sage: set(ch.defining_ideal().normal_basis()) == set(ch.basis())
True
"""
from sage.sets.family import Family
monomial_basis = self._ideal.normal_basis()
return Family([self.element_class(self, mon, reduce=False) for mon in monomial_basis])

class Element(QuotientRing_generic.Element):
def to_vector(self, order=None):
r"""
Return ``self`` as a (dense) free module vector.

EXAMPLES::

sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False)
sage: v = ch.an_element(); v
-A01 - A02 - A03 - A04 - A05 - A012345
sage: v.to_vector()
(0, -1, -1, 0, -1, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0)
"""
P = self.parent()
B = P.basis()
FM = P._dense_free_module()
f = self.lift()
return FM([f.monomial_coefficient(b.lift()) for b in B])

_vector_ = to_vector

def monomial_coefficients(self, copy=None):
r"""
Return the monomial coefficients of ``self``.

EXAMPLES::

sage: ch = matroids.catalog.NonFano().chow_ring(QQ, True, 'atom-free')
sage: v = ch.an_element(); v
Aa
sage: v.monomial_coefficients()
{0: 0, 1: 1, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,
10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0,
18: 0, 19: 0, 20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0,
26: 0, 27: 0, 28: 0, 29: 0, 30: 0, 31: 0, 32: 0, 33: 0,
34: 0, 35: 0}
"""
B = self.parent().basis()
f = self.lift()
return {i: f.monomial_coefficient(b.lift()) for i, b in enumerate(B)}

def degree(self):
r"""
Return the degree of ``self``.

EXAMPLES::

sage: ch = matroids.Uniform(3, 6).chow_ring(QQ, False)
sage: for b in ch.basis():
....: print(b, b.degree())
1 0
A01 1
A02 1
A12 1
A03 1
A13 1
A23 1
A04 1
A14 1
A24 1
A34 1
A05 1
A15 1
A25 1
A35 1
A45 1
A012345 1
A012345^2 2
sage: v = sum(ch.basis())
sage: v.degree()
2
"""
return self.lift().degree()

def homogeneous_degree(self):
r"""
Return the (homogeneous) degree of ``self`` if homogeneous
otherwise raise an error.

EXAMPLES::

sage: ch = matroids.catalog.Fano().chow_ring(QQ, True, 'fy')
sage: for b in ch.basis():
....: print(b, b.homogeneous_degree())
1 0
Ba 1
Ba*Babcdefg 2
Bb 1
Bb*Babcdefg 2
Bc 1
Bc*Babcdefg 2
Bd 1
Bd*Babcdefg 2
Bbcd 1
Bbcd^2 2
Be 1
Be*Babcdefg 2
Bace 1
Bace^2 2
Bf 1
Bf*Babcdefg 2
Babf 1
Babf^2 2
Bdef 1
Bdef^2 2
Bg 1
Bg*Babcdefg 2
Badg 1
Badg^2 2
Bbeg 1
Bbeg^2 2
Bcfg 1
Bcfg^2 2
Babcdefg 1
Babcdefg^2 2
Babcdefg^3 3
sage: v = sum(ch.basis()); v
Babcdefg^3 + Babf^2 + Bace^2 + Badg^2 + Bbcd^2 + Bbeg^2 +
Bcfg^2 + Bdef^2 + Ba*Babcdefg + Bb*Babcdefg + Bc*Babcdefg +
Bd*Babcdefg + Be*Babcdefg + Bf*Babcdefg + Bg*Babcdefg +
Babcdefg^2 + Ba + Bb + Bc + Bd + Be + Bf + Bg + Babf + Bace +
Badg + Bbcd + Bbeg + Bcfg + Bdef + Babcdefg + 1
sage: v.homogeneous_degree()
Traceback (most recent call last):
...
ValueError: element is not homogeneous

TESTS::

sage: ch = matroids.Wheel(3).chow_ring(QQ, True, 'atom-free')
sage: ch.zero().homogeneous_degree()
Traceback (most recent call last):
...
ValueError: the zero element does not have a well-defined degree
"""
if not self:
raise ValueError("the zero element does not have a well-defined degree")
f = self.lift()
if not f.is_homogeneous():
raise ValueError("element is not homogeneous")
return f.degree()
Loading
Loading