@@ -4845,11 +4845,19 @@ def intersection(self, other):
4845
4845
F = F + [s for s in self .faces ()[k ] if s in other .faces ()[k ]]
4846
4846
return SimplicialComplex (F )
4847
4847
4848
- def bigraded_betti_numbers (self , base_ring = ZZ ):
4848
+ def bigraded_betti_numbers (self , base_ring = ZZ , verbose = False ):
4849
4849
r"""
4850
4850
Return a dictionary of the bigraded Betti numbers of ``self``,
4851
4851
with keys `(-a, 2b)`.
4852
4852
4853
+ INPUT:
4854
+
4855
+ - ``base_ring`` -- (optional, default ``ZZ``) the base ring used
4856
+ when computing homology
4857
+ - ``verbose`` -- (optional, default ``False``) if ``True``, print
4858
+ messages during the computation, which indicate in which subcomplexes
4859
+ non-trivial homologies appear
4860
+
4853
4861
.. SEEALSO::
4854
4862
4855
4863
See :meth:`bigraded_betti_number` for more information.
@@ -4862,8 +4870,38 @@ def bigraded_betti_numbers(self, base_ring=ZZ):
4862
4870
[((0, 0), 1), ((-1, 6), 1), ((-1, 4), 2), ((-2, 8), 1), ((-2, 6), 1)]
4863
4871
sage: sorted(Y.bigraded_betti_numbers(base_ring=QQ).items(), reverse=True) # needs sage.modules
4864
4872
[((0, 0), 1), ((-1, 4), 3), ((-2, 8), 2), ((-2, 6), 1), ((-3, 10), 1)]
4865
- """
4866
- if base_ring in self ._bbn_all_computed :
4873
+
4874
+ If we wish to view them in a form of a table, it is
4875
+ simple enough to create a function as such::
4876
+
4877
+ sage: def print_table(bbns):
4878
+ ....: max_a = max(-p[0] for p in bbns)
4879
+ ....: max_b = max(p[1] for p in bbns)
4880
+ ....: bbn_table = [[bbns.get((-a,b), 0) for a in range(max_a+1)]
4881
+ ....: for b in range(max_b+1)]
4882
+ ....: width = len(str(max(bbns.values()))) + 1
4883
+ ....: print(' '*width, end=' ')
4884
+ ....: for i in range(max_a+1):
4885
+ ....: print(f'{-i:{width}}', end=' ')
4886
+ ....: print()
4887
+ ....: for j in range(len(bbn_table)):
4888
+ ....: print(f'{j:{width}}', end=' ')
4889
+ ....: for r in bbn_table[j]:
4890
+ ....: print(f'{r:{width}}', end=' ')
4891
+ ....: print()
4892
+ sage: print_table(X.bigraded_betti_numbers())
4893
+ 0 -1 -2
4894
+ 0 1 0 0
4895
+ 1 0 0 0
4896
+ 2 0 0 0
4897
+ 3 0 0 0
4898
+ 4 0 2 0
4899
+ 5 0 0 0
4900
+ 6 0 1 1
4901
+ 7 0 0 0
4902
+ 8 0 0 1
4903
+ """
4904
+ if base_ring in self ._bbn_all_computed and not verbose :
4867
4905
return self ._bbn [base_ring ]
4868
4906
4869
4907
from sage .homology .homology_group import HomologyGroup
@@ -4884,18 +4922,29 @@ def bigraded_betti_numbers(self, base_ring=ZZ):
4884
4922
if ind not in B :
4885
4923
B [ind ] = ZZ .zero ()
4886
4924
B [ind ] += len (H [j - k - 1 ].gens ())
4925
+ if verbose :
4926
+ print ("Non-trivial homology {} in dimension {} of the full subcomplex generated by a set of vertices {}" .format (H [j - k - 1 ], j - k - 1 , x ))
4887
4927
4888
4928
self ._bbn [base_ring ] = B
4889
4929
self ._bbn_all_computed .add (base_ring )
4890
4930
4891
4931
return B
4892
4932
4893
- def bigraded_betti_number (self , a , b , base_ring = ZZ ):
4933
+ def bigraded_betti_number (self , a , b , base_ring = ZZ , verbose = False ):
4894
4934
r"""
4895
4935
Return the bigraded Betti number indexed in the form `(-a, 2b)`.
4896
4936
4897
- Bigraded Betti number with indices `(-a, 2b)` is defined as a sum of ranks
4898
- of `(b-a-1)`-th (co)homologies of full subcomplexes with exactly `b` vertices.
4937
+ Bigraded Betti number with indices `(-a, 2b)` is defined as a
4938
+ sum of ranks of `(b-a-1)`-th (co)homologies of full subcomplexes
4939
+ with exactly `b` vertices.
4940
+
4941
+ INPUT:
4942
+
4943
+ - ``base_ring`` -- (optional, default ``ZZ``) the base ring used
4944
+ when computing homology
4945
+ - ``verbose`` -- (optional, default ``False``) if ``True``, print
4946
+ messages during the computation, which indicate in which subcomplexes
4947
+ non-trivial homologies appear
4899
4948
4900
4949
EXAMPLES::
4901
4950
@@ -4915,12 +4964,18 @@ def bigraded_betti_number(self, a, b, base_ring=ZZ):
4915
4964
2
4916
4965
sage: X.bigraded_betti_number(-1, 8)
4917
4966
0
4967
+ sage: Y = SimplicialComplex([[1,2,3],[1,2,4],[3,5],[4,5]])
4968
+ sage: Y.bigraded_betti_number(-1, 4, verbose=True)
4969
+ Non-trivial homology Z in dimension 0 of the full subcomplex generated by a set of vertices (1, 5)
4970
+ Non-trivial homology Z in dimension 0 of the full subcomplex generated by a set of vertices (2, 5)
4971
+ Non-trivial homology Z in dimension 0 of the full subcomplex generated by a set of vertices (3, 4)
4972
+ 3
4918
4973
"""
4919
4974
if b % 2 :
4920
4975
return ZZ .zero ()
4921
4976
if a == 0 and b == 0 :
4922
4977
return ZZ .one ()
4923
- if base_ring in self ._bbn :
4978
+ if base_ring in self ._bbn and not verbose :
4924
4979
if base_ring in self ._bbn_all_computed :
4925
4980
return self ._bbn [base_ring ].get ((a , b ), ZZ .zero ())
4926
4981
elif (a , b ) in self ._bbn [base_ring ]:
@@ -4939,6 +4994,8 @@ def bigraded_betti_number(self, a, b, base_ring=ZZ):
4939
4994
H = S .homology (base_ring = base_ring )
4940
4995
if b + a - 1 in H and H [b + a - 1 ] != H0 :
4941
4996
B += len (H [b + a - 1 ].gens ())
4997
+ if verbose :
4998
+ print ("Non-trivial homology {} in dimension {} of the full subcomplex generated by a set of vertices {}" .format (H [b + a - 1 ], b + a - 1 , x ))
4942
4999
4943
5000
B = ZZ (B )
4944
5001
0 commit comments