Skip to content

Commit

Permalink
src/sage/homology/graded_resolution.py: Use file-level # optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed May 24, 2023
1 parent 0c97bcf commit c4c593a
Showing 1 changed file with 61 additions and 60 deletions.
121 changes: 61 additions & 60 deletions src/sage/homology/graded_resolution.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# sage.doctest: optional - sage.libs.singular
r"""
Graded free resolutions
Expand All @@ -9,20 +10,20 @@
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution(algorithm='minimal') # optional - sage.libs.singular
sage: r # optional - sage.libs.singular
sage: r = I.graded_free_resolution(algorithm='minimal')
sage: r
S(0) <-- S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
sage: I.graded_free_resolution(algorithm='shreyer') # optional - sage.libs.singular
sage: I.graded_free_resolution(algorithm='shreyer')
S(0) <-- S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
sage: I.graded_free_resolution(algorithm='standard') # optional - sage.libs.singular
sage: I.graded_free_resolution(algorithm='standard')
S(0) <-- S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
sage: I.graded_free_resolution(algorithm='heuristic') # optional - sage.libs.singular
sage: I.graded_free_resolution(algorithm='heuristic')
S(0) <-- S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
::
sage: d = r.differential(2) # optional - sage.libs.singular
sage: d # optional - sage.libs.singular
sage: d = r.differential(2)
sage: d
Free module morphism defined as left-multiplication by the matrix
[ y x]
[-z -y]
Expand All @@ -31,30 +32,30 @@
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Codomain: Ambient free module of rank 3 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
sage: d.image() # optional - sage.libs.singular
sage: d.image()
Submodule of Ambient free module of rank 3 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Generated by the rows of the matrix:
[ y -z w]
[ x -y z]
sage: m = d.image() # optional - sage.libs.singular
sage: m.graded_free_resolution(shifts=(2,2,2)) # optional - sage.libs.singular
sage: m = d.image()
sage: m.graded_free_resolution(shifts=(2,2,2))
S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
An example of multigraded resolution from Example 9.1 of [MilStu2005]_::
sage: R.<s,t> = QQ[]
sage: S.<a,b,c,d> = QQ[]
sage: phi = S.hom([s, s*t, s*t^2, s*t^3])
sage: I = phi.kernel(); I # optional - sage.libs.singular
sage: I = phi.kernel(); I
Ideal (c^2 - b*d, b*c - a*d, b^2 - a*c) of
Multivariate Polynomial Ring in a, b, c, d over Rational Field
sage: P3 = ProjectiveSpace(S) # optional - sage.libs.singular
sage: C = P3.subscheme(I) # twisted cubic curve # optional - sage.libs.singular
sage: r = I.graded_free_resolution(degrees=[(1,0), (1,1), (1,2), (1,3)]) # optional - sage.libs.singular
sage: r # optional - sage.libs.singular
sage: P3 = ProjectiveSpace(S)
sage: C = P3.subscheme(I) # twisted cubic curve
sage: r = I.graded_free_resolution(degrees=[(1,0), (1,1), (1,2), (1,3)])
sage: r
S((0, 0)) <-- S((-2, -4))⊕S((-2, -3))⊕S((-2, -2)) <-- S((-3, -5))⊕S((-3, -4)) <-- 0
sage: r.K_polynomial(names='s,t') # optional - sage.libs.singular
sage: r.K_polynomial(names='s,t')
s^3*t^5 + s^3*t^4 - s^2*t^4 - s^2*t^3 - s^2*t^2 + 1
AUTHORS:
Expand Down Expand Up @@ -114,18 +115,18 @@ def __init__(self, module, degrees=None, shifts=None, name='S', **kwds):
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution() # optional - sage.libs.singular
sage: TestSuite(r).run(skip=['_test_pickling']) # optional - sage.libs.singular
sage: r = I.graded_free_resolution()
sage: TestSuite(r).run(skip=['_test_pickling'])
An overdetermined system over a PID::
sage: from sage.homology.free_resolution import FreeResolution
sage: M = matrix([[x^2, 2*x^2],
....: [3*x^2, 5*x^2],
....: [5*x^2, 4*x^2]])
sage: res = FreeResolution(M, graded=True); res # optional - sage.libs.singular
sage: res = FreeResolution(M, graded=True); res
S(0)⊕S(0) <-- S(-2)⊕S(-2) <-- 0
sage: res._res_shifts # optional - sage.libs.singular
sage: res._res_shifts
[[2, 2]]
"""
super().__init__(module, name=name, **kwds)
Expand Down Expand Up @@ -167,18 +168,18 @@ def _repr_module(self, i):
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution() # optional - sage.libs.singular
sage: r._repr_module(0) # optional - sage.libs.singular
sage: r = I.graded_free_resolution()
sage: r._repr_module(0)
'S(0)'
sage: r._repr_module(1) # optional - sage.libs.singular
sage: r._repr_module(1)
'S(-2)⊕S(-2)⊕S(-2)'
sage: r._repr_module(2) # optional - sage.libs.singular
sage: r._repr_module(2)
'S(-3)⊕S(-3)'
sage: r._repr_module(3) # optional - sage.libs.singular
sage: r._repr_module(3)
'0'
sage: r = I.graded_free_resolution(shifts=[-1]) # optional - sage.libs.singular
sage: r._repr_module(0) # optional - sage.libs.singular
sage: r = I.graded_free_resolution(shifts=[-1])
sage: r._repr_module(0)
'S(1)'
"""
self._maps # to set _res_shifts
Expand All @@ -204,14 +205,14 @@ def shifts(self, i):
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution() # optional - sage.libs.singular
sage: r.shifts(0) # optional - sage.libs.singular
sage: r = I.graded_free_resolution()
sage: r.shifts(0)
[0]
sage: r.shifts(1) # optional - sage.libs.singular
sage: r.shifts(1)
[2, 2, 2]
sage: r.shifts(2) # optional - sage.libs.singular
sage: r.shifts(2)
[3, 3]
sage: r.shifts(3) # optional - sage.libs.singular
sage: r.shifts(3)
[]
"""
if i < 0:
Expand Down Expand Up @@ -240,18 +241,18 @@ def betti(self, i, a=None):
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution() # optional - sage.libs.singular
sage: r.betti(0) # optional - sage.libs.singular
sage: r = I.graded_free_resolution()
sage: r.betti(0)
{0: 1}
sage: r.betti(1) # optional - sage.libs.singular
sage: r.betti(1)
{2: 3}
sage: r.betti(2) # optional - sage.libs.singular
sage: r.betti(2)
{3: 2}
sage: r.betti(1, 0) # optional - sage.libs.singular
sage: r.betti(1, 0)
0
sage: r.betti(1, 1) # optional - sage.libs.singular
sage: r.betti(1, 1)
0
sage: r.betti(1, 2) # optional - sage.libs.singular
sage: r.betti(1, 2)
3
"""
shifts = self.shifts(i)
Expand Down Expand Up @@ -282,9 +283,9 @@ def K_polynomial(self, names=None):
EXAMPLES::
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2]) # optional - sage.libs.singular
sage: r = I.graded_free_resolution() # optional - sage.libs.singular
sage: r.K_polynomial() # optional - sage.libs.singular
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution()
sage: r.K_polynomial()
2*t^3 - 3*t^2 + 1
"""
if self._multigrade:
Expand Down Expand Up @@ -325,7 +326,7 @@ class GradedFiniteFreeResolution_free_module(GradedFiniteFreeResolution, FiniteF
sage: R.<x> = QQ[]
sage: M = matrix([[x^3, 3*x^3, 5*x^3],
....: [0, x, 2*x]])
sage: res = FreeResolution(M, graded=True); res # optional - sage.libs.singular
sage: res = FreeResolution(M, graded=True); res
S(0)⊕S(0)⊕S(0) <-- S(-3)⊕S(-1) <-- 0
"""
def __init__(self, module, degrees=None, *args, **kwds):
Expand All @@ -338,8 +339,8 @@ def __init__(self, module, degrees=None, *args, **kwds):
sage: R.<x> = QQ[]
sage: M = matrix([[x^3, 3*x^3, 5*x^3],
....: [0, x, 2*x]])
sage: res = FreeResolution(M, graded=True) # optional - sage.libs.singular
sage: TestSuite(res).run(skip="_test_pickling") # optional - sage.libs.singular
sage: res = FreeResolution(M, graded=True)
sage: TestSuite(res).run(skip="_test_pickling")
"""
super().__init__(module, degrees=degrees, *args, **kwds)

Expand All @@ -360,23 +361,23 @@ def _maps(self):
sage: R.<x> = QQ[]
sage: M = matrix([[x^3, 3*x^3, 5*x^3],
....: [0, x, 2*x]])
sage: res = FreeResolution(M, graded=True); res # optional - sage.libs.singular
sage: res = FreeResolution(M, graded=True); res
S(0)⊕S(0)⊕S(0) <-- S(-3)⊕S(-1) <-- 0
sage: res._maps # optional - sage.libs.singular
sage: res._maps
[
[ x^3 0]
[3*x^3 x]
[5*x^3 2*x]
]
sage: res._res_shifts # optional - sage.libs.singular
sage: res._res_shifts
[[3, 1]]
sage: I = R.ideal([x^4])
sage: res = I.graded_free_resolution(shifts=[1], degrees=[2]); res # optional - sage.libs.singular
sage: res = I.graded_free_resolution(shifts=[1], degrees=[2]); res
S(-1) <-- S(-9) <-- 0
sage: res._maps # optional - sage.libs.singular
sage: res._maps
[[x^4]]
sage: res._res_shifts # optional - sage.libs.singular
sage: res._res_shifts
[[9]]
"""
def compute_degree(base, i):
Expand Down Expand Up @@ -468,15 +469,15 @@ class GradedFiniteFreeResolution_singular(GradedFiniteFreeResolution, FiniteFree
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution(); r # optional - sage.libs.singular
sage: r = I.graded_free_resolution(); r
S(0) <-- S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
sage: len(r) # optional - sage.libs.singular
sage: len(r)
2
sage: I = S.ideal([z^2 - y*w, y*z - x*w, y - x])
sage: I.is_homogeneous()
True
sage: r = I.graded_free_resolution(); r # optional - sage.libs.singular
sage: r = I.graded_free_resolution(); r
S(0) <-- S(-1)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3)⊕S(-4) <-- S(-5) <-- 0
"""
def __init__(self, module, degrees=None, shifts=None, name='S', algorithm='heuristic', **kwds):
Expand All @@ -487,8 +488,8 @@ def __init__(self, module, degrees=None, shifts=None, name='S', algorithm='heuri
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution() # optional - sage.libs.singular
sage: TestSuite(r).run(skip=['_test_pickling']) # optional - sage.libs.singular
sage: r = I.graded_free_resolution()
sage: TestSuite(r).run(skip=['_test_pickling'])
"""
super().__init__(module, degrees=degrees, shifts=shifts, name=name, **kwds)
self._algorithm = algorithm
Expand All @@ -503,15 +504,15 @@ def _maps(self):
TESTS::
sage: S.<x,y,z,w> = PolynomialRing(QQ)
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2]) # optional - sage.libs.singular
sage: r = I.graded_free_resolution() # optional - sage.libs.singular
sage: r._maps # optional - sage.libs.singular
sage: I = S.ideal([y*w - z^2, -x*w + y*z, x*z - y^2])
sage: r = I.graded_free_resolution()
sage: r._maps
[
[-y x]
[ z -y]
[z^2 - y*w y*z - x*w y^2 - x*z], [-w z]
]
sage: r._res_shifts # optional - sage.libs.singular
sage: r._res_shifts
[[2, 2, 2], [3, 3]]
"""
from sage.libs.singular.singular import si2sa_resolution_graded
Expand Down

0 comments on commit c4c593a

Please sign in to comment.