Skip to content
Merged
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
66 changes: 54 additions & 12 deletions src/sage/homology/free_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

.. MATH::

R^{n_1} \xleftarrow{d_1} R^{n_1} \xleftarrow{d_2}
R^{n_0} \xleftarrow{d_1} R^{n_1} \xleftarrow{d_2}
\cdots \xleftarrow{d_k} R^{n_k} \xleftarrow{d_{k+1}} 0

terminating with a zero module at the end that is exact (all homology groups
Expand Down Expand Up @@ -242,9 +242,20 @@ def _repr_module(self, i):
'S^2'
sage: r # indirect doctest
S^1 <-- S^3 <-- S^2 <-- 0

TESTS::

sage: S.<x,y,z> = PolynomialRing(QQ)
sage: I = S.ideal(0)
sage: C = I.free_resolution()
sage: C
S^1 <-- 0
"""
if i == 0:
r = self._maps[0].nrows()
if self._length > 0:
r = self._maps[0].nrows()
else:
r = self._initial_differential.domain().dimension()
s = f'{self._name}^{r}'
return s
elif i > self._length:
Expand Down Expand Up @@ -422,6 +433,8 @@ def __getitem__(self, i):
raise IndexError('invalid index')
elif i > self._length:
F = FreeModule(self._base_ring, 0)
elif i == 0:
F = self.differential(0).domain()
elif i == self._length:
F = FreeModule(self._base_ring, self._maps[i - 1].ncols())
else:
Expand All @@ -444,11 +457,12 @@ def differential(self, i):
sage: r
S(0) <-- S(-2)⊕S(-2)⊕S(-2) <-- S(-3)⊕S(-3) <-- 0
sage: r.differential(3)
Free module morphism defined by the matrix []
Domain: Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Codomain: Ambient free module of rank 2 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Free module morphism defined as left-multiplication by the matrix
[]
Domain: Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
Codomain: Ambient free module of rank 2 over the integral domain
Multivariate Polynomial Ring in x, y, z, w over Rational Field
sage: r.differential(2)
Free module morphism defined as left-multiplication by the matrix
[-y x]
Expand Down Expand Up @@ -476,6 +490,31 @@ def differential(self, i):
[-z^2 + y*w]
[ y*z - x*w]
[-y^2 + x*z]

TESTS::

sage: P2.<x,y,z> = ProjectiveSpace(QQ, 2)
sage: S = P2.coordinate_ring()
sage: I = S.ideal(0)
sage: C = I.graded_free_resolution(); C
S(0) <-- 0
sage: C[1]
Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: C[0]
Ambient free module of rank 1 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: C.differential(1)
Free module morphism defined as left-multiplication by the matrix
[]
Domain: Ambient free module of rank 0 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
Codomain: Ambient free module of rank 1 over the integral domain
Multivariate Polynomial Ring in x, y, z over Rational Field
sage: C.differential(1).matrix()
[]
sage: C.differential(1).matrix().dimensions()
(1, 0)
"""
if i < 0:
raise IndexError('invalid index')
Expand All @@ -484,14 +523,17 @@ def differential(self, i):
return self._initial_differential
except AttributeError:
raise ValueError('0th differential map undefined')
elif i == self._length + 1:
s = FreeModule(self._base_ring, 0)
t = FreeModule(self._base_ring, self._maps[i - 2].ncols())
m = s.hom(0, t)
elif i > self._length + 1:
s = FreeModule(self._base_ring, 0)
t = FreeModule(self._base_ring, 0)
m = s.hom(0, t)
m = s.hom(0, t, side='right')
elif i == self._length + 1:
s = FreeModule(self._base_ring, 0)
if self._length > 0:
t = FreeModule(self._base_ring, self._maps[i - 2].ncols())
else:
t = self._initial_differential.domain()
m = s.hom(0, t, side='right')
else:
s = FreeModule(self._base_ring, self._maps[i - 1].ncols())
t = FreeModule(self._base_ring, self._maps[i - 1].nrows())
Expand Down