Skip to content

Commit 034c1b5

Browse files
committed
adding @cached_method's
1 parent 14c4ef3 commit 034c1b5

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

src/sage/groups/finitely_presented.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,7 @@ def abelian_invariants(self):
13531353
invariants = self.gap().AbelianInvariants()
13541354
return tuple(i.sage() for i in invariants)
13551355

1356+
@cached_method
13561357
def abelianization_map(self):
13571358
r"""
13581359
Return the abelianization map of ``self``.
@@ -1391,6 +1392,7 @@ def abelianization_map(self):
13911392
images.append(ab([int(j) for j in L]))
13921393
return self.hom(codomain=ab, im_gens=images)
13931394

1395+
@cached_method
13941396
def abelianization_to_algebra(self, ring=QQ):
13951397
r"""
13961398
Return the group algebra of the abelianization of ``self``
@@ -1634,7 +1636,8 @@ def alexander_matrix(self, im_gens=None):
16341636
return matrix(len(rel), len(gen),
16351637
lambda i, j: rel[i].fox_derivative(gen[j], im_gens))
16361638

1637-
def abelian_alexander_matrix(self, ring=QQ, abelianized=None, simplified=True):
1639+
@cached_method
1640+
def abelian_alexander_matrix(self, ring=QQ, simplified=True):
16381641
"""
16391642
Return the Alexander matrix of the group with values in the group
16401643
algebra of the abelianized.
@@ -1643,8 +1646,6 @@ def abelian_alexander_matrix(self, ring=QQ, abelianized=None, simplified=True):
16431646
16441647
- ``ring`` -- (default: ``QQ``) the base ring of the
16451648
group algebra
1646-
- ``abelianized`` -- optional (default: ``None``); a tuple containing the output of
1647-
``self.abelianization_to_algebra()`` to avoid recomputation
16481649
- ``simplified`` -- boolean (default: ``False``); if set to
16491650
``True`` use Gauss elimination and erase rows and columns
16501651
@@ -1667,9 +1668,6 @@ def abelian_alexander_matrix(self, ring=QQ, abelianized=None, simplified=True):
16671668
Multivariate Laurent Polynomial Ring in f1, f2, f3 over Rational Field
16681669
sage: ideal
16691670
[]
1670-
sage: abel = H.abelianization_to_algebra()
1671-
sage: (A, ideal) == H.abelian_alexander_matrix(abelianized=abel)
1672-
True
16731671
sage: G = FreeGroup(3)/[(2, 1, 1), (1, 2, 2, 3, 3)]
16741672
sage: A, ideal = G.abelian_alexander_matrix(simplified=True); A
16751673
[-f3^2 - f3^4 - f3^6 f3^3 + f3^6]
@@ -1680,10 +1678,7 @@ def abelian_alexander_matrix(self, ring=QQ, abelianized=None, simplified=True):
16801678
sage: g.abelian_alexander_matrix()
16811679
([], [])
16821680
"""
1683-
if abelianized is None:
1684-
ab, R, ideal, images = self.abelianization_to_algebra(ring=ring)
1685-
else:
1686-
ab, R, ideal, images = abelianized
1681+
ab, R, ideal, images = self.abelianization_to_algebra(ring=ring)
16871682
A = self.alexander_matrix(im_gens=images)
16881683
if simplified:
16891684
n, m = A.dimensions()
@@ -1713,7 +1708,7 @@ def abelian_alexander_matrix(self, ring=QQ, abelianized=None, simplified=True):
17131708
simpli = unidad
17141709
return A, ideal
17151710

1716-
def characteristic_varieties(self, ring=QQ, matrix_ideal=None, abelianized=None, groebner=False):
1711+
def characteristic_varieties(self, ring=QQ, matrix_ideal=None, groebner=False):
17171712
r"""
17181713
Return the characteristic varieties of the group ``self``.
17191714
@@ -1731,8 +1726,6 @@ def characteristic_varieties(self, ring=QQ, matrix_ideal=None, abelianized=None,
17311726
INPUT:
17321727
17331728
- ``ring`` -- (default: ``QQ``) the base ring of the group algebra
1734-
- ``matrix_ideal`` -- optional; an abelian Alexander matrix and an ideal
1735-
- ``abelianized`` -- optional; the data of of the output of ``abelianization_to_algebra``
17361729
- ``groebner`` -- boolean (default: ``False``); If set to
17371730
``True`` the minimal associated primes of the ideals and their
17381731
groebner bases are computed; ignored if the base ring
@@ -1760,9 +1753,6 @@ def characteristic_varieties(self, ring=QQ, matrix_ideal=None, abelianized=None,
17601753
(f2*f3 + 1, f1 - f2),
17611754
(f2*f3 + 1, f1 - f3),
17621755
(f1*f3 + 1, f2 - f3)]]
1763-
sage: A, I = G.abelian_alexander_matrix()
1764-
sage: G.characteristic_varieties(groebner=True) == G.characteristic_varieties(groebner=True, matrix_ideal=(A, I))
1765-
True
17661756
sage: G = FreeGroup(2)/[2*(1,2,-1,-2)]
17671757
sage: G.characteristic_varieties()
17681758
[Ideal (-2*f2 + 2, 2*f1 - 2) of Multivariate Laurent Polynomial Ring in f1, f2 over Rational Field]
@@ -1774,10 +1764,7 @@ def characteristic_varieties(self, ring=QQ, matrix_ideal=None, abelianized=None,
17741764
sage: G.characteristic_varieties(groebner=True)
17751765
[[1 - f2 + f2^2]]
17761766
"""
1777-
if matrix_ideal is None:
1778-
A, ideal = self.abelian_alexander_matrix(ring=ring, abelianized=abelianized, simplified=True)
1779-
else:
1780-
A, ideal = matrix_ideal
1767+
A, ideal = self.abelian_alexander_matrix(ring=ring, simplified=True)
17811768
R = A.base_ring()
17821769
res = []
17831770
S = R.polynomial_ring()

0 commit comments

Comments
 (0)