Ticket #13725: trac_13725-sum-complex-review-ts.patch

File trac_13725-sum-complex-review-ts.patch, 5.2 KB (added by tscrim, 8 years ago)
  • sage/homology/examples.py

    # HG changeset patch
    # User Travis Scrimshaw <tscrim@ucdavis.edu>
    # Date 1355267723 28800
    # Node ID 36fb4e873ecbeecbd8a310857f85f17c955d07c3
    # Parent  0e80cec881aba827ace0ef2fc48979ff64280a55
    Review patch for #13725.
    
    diff --git a/sage/homology/examples.py b/sage/homology/examples.py
    a b class SimplicialComplexExamples(): 
    10641064
    10651065    def SumComplex(self, n, A):
    10661066        r"""
    1067         The sum complexes of Linial, Meshulam, and Rosenthal.
    1068 
    1069         INPUT:
    1070 
    1071         - ``n``, a positive integer
    1072         - ``A``, a subset of `\ZZ/(n)`
     1067        The sum complexes of Linial, Meshulam, and Rosenthal [LMR2010]_.
    10731068
    10741069        If `k+1` is the cardinality of `A`, then this returns a
    10751070        `k`-dimensional simplicial complex `X_A` with vertices
    class SimplicialComplexExamples(): 
    10901085        4-dimensional complex on 13 vertices with `H_3` having a
    10911086        cyclic summand of order
    10921087
    1093         .. math::
     1088        .. MATH::
    10941089   
    1095             706565607945 = 3 \times 5 \times 53 \times 79 \times 131
    1096             \times 157 \times 547.
     1090            706565607945 = 3 \cdot 5 \cdot 53 \cdot 79 \cdot 131
     1091            \cdot 157 \cdot 547.
    10971092
    10981093        See the examples.
    10991094
     1095        INPUT:
     1096
     1097        - ``n`` -- a positive integer
     1098
     1099        - ``A`` -- a subset of `\ZZ/(n)`
     1100
    11001101        REFERENCES:
    11011102
    11021103        .. [LMR2010] N. Linial, R. Meshulam and M. Rosenthal, "Sum
    class SimplicialComplexExamples(): 
    11061107
    11071108        EXAMPLES::
    11081109
    1109             sage: simplicial_complexes.SumComplex(10, [0,1,2,3,6]).homology()
     1110            sage: S = simplicial_complexes.SumComplex(10, [0,1,2,3,6]); S
     1111            Simplicial complex with 10 vertices and 126 facets
     1112            sage: S.homology()
    11101113            {0: 0, 1: 0, 2: 0, 3: C2728, 4: 0}
    11111114            sage: factor(2728)
    11121115            2^3 * 11 * 31
    11131116
    1114             sage: simplicial_complexes.SumComplex(11, [0, 1, 3]).homology(1)
     1117            sage: S = simplicial_complexes.SumComplex(11, [0, 1, 3]); S
     1118            Simplicial complex with 11 vertices and 45 facets
     1119            sage: S.homology(1)
    11151120            C23
    1116             sage: simplicial_complexes.SumComplex(11, [0,1,2,3,4,7]).homology() # long time
     1121            sage: S = simplicial_complexes.SumComplex(11, [0,1,2,3,4,7]); S
     1122            Simplicial complex with 11 vertices and 252 facets
     1123            sage: S.homology() # long time
    11171124            {0: 0, 1: 0, 2: 0, 3: 0, 4: C645679, 5: 0}
    11181125            sage: factor(645679)
    11191126            23 * 67 * 419
    11201127
    1121             sage: simplicial_complexes.SumComplex(13, [0, 1, 3]).homology(1)
     1128            sage: S = simplicial_complexes.SumComplex(13, [0, 1, 3]); S
     1129            Simplicial complex with 13 vertices and 66 facets
     1130            sage: S.homology(1)
    11221131            C159
    11231132            sage: factor(159)
    11241133            3 * 53
    1125             sage: simplicial_complexes.SumComplex(13, [0,1,2,5]).homology() # long time
     1134            sage: S = simplicial_complexes.SumComplex(13, [0,1,2,5]); S
     1135            Simplicial complex with 13 vertices and 220 facets
     1136            sage: S.homology() # long time
    11261137            {0: 0, 1: 0, 2: C146989209, 3: 0}
    11271138            sage: factor(1648910295)
    11281139            3^2 * 5 * 53 * 521 * 1327
    1129             sage: simplicial_complexes.SumComplex(13, [0,1,2,3,5]).homology() # long time
     1140            sage: S = simplicial_complexes.SumComplex(13, [0,1,2,3,5]); S
     1141            Simplicial complex with 13 vertices and 495 facets
     1142            sage: S.homology() # long time
    11301143            {0: 0, 1: 0, 2: 0, 3: C3 x C237 x C706565607945, 4: 0}
    11311144            sage: factor(706565607945)
    11321145            3 * 5 * 53 * 79 * 131 * 157 * 547
    11331146
    1134             sage: simplicial_complexes.SumComplex(17, [0, 1, 4]).homology(1)
     1147            sage: S = simplicial_complexes.SumComplex(17, [0, 1, 4]); S
     1148            Simplicial complex with 17 vertices and 120 facets
     1149            sage: S.homology(1)
    11351150            C140183
    11361151            sage: factor(140183)
    11371152            103 * 1361
    1138             sage: simplicial_complexes.SumComplex(19, [0, 1, 4]).homology(1)
     1153            sage: S = simplicial_complexes.SumComplex(19, [0, 1, 4]); S
     1154            Simplicial complex with 19 vertices and 153 facets
     1155            sage: S.homology(1)
    11391156            C5670599
    11401157            sage: factor(5670599)
    11411158            11 * 191 * 2699
    1142             sage: simplicial_complexes.SumComplex(31, [0, 1, 4]).homology(1) # long time
     1159            sage: S = simplicial_complexes.SumComplex(31, [0, 1, 4]); S
     1160            Simplicial complex with 31 vertices and 435 facets
     1161            sage: S.homology(1) # long time
    11431162            C5 x C5 x C5 x C5 x C26951480558170926865
    11441163            sage: factor(26951480558170926865)
    11451164            5 * 311 * 683 * 1117 * 11657 * 1948909
    11461165        """
    11471166        from sage.rings.all import Integers
    1148         from sage.sets.set import Set
    1149         from sage.homology.all import SimplicialComplex
    11501167        Zn = Integers(n)
    11511168        A = frozenset([Zn(x) for x in A])
    1152         k = len(A) - 1
    11531169        facets = []
    1154         for f in Set(Zn).subsets(k+1):
     1170        for f in Set(Zn).subsets(len(A)):
    11551171            if sum(f) in A:
    11561172                facets.append(tuple(f))
    1157         return SimplicialComplex(facets)
     1173        return SimplicialComplex(facets, is_mutable=False)
    11581174
    11591175simplicial_complexes = SimplicialComplexExamples()