-
-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-36368: Laurent polynomials, Fitting ideals and characteristic vari…
…eties <!-- Describe your changes here in detail --> Recently in #36128 (already in develop) characteristic varieties of finitely presented fundamental groups were introduced. Its computation is based on Fitting ideals of Laurent polynomial matrices. In #36299, Fitting ideals were implemented for generic rings with some improvements for PID and polynomial rings. There are two original goals in this PR: to improve the output of characteristic varieties and to use the cited implementation. In order to make computations faster, the implementation of Fitting ideals should apply to Laurent polynomial rings and for this goal, several changes should be applied to Laurent polynomials in `Sagemath`. I am not sure if a deeper change should be made, since I applied only the changes I needed for the above goal: - src/sage/groups/finitely_presented.py: - Changes in `fitting_ideals`. - src/sage/matrix/matrix2.py: Style changes. - src/sage/matrix/matrix_laurent_mpolynomial_dense.pyx: This is a new file to create the class `Matrix_laurent_mpolynomial_dense`. - A method `laurent_matrix_reduction` to obtain a matrix of polynomials where the variables are non common factors for neither the rows nor the columns. - A methord `_fitting_ideal` to use the same method for matrices of polynomials. - src/sage/matrix/matrix__mpolynomial_dense.pyx: Style changes. The main changes are for Laurent polynomials to avoid errors in the above implementations. - src/sage/rings/polynomials/laurent_polynomial.pyx: - Style changes. - Create `xgcd` needed for `inverse_mod`. - Create `inverse_mod`. - Create `divides`, I copied the code for polynomials with minor changes. - src/sage/rings/polynomials/laurent_polynomial_ideal.py: - Style changes. - Changes in hint keyword in `__init__`, the previous code create issues, e.g., impossible to sum ideals of univariate Laurent polynomial rings. They involve changes in doctests for `hint` - Changes in `__contains__` since `__reduce__` is different for univariate and multivaraite case. - Create `gens_reduced`. - Changes in `polynomial_ideal` to deal differently if uni- and multi-variate. - src/sage/rings/polynomials/laurent_polynomial_mpair.py: - Style changes. - Create `divides`, I copied the code for polynomials with minor changes. - src/sage/rings/polynomials/laurent_polynomial_ring.py: - Style changes. - Some `TestSuite`'s applied to domains as base_rings; the corresponding `TestSuite`'s for polynomials also failed if applied to polynomial rings. - src/sage/rings/polynomials/laurent_polynomial_ring_base.py: - Style changes. - Implement `is_noetherian`. - src/sage/rings/polynomials/polynomial_element.pyx: Style changes. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36368 Reported by: Enrique Manuel Artal Bartolo Reviewer(s): Enrique Manuel Artal Bartolo, kedlaya, miguelmarco, Travis Scrimshaw
- Loading branch information
Showing
11 changed files
with
429 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense | ||
|
||
cdef class Matrix_Laurent_mpolynomial_dense(Matrix_generic_dense): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
""" | ||
Dense matrices over multivariate polynomials over fields. | ||
AUTHOR: | ||
- Enrique Artal (2023-??): initial version | ||
""" | ||
|
||
# ***************************************************************************** | ||
# Copyright (C) 2023 Enrique Artal <artal@unizar.es> | ||
# | ||
# Distributed under the terms of the GNU General Public License (GPL) | ||
# as published by the Free Software Foundation; either version 2 of | ||
# the License, or (at your option) any later version. | ||
# https://www.gnu.org/licenses/ | ||
# ***************************************************************************** | ||
from sage.matrix.constructor import identity_matrix | ||
from sage.rings.polynomial.laurent_polynomial_ring_base import LaurentPolynomialRing_generic | ||
|
||
cdef class Matrix_laurent_mpolynomial_dense(Matrix_generic_dense): | ||
""" | ||
Dense matrix over a Laurent multivariate polynomial ring over a field. | ||
""" | ||
def laurent_matrix_reduction(self): | ||
""" | ||
From a matrix `self` of Laurent polynomials, apply elementary operations | ||
to obtain a matrix `P` of polynomials such that the variables do not divide | ||
no column and no row. | ||
OUTPUT: | ||
Three matrices `L`, `P`, `R` such that ``self` equals `L P R`, where `L` and | ||
`R` are diagonal with monomial entries. | ||
EXAMPLES: | ||
sage: R.<x, y> = LaurentPolynomialRing(QQ) | ||
sage: L = [1/3*x^-1*y - 6*x^-2*y^2 - 1/2*x^-2*y, 1/5*x + 1/2*y + 1/6] | ||
sage: L += [1/2 - 5*x^-1*y - 2*x^-1, -1/3*y^-2 - 4*x^-1*y^-1 + 11*x^-1*y^-2] | ||
sage: A = matrix(R, 2, L) | ||
sage: lf, P, rg = A.laurent_matrix_reduction() | ||
sage: lf | ||
[ x^-2 0] | ||
[ 0 x^-1*y^-2] | ||
sage: P | ||
[ 1/3*x - 6*y - 1/2 1/5*x^3 + 1/2*x^2*y + 1/6*x^2] | ||
[ 1/2*x*y - 5*y^2 - 2*y -1/3*x - 4*y + 11] | ||
sage: rg | ||
[y 0] | ||
[0 1] | ||
""" | ||
R = self.base_ring() | ||
n_rows, n_cols = self.dimensions() | ||
mat_l = identity_matrix(R, n_rows) | ||
mat_r = identity_matrix(R, n_cols) | ||
res = self.__copy__() | ||
for j, rw in enumerate(res.rows()): | ||
for t in R.gens(): | ||
n = min(mon.degree(t) for a in rw for cf, mon in a) | ||
res.rescale_row(j, t ** -n) | ||
mat_l.rescale_col(j, t ** n) | ||
for j, cl in enumerate(res.columns()): | ||
for t in R.gens(): | ||
n = min(mon.degree(t) for a in cl for cf, mon in a) | ||
res.rescale_col(j, t ** -n) | ||
mat_r.rescale_row(j, t ** n) | ||
res = res.change_ring(R.polynomial_ring()) | ||
return mat_l, res, mat_r | ||
|
||
def _fitting_ideal(self, i): | ||
r""" | ||
Return the `i`-th Fitting ideal of the matrix. This is the ideal generated | ||
by the `n - i` minors, where `n` is the number of columns. | ||
INPUT: | ||
``i`` -- an integer | ||
OUTPUT: | ||
An ideal on the base ring. | ||
EXAMPLES:: | ||
sage: R.<x,y,z> = LaurentPolynomialRing(QQ) | ||
sage: M = matrix(R, [[2*x^-1-z, 0, y-z^-2, 0], [0, z - y^-1, z - x, 0],[z - y, x^-2 - y, 0, z]]) | ||
sage: M | ||
[-z + 2*x^-1 0 y - z^-2 0] | ||
[ 0 z - y^-1 -x + z 0] | ||
[ -y + z -y + x^-2 0 z] | ||
sage: M.fitting_ideal(0) | ||
Ideal (0) of Multivariate Laurent Polynomial Ring in x, y, z over Rational Field | ||
sage: M.fitting_ideal(1) == M._fitting_ideal(1) | ||
True | ||
sage: M.fitting_ideal(1).groebner_basis() | ||
(x^4 - 2*x^3*y - x*z^3 - 4*x^2*y + 8*x*y^2 + 4*x*y*z + 2*z^2 - 8*y, | ||
x*y*z^2 - x*z - 2*y*z + 2, | ||
x^2*z - x*z^2 - 2*x + 2*z, | ||
y^2*z + 1/4*x^2 - 1/2*x*y - 1/4*x*z - y + 1/2) | ||
sage: M.fitting_ideal(2).groebner_basis() | ||
(1,) | ||
sage: M.fitting_ideal(3).groebner_basis() | ||
(1,) | ||
sage: M.fitting_ideal(4).groebner_basis() | ||
(1,) | ||
sage: [R.ideal(M.minors(i)) == M._fitting_ideal(4 - i) for i in range(5)] | ||
[True, True, True, True, True] | ||
""" | ||
R = self.base_ring() | ||
S = R.polynomial_ring() | ||
A = self.laurent_matrix_reduction()[1].change_ring(S) | ||
J = A._fitting_ideal(i) | ||
return J.change_ring(R) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.