Ticket #15029: trac_15029-review-ts.patch

File trac_15029-review-ts.patch, 28.2 KB (added by tscrim, 6 years ago)
  • sage/combinat/similarity_class_type.py

    # HG changeset patch
    # User Travis Scrimshaw <tscrim@ucdavis.edur>
    # Date 1378742119 25200
    # Node ID 6cb97e9372a9951892ecf0a066c4cc2c12ce8935
    # Parent 0d3b6cc0a691326fa2166704f891e6268fe4ac1e
    #15029: review patch.
    
    diff --git a/sage/combinat/similarity_class_type.py b/sage/combinat/similarity_class_type.py
    a b This makes it possible to perform many c 
    1818as a formal variable.
    1919
    2020In order to define similarity class types, recall that similarity classes of
    21 `n\times n` matrices with entries in `\mathbf{F}_q` correspond to functions
     21`n\times n` matrices with entries in `\GF{q}` correspond to functions
    2222
    2323.. MATH::
    2424
    25     c: \mathrm{Irr}\mathbf{F}_q[t] \to \Lambda
     25    c: \mathrm{Irr}\GF{q[t]} \to \Lambda
    2626
    2727such that
    2828
    2929.. MATH::
    3030
    31     \sum_{f\in \mathrm{Irr}\mathbf{F}_q[t]} |c(f)|\deg f = n,
     31    \sum_{f\in \mathrm{Irr}\GF{q[t]}} |c(f)|\deg f = n,
    3232
    33 where we denote the set of irreducible monic polynomials in `\mathbf{F}_q[t]`
    34 by `\mathrm{Irr}\mathbf{F}_q[t]`, the set of all partitions by `\Lambda`, and
     33where we denote the set of irreducible monic polynomials in `\GF{q[t]}`
     34by `\mathrm{Irr}\GF{q[t]}`, the set of all partitions by `\Lambda`, and
    3535the size of `\lambda \in \Lambda` by `|\lambda|`.
    3636
    3737Similarity classes indexed by functions `c_1` and `c_2` as above are said to be
    3838of the same type if there exists a degree-preserving self-bijection `\sigma` of
    39 `\mathrm{Irr}\mathbf{F}_q[t]` such that `c_2 = c_1\circ \sigma`. Thus, the type
     39`\mathrm{Irr}\GF{q[t]}` such that `c_2 = c_1\circ \sigma`. Thus, the type
    4040of `c` remembers only the degrees of the polynomials (and not the polynomials
    4141themselves) for which `c` takes a certain value `\lambda`. Replacing each
    4242irreducible polynomial of degree `d` for which `c` takes a non-trivial value
    respectively. 
    6161For any matrix `A` in a given similarity class type, it is possible to calculate
    6262the number elements in the similarity class of `A`, the dimension of the algebra
    6363of matrices in `M_n(A)` that commite  with `A`, and the cardinality of the
    64 subgroup of `GL_n(\mathbf{F}_q)` that commute with `A`. For each similarity
     64subgroup of `GL_n(\GF{q})` that commute with `A`. For each similarity
    6565class type, it is also possible to compute the number of classes of that type
    6666(and hence, the total number of matrices of that type). All these calculations
    6767treat the cardinality `q` of the finite field as a formal variable::
    matrices with a given rational canonical 
    9696
    9797Similarity class types can also be used to calculate the number of simultaneous
    9898similarity classes of `k`-tuples of `n\times n` matrices with entries in
    99 `\mathbf{F}_q` by using Burnside's lemma::
     99`\GF{q}` by using Burnside's lemma::
    100100
    101101    sage: from sage.combinat.similarity_class_type import order_of_general_linear_group, centralizer_algebra_dim
    102102    sage: q = ZZ['q'].gen()
    Morrison [Morrison06]_). 
    112112Along with the results of [PSS13]_, similarity class types can be used to
    113113calculate the number of similarity classes of matrices of order `n` with entries
    114114in a principal ideal local ring of length two with residue field of cardinality
    115 `q` with centralizer of any given cardinality up to `n=4`. Among these, the
     115`q` with centralizer of any given cardinality up to `n = 4`. Among these, the
    116116classes which are selftranspose can also be counted::
    117117
    118     sage: from sage.combinat.similarity_class_type import matrix_centralizer_cardinalities2
    119     sage: list(matrix_centralizer_cardinalities2(3))
     118    sage: from sage.combinat.similarity_class_type import matrix_centralizer_cardinalities_length_two
     119    sage: list(matrix_centralizer_cardinalities_length_two(3))
    120120    [(q^6 - 3*q^5 + 3*q^4 - q^3, 1/6*q^6 - 1/2*q^5 + 1/3*q^4),
    121121    (q^6 - 2*q^5 + q^4, q^5 - q^4),
    122122    (q^8 - 3*q^7 + 3*q^6 - q^5, 1/2*q^5 - q^4 + 1/2*q^3),
    classes which are selftranspose can also 
    140140
    141141REFERENCES:
    142142
    143 .. [Green55] Green, J. A.  The characters of the finite general linear groups.
     143.. [Green55] Green, J. A.  *The characters of the finite general linear groups*.
    144144   Trans. Amer. Math. Soc.  80  (1955), 402--447.
    145    Available from: http://dx.doi.org/10.1090/S0002-9947-1955-0072878-2
     145   :doi:`10.1090/S0002-9947-1955-0072878-2`
    146146
    147 .. [Morrison06] Morrison, Kent E. Integer sequences and matrices over finite fields.
     147.. [Morrison06] Morrison, Kent E.
     148   *Integer sequences and matrices over finite fields*.
    148149   J. Integer Seq. 9 (2006), no. 2, Article 06.2.1, 28 pp.
    149    Available from: https://cs.uwaterloo.ca/journals/JIS/VOL9/Morrison/morrison37.html
     150   https://cs.uwaterloo.ca/journals/JIS/VOL9/Morrison/morrison37.html
    150151
    151 .. [PSS13] Prasad, A., Singla, P., and Spallone, S., Similarity of matrices over
    152    local rings of length two. arxiv.org:1212.6157
     152.. [PSS13] Prasad, A., Singla, P., and Spallone, S., *Similarity of matrices
     153   over local rings of length two*. :arxiv:`1212.6157`
    153154
    154155AUTHOR:
    155156
    def fq(n, q = None): 
    222223def primitives(n, invertible = False, q = None):
    223224    """
    224225    Return the number of similarity classes of simple matrices
    225     of order n with entries in a finite field of order ``q``.
     226    of order ``n`` with entries in a finite field of order ``q``.
    226227    This is the same as the number of irreducible polynomials
    227     of degree d.
     228    of degree `d`.
    228229
    229230    If ``invertible`` is ``True``, then only the number of
    230231    similarity classes of invertible matrices is returned.
    def primitives(n, invertible = False, q  
    267268
    268269@cached_function
    269270def order_of_general_linear_group(n, q = None):
    270     """
     271    r"""
    271272    Return the cardinality of the group of `n \times n` invertible matrices
    272273    with entries in a field of order ``q``.
    273274
    def order_of_general_linear_group(n, q = 
    292293@cached_function
    293294def centralizer_algebra_dim(la):
    294295    r"""
    295     Return the dimension of the centralizer algebra in `M_n(\mathbf{F}_q)`
     296    Return the dimension of the centralizer algebra in `M_n(\GF{q})`
    296297    of a nilpotent matrix whose Jordan blocks are given by ``la``.
    297298
    298299    EXAMPLES::
    def centralizer_algebra_dim(la): 
    310311@cached_function
    311312def centralizer_group_cardinality(la, q = None):
    312313    r"""
    313     Return the cardinality of the centralizer group in `GL_n(\mathbf{F}_q)`
     314    Return the cardinality of the centralizer group in `GL_n(\GF{q})`
    314315    of a nilpotent matrix whose Jordan blocks are given by ``la``.
    315316
    316317    INPUT:
    class PrimarySimilarityClassType(Element 
    342343    For a partition `\lambda` and a positive integer `d`, the primary similarity
    343344    class type `(d, \lambda)` represents similarity classes of square matrices
    344345    of order `|\lambda| \cdot d` with entries in a finite field of order `q`
    345     which correspond to the `\mathbf{F}_q[t]`-module
     346    which correspond to the `\GF{q[t]}`-module
    346347
    347348    .. MATH ::
    348349
    349         \frac{\mathbf{F}_q[t]}{p(t)^{\lambda_1} } \oplus
    350         \frac{\mathbf{F}_q[t]}{p(t)^{\lambda_2}} \oplus \dotsb
     350        \frac{\GF{q[t]}}{p(t)^{\lambda_1} } \oplus
     351        \frac{\GF{q[t]}}{p(t)^{\lambda_2}} \oplus \dotsb
    351352
    352353    for some irreducible polynomial `p(t)` of degree `d`.
    353354    """
    class PrimarySimilarityClassType(Element 
    364365            [2, [3, 2, 1]]
    365366
    366367        The parent class is the class of primary similarity class types of order
    367         `d|\lambda\`::
     368        `d |\lambda|`::
    368369
    369370            sage: PT = PrimarySimilarityClassType(2, [3, 2, 1])
    370371            sage: PT.parent().size()
    class PrimarySimilarityClassType(Element 
    477478    @cached_in_parent_method
    478479    def statistic(self, func, q = None):
    479480        r"""
    480         Return `n_\lambda(q^d)` where `n_\lambda` is the value returned by
    481         ``func`` upon input ``\lambda`, if ``self`` is `(d, \lambda)`.
     481        Return `n_{\lambda}(q^d)` where `n_{\lambda}` is the value returned by
     482        ``func`` upon input `\lambda`, if ``self`` is `(d, \lambda)`.
    482483
    483         EXAMPLE::
     484        EXAMPLES::
    484485
    485486            sage: PT = PrimarySimilarityClassType(2, [3, 1])
    486487            sage: q = ZZ['q'].gen()
    class PrimarySimilarityClassType(Element 
    499500
    500501        INPUT:
    501502
    502         ``q`` -- an integer or an indeterminate
     503        - ``q`` -- an integer or an indeterminate
    503504
    504505        EXAMPLES::
    505506
    class PrimarySimilarityClassTypes(Parent 
    525526
    526527    A primary similarity class type of size `n` is a pair `(\lambda, d)`
    527528    consisting of a partition `\lambda` and a positive integer `d` such that
    528     `|\lambda|d = n`.
     529    `|\lambda| d = n`.
    529530
    530531    INPUT:
    531532
    532533    - ``n`` -- a positive integer
    533     - ``min`` -- a primary matrix type of size ``n``.
     534    - ``min`` -- a primary matrix type of size ``n``
    534535
    535536    EXAMPLES:
    536537
    class PrimarySimilarityClassTypes(Parent 
    645646            2
    646647        """
    647648        return self._n
     649
    648650###############################################################################
    649651
    650652###############################################################################
     653
    651654class SimilarityClassType(CombinatorialObject, Element):
    652655    r"""
    653656    A similarity class type.
    class SimilarityClassType(CombinatorialO 
    677680
    678681            sage: tau1 = SimilarityClassType([[3, [3, 2, 1]], [2, [2, 1]]]); tau1
    679682            [[2, [2, 1]], [3, [3, 2, 1]]]
    680             sage: tau2 = SimilarityClassType([PrimarySimilarityClassType(2, [2, 1]), PrimarySimilarityClassType(3, [3, 2, 1])])
     683            sage: types = [PrimarySimilarityClassType(2, [2, 1]), PrimarySimilarityClassType(3, [3, 2, 1])]
     684            sage: tau2 = SimilarityClassType(types)
    681685            sage: tau1 == tau2
    682686            True
    683687
    class SimilarityClassType(CombinatorialO 
    737741
    738742    def centralizer_group_card(self, q = None):
    739743        """
    740         Return the cardinality of the group of matrices in `GL_n(\mathbf{F}_q)`
     744        Return the cardinality of the group of matrices in `GL_n(\GF{q})`
    741745        which commute with a matrix of type ``self``.
    742746
    743747        INPUT:
    class SimilarityClassType(CombinatorialO 
    776780        """
    777781        Return the number of similarity classes of matrices of type ``self``.
    778782
    779         IMPUT:
     783        INPUT:
    780784
    781785        - ``invertible`` -- Boolean; return number of invertible classes if set
    782786          to ``True``
    class SimilarityClassType(CombinatorialO 
    900904        return self.class_card(q = q)*self.number_of_classes(invertible = invertible, q = q)
    901905
    902906    def statistic(self, func, q = None):
    903         """
     907        r"""
    904908        Return
    905909
    906910        .. MATH::
    907911
    908             prod_{(d, \lambda)\in \tau} n_\lambda(q^d)
     912            \prod_{(d, \lambda)\in \tau} n_{\lambda}(q^d)
    909913
    910         where `n_\lambda(q)` is the value returned by ``func`` on the input
     914        where `n_{\lambda}(q)` is the value returned by ``func`` on the input
    911915        `\lambda`.
    912916
    913917        INPUT:
    class SimilarityClassTypes(Parent, Uniqu 
    10371041            8
    10381042
    10391043        A good test of the iterator is to see that all elements of
    1040         `M_n(\mathbf{F}_q)` or `GL_n(\mathbf{F}_q` are enumerated through
     1044        `M_n(\GF{q})` or `GL_n(\GF{q})` are enumerated through
    10411045        types::
    10421046
    10431047            sage: from sage.combinat.similarity_class_type import order_of_general_linear_group
    class SimilarityClassTypes(Parent, Uniqu 
    10661070
    10671071    def size(self):
    10681072        """
    1069         Return size of ``self``
     1073        Return size of ``self``.
    10701074
    10711075        EXAMPLES::
    10721076
    class SimilarityClassTypes(Parent, Uniqu 
    10771081        return self._n
    10781082
    10791083    def sum(self, stat, sumover = "matrices", invertible = False, q = None):
    1080         """
     1084        r"""
    10811085        Return the sum of a local statistic over all types.
    10821086
    1083         Given a set of functions `n_\lambda(q)` (these could be polynomials or
     1087        Given a set of functions `n_{\lambda}(q)` (these could be polynomials or
    10841088        rational functions in `q`, for each similarity class type `\tau` define
    10851089
    10861090        .. MATH::
    10871091
    1088             n_\tau(q) = \prod_{(d,\lambda)\in \tau} n_\lambda(q^d).
     1092            n_\tau(q) = \prod_{(d,\lambda)\in \tau} n_{\lambda}(q^d).
    10891093
    10901094        This function returns
    10911095
    class SimilarityClassTypes(Parent, Uniqu 
    10931097
    10941098            \sum n_{\tau(g)}(q)
    10951099
    1096         where `tau(g)` denotes the type of a matrix `g`, and the sum is over
    1097         all `n\times n` matrices if ``sumover`` is set to "matrices", is over
    1098         all `n\times n` similarity classes if ``sumover`` is set to "classes",
    1099         and over all `n\times n` types if ``sumover`` is set to types. If
    1100         ``invertible`` is set to ``True``, then the sum is only over invertible
    1101         matrices or classes.
     1100        where `\tau(g)` denotes the type of a matrix `g`, and the sum is over
     1101        all `n \times n` matrices if ``sumover`` is set to ``"matrices"``, is
     1102        over all `n \times n` similarity classes if ``sumover`` is set to
     1103        ``"classes"``, and over all `n \times n` types if ``sumover`` is set
     1104        to ``"types"``. If ``invertible`` is set to ``True``, then the sum is
     1105        only over invertible matrices or classes.
    11021106
    11031107        INPUT:
    11041108
    11051109        - ``stat`` -- a function which takes partitions and returns a function
    11061110          of ``q``
    1107         - ``sumover`` -- a parameter, either "matrices", "classes" or "types"
     1111        - ``sumover`` -- can be one of the following:
     1112
     1113          * ``"matrices"``
     1114          * ``"classes"``
     1115          * ``"types"``
     1116
    11081117        - ``q`` -- an integer or an indeterminate
    11091118
    11101119        OUTPUT:
    class SimilarityClassTypes(Parent, Uniqu 
    11461155
    11471156def dictionary_from_generator(gen):
    11481157    r"""
    1149     Given a generator for a list of pairs `(c,f)` construct a dictionary whose
     1158    Given a generator for a list of pairs `(c,f)`, construct a dictionary whose
    11501159    keys are the distinct values for `c` and whose value at `c` is the sum of
    11511160    `f` over all pairs of the form `(c',f)` such that `c=c'`.
    11521161
    def matrix_similarity_classes(n, q = Non 
    11911200        return 1
    11921201    if invertible:
    11931202        return sum([q**max(la)*((1-q**(-1))**map(lambda x: x>0, la.to_exp()).count(True)) for la in Partitions(n)])
    1194     else:
    1195         return sum([q**max(la) for la in Partitions(n)])
     1203    return sum([q**max(la) for la in Partitions(n)])
    11961204
    11971205def matrix_centralizer_cardinalities(n, q = None, invertible = False):
    11981206    """
    def matrix_centralizer_cardinalities(n,  
    12141222        (q^2 - q, q - 1),
    12151223        (q^4 - q^3 - q^2 + q, q - 1),
    12161224        (q^2 - 1, 1/2*q^2 - 1/2*q)]
    1217 
    12181225    """
    12191226    for tau in SimilarityClassTypes(n):
    12201227        yield (tau.centralizer_group_card(q = q), tau.number_of_classes(invertible = invertible, q = q))
    12211228
    12221229def input_parsing(data):
    12231230    """
    1224     Recognize and return the intended type of ``input``
     1231    Recognize and return the intended type of ``input``.
    12251232
    12261233    TESTS::
    12271234
    def input_parsing(data): 
    12671274                    raise ValueError("Expected a Partition, a SimiliarityClassType or a PrimarySimilarityClassType, got a %s"%(type(data)))
    12681275    return case, data
    12691276
    1270 def ext_orbits(input, q = None, selftranspose = False):
     1277def ext_orbits(input_data, q = None, selftranspose = False):
    12711278    r"""
    12721279    Return the number of orbits in `\mathrm{Ext}^1(M, M)` for the action of
    1273     `\mathrm{Aut}(M, M)`, where `M` is the `\mathbf F_q[t]`-module constructed
    1274     from ``input``.
     1280    `\mathrm{Aut}(M, M)`, where `M` is the `\GF{q[t]}`-module constructed
     1281    from ``input_data``.
     1282
     1283    INPUT:
     1284
     1285    - ``input_data`` -- input for :func:`input_parsing()`
     1286    - ``q`` -- (default: `q`) an integer or an indeterminate
     1287    - ``selftranspose`` -- (default: ``False``) boolean stating if we only want
     1288      selftranspose type
    12751289
    12761290    TESTS::
    12771291
    def ext_orbits(input, q = None, selftran 
    13051319    # Prasad, Singla, and Spallone.
    13061320    if q is None:
    13071321        q = FractionField(QQ['q']).gen()
    1308     case, data = input_parsing(input)
     1322    case, data = input_parsing(input_data)
    13091323    if case == 'par':
    13101324        la = data
    13111325        if la.size() == 0:
    def ext_orbits(input, q = None, selftran 
    13271341            else:
    13281342                return q**m*(q**3 + 2*q**2)
    13291343        elif min(la) == 2 and max(la) == 2:
    1330             return matrix_similarity_classes2(len(la), q = q, selftranspose = selftranspose)
     1344            return matrix_similarity_classes_length_two(len(la), q = q, selftranspose = selftranspose)
    13311345        else:
    13321346            raise ValueError('partition %s not implemented for ExtOrbitClasses.orbits'%(la))
    13331347    elif case == 'pri':
    def ext_orbits(input, q = None, selftran 
    13371351        tau = data
    13381352        return prod([ext_orbits(PT, q = q, selftranspose = selftranspose) for PT in tau])
    13391353
    1340 def matrix_similarity_classes2(n, q = None, selftranspose = False, invertible = False):
     1354def matrix_similarity_classes_length_two(n, q = None, selftranspose = False, invertible = False):
    13411355    """
    13421356    Return the number of similarity classes of matrices of order ``n`` with
    13431357    entries in a principal ideal local ring of length two.
    13441358
     1359    INPUT:
     1360
     1361    - ``n`` -- the order
     1362    - ``q`` -- (default: `q`) an integer or an indeterminate
     1363    - ``selftranspose`` -- (default: ``False``) boolean stating if we only want
     1364      selftranspose type
     1365    - ``invertible`` -- (default: ``False``) boolean stating if we only want
     1366      invertible type
     1367
    13451368    EXAMPLES:
    13461369
    13471370    We can generate Table 6 of [PSS13]_::
    13481371
    1349         sage: from sage.combinat.similarity_class_type import matrix_similarity_classes2
    1350         sage: matrix_similarity_classes2(2)
     1372        sage: from sage.combinat.similarity_class_type import matrix_similarity_classes_length_two
     1373        sage: matrix_similarity_classes_length_two(2)
    13511374        q^4 + q^3 + q^2
    1352         sage: matrix_similarity_classes2(2, invertible = True)
     1375        sage: matrix_similarity_classes_length_two(2, invertible = True)
    13531376        q^4 - q
    1354         sage: matrix_similarity_classes2(3)
     1377        sage: matrix_similarity_classes_length_two(3)
    13551378        q^6 + q^5 + 2*q^4 + q^3 + 2*q^2
    1356         sage: matrix_similarity_classes2(3, invertible = true)
     1379        sage: matrix_similarity_classes_length_two(3, invertible = true)
    13571380        q^6 - q^3 + 2*q^2 - 2*q
    1358         sage: matrix_similarity_classes2(4)
     1381        sage: matrix_similarity_classes_length_two(4)
    13591382        q^8 + q^7 + 3*q^6 + 3*q^5 + 5*q^4 + 3*q^3 + 3*q^2
    1360         sage: matrix_similarity_classes2(4, invertible = True)
     1383        sage: matrix_similarity_classes_length_two(4, invertible = True)
    13611384        q^8 + q^6 - q^5 + 2*q^4 - 2*q^3 + 2*q^2 - 3*q
    13621385
    13631386    And also Table 7::
    13641387
    1365         sage: matrix_similarity_classes2(2, selftranspose = True)
     1388        sage: matrix_similarity_classes_length_two(2, selftranspose = True)
    13661389        q^4 + q^3 + q^2
    1367         sage: matrix_similarity_classes2(2, selftranspose = True, invertible = True)
     1390        sage: matrix_similarity_classes_length_two(2, selftranspose = True, invertible = True)
    13681391        q^4 - q
    1369         sage: matrix_similarity_classes2(3, selftranspose = True)
     1392        sage: matrix_similarity_classes_length_two(3, selftranspose = True)
    13701393        q^6 + q^5 + 2*q^4 + q^3
    1371         sage: matrix_similarity_classes2(3, selftranspose = True, invertible = True)
     1394        sage: matrix_similarity_classes_length_two(3, selftranspose = True, invertible = True)
    13721395        q^6 - q^3
    1373         sage: matrix_similarity_classes2(4, selftranspose = True)
     1396        sage: matrix_similarity_classes_length_two(4, selftranspose = True)
    13741397        q^8 + q^7 + 3*q^6 + 3*q^5 + 3*q^4 + q^3 + q^2
    1375         sage: matrix_similarity_classes2(4, selftranspose = True, invertible = True)
     1398        sage: matrix_similarity_classes_length_two(4, selftranspose = True, invertible = True)
    13761399        q^8 + q^6 - q^5 - q
    13771400    """
    13781401    if q is None:
    13791402        q = FractionField(QQ['q']).gen()
    13801403    return sum([tau.number_of_classes(invertible = invertible, q = q)*ext_orbits(tau, q = q, selftranspose = selftranspose) for tau in SimilarityClassTypes(n)])
    13811404
    1382 def ext_orbit_centralizers(input, q = None, selftranspose = False):
     1405def ext_orbit_centralizers(input_data, q = None, selftranspose = False):
    13831406    r"""
    13841407    Generate pairs consisting of centralizer cardinalities of orbits in
    13851408    `\mathrm{Ext}^1(M, M)` for the action of `\mathrm{Aut}(M, M)`, where `M` is
    1386     the `\mathbf F_q[t]`-module constructed from ``input`` and their frequencies.
     1409    the `\GF{q[t]}`-module constructed from ``input`` and their frequencies.
     1410
     1411    INPUT:
     1412
     1413    - ``input_data`` -- input for :func:`input_parsing()`
     1414    - ``q`` -- (default: `q`) an integer or an indeterminate
     1415    - ``selftranspose`` -- (default: ``False``) boolean stating if we only want
     1416      selftranspose type
    13871417
    13881418    TESTS::
    13891419
    13901420        sage: from sage.combinat.similarity_class_type import ext_orbit_centralizers
    13911421        sage: list(ext_orbit_centralizers([6, 1]))
    13921422        [(q^9 - 2*q^8 + q^7, q^6),
    1393         (q^7 - 2*q^6 + q^5, q^7 - q^6),
    1394         (q^7 - q^6, q^6 + q^5)]
     1423         (q^7 - 2*q^6 + q^5, q^7 - q^6),
     1424         (q^7 - q^6, q^6 + q^5)]
    13951425        sage: list(ext_orbit_centralizers([6, 1], selftranspose = True))
    13961426        [(q^9 - 2*q^8 + q^7, q^6),
    1397         (q^7 - 2*q^6 + q^5, q^7 - q^6),
    1398         (q^7 - q^6, q^6 - q^5)]
     1427         (q^7 - 2*q^6 + q^5, q^7 - q^6),
     1428         (q^7 - q^6, q^6 - q^5)]
    13991429        sage: list(ext_orbit_centralizers([6, 1, 1]))
    14001430        [(q^12 - 3*q^11 + 3*q^10 - q^9, 1/2*q^7 - 1/2*q^6),
    1401         (q^8 - 3*q^7 + 3*q^6 - q^5, 1/2*q^8 - q^7 + 1/2*q^6),
    1402         (q^12 - 2*q^11 + q^10, q^6),
    1403         (q^8 - 2*q^7 + q^6, q^7 - q^6),
    1404         (q^14 - 2*q^13 + 2*q^11 - q^10, q^6),
    1405         (q^10 - 2*q^9 + 2*q^7 - q^6, q^7 - q^6),
    1406         (q^12 - q^11 - q^10 + q^9, 1/2*q^7 - 1/2*q^6),
    1407         (q^8 - q^7 - q^6 + q^5, 1/2*q^8 - q^7 + 1/2*q^6),
    1408         (q^8 - 2*q^7 + q^6, q^7 - q^6),
    1409         (q^8 - q^7, q^6 + 2*q^5),
    1410         (q^10 - 2*q^9 + q^8, 2*q^6)]
     1431         (q^8 - 3*q^7 + 3*q^6 - q^5, 1/2*q^8 - q^7 + 1/2*q^6),
     1432         (q^12 - 2*q^11 + q^10, q^6),
     1433         (q^8 - 2*q^7 + q^6, q^7 - q^6),
     1434         (q^14 - 2*q^13 + 2*q^11 - q^10, q^6),
     1435         (q^10 - 2*q^9 + 2*q^7 - q^6, q^7 - q^6),
     1436         (q^12 - q^11 - q^10 + q^9, 1/2*q^7 - 1/2*q^6),
     1437         (q^8 - q^7 - q^6 + q^5, 1/2*q^8 - q^7 + 1/2*q^6),
     1438         (q^8 - 2*q^7 + q^6, q^7 - q^6),
     1439         (q^8 - q^7, q^6 + 2*q^5),
     1440         (q^10 - 2*q^9 + q^8, 2*q^6)]
    14111441        sage: list(ext_orbit_centralizers([6, 1, 1], selftranspose = True))
    14121442        [(q^12 - 3*q^11 + 3*q^10 - q^9, 1/2*q^7 - 1/2*q^6),
    1413         (q^8 - 3*q^7 + 3*q^6 - q^5, 1/2*q^8 - q^7 + 1/2*q^6),
    1414         (q^12 - 2*q^11 + q^10, q^6),
    1415         (q^8 - 2*q^7 + q^6, q^7 - q^6),
    1416         (q^14 - 2*q^13 + 2*q^11 - q^10, q^6),
    1417         (q^10 - 2*q^9 + 2*q^7 - q^6, q^7 - q^6),
    1418         (q^12 - q^11 - q^10 + q^9, 1/2*q^7 - 1/2*q^6),
    1419         (q^8 - q^7 - q^6 + q^5, 1/2*q^8 - q^7 + 1/2*q^6),
    1420         (q^8 - 2*q^7 + q^6, q^7 - q^6),
    1421         (q^8 - q^7, q^6)]
     1443         (q^8 - 3*q^7 + 3*q^6 - q^5, 1/2*q^8 - q^7 + 1/2*q^6),
     1444         (q^12 - 2*q^11 + q^10, q^6),
     1445         (q^8 - 2*q^7 + q^6, q^7 - q^6),
     1446         (q^14 - 2*q^13 + 2*q^11 - q^10, q^6),
     1447         (q^10 - 2*q^9 + 2*q^7 - q^6, q^7 - q^6),
     1448         (q^12 - q^11 - q^10 + q^9, 1/2*q^7 - 1/2*q^6),
     1449         (q^8 - q^7 - q^6 + q^5, 1/2*q^8 - q^7 + 1/2*q^6),
     1450         (q^8 - 2*q^7 + q^6, q^7 - q^6),
     1451         (q^8 - q^7, q^6)]
    14221452        sage: list(ext_orbit_centralizers([2, [6, 1, 1]], selftranspose = True))
    14231453        [(q^24 - 3*q^22 + 3*q^20 - q^18, 1/2*q^14 - 1/2*q^12),
    1424         (q^16 - 3*q^14 + 3*q^12 - q^10, 1/2*q^16 - q^14 + 1/2*q^12),
    1425         (q^24 - 2*q^22 + q^20, q^12),
    1426         (q^16 - 2*q^14 + q^12, q^14 - q^12),
    1427         (q^28 - 2*q^26 + 2*q^22 - q^20, q^12),
    1428         (q^20 - 2*q^18 + 2*q^14 - q^12, q^14 - q^12),
    1429         (q^24 - q^22 - q^20 + q^18, 1/2*q^14 - 1/2*q^12),
    1430         (q^16 - q^14 - q^12 + q^10, 1/2*q^16 - q^14 + 1/2*q^12),
    1431         (q^16 - 2*q^14 + q^12, q^14 - q^12),
    1432         (q^16 - q^14, q^12)]
     1454         (q^16 - 3*q^14 + 3*q^12 - q^10, 1/2*q^16 - q^14 + 1/2*q^12),
     1455         (q^24 - 2*q^22 + q^20, q^12),
     1456         (q^16 - 2*q^14 + q^12, q^14 - q^12),
     1457         (q^28 - 2*q^26 + 2*q^22 - q^20, q^12),
     1458         (q^20 - 2*q^18 + 2*q^14 - q^12, q^14 - q^12),
     1459         (q^24 - q^22 - q^20 + q^18, 1/2*q^14 - 1/2*q^12),
     1460         (q^16 - q^14 - q^12 + q^10, 1/2*q^16 - q^14 + 1/2*q^12),
     1461         (q^16 - 2*q^14 + q^12, q^14 - q^12),
     1462         (q^16 - q^14, q^12)]
    14331463        sage: list(ext_orbit_centralizers([[2, [6, 1, 1]]], selftranspose = True))
    14341464        [(q^24 - 3*q^22 + 3*q^20 - q^18, 1/2*q^14 - 1/2*q^12),
    1435         (q^16 - 3*q^14 + 3*q^12 - q^10, 1/2*q^16 - q^14 + 1/2*q^12),
    1436         (q^24 - 2*q^22 + q^20, q^12),
    1437         (q^16 - 2*q^14 + q^12, q^14 - q^12),
    1438         (q^28 - 2*q^26 + 2*q^22 - q^20, q^12),
    1439         (q^20 - 2*q^18 + 2*q^14 - q^12, q^14 - q^12),
    1440         (q^24 - q^22 - q^20 + q^18, 1/2*q^14 - 1/2*q^12),
    1441         (q^16 - q^14 - q^12 + q^10, 1/2*q^16 - q^14 + 1/2*q^12),
    1442         (q^16 - 2*q^14 + q^12, q^14 - q^12),
    1443         (q^16 - q^14, q^12)]
    1444 
     1465         (q^16 - 3*q^14 + 3*q^12 - q^10, 1/2*q^16 - q^14 + 1/2*q^12),
     1466         (q^24 - 2*q^22 + q^20, q^12),
     1467         (q^16 - 2*q^14 + q^12, q^14 - q^12),
     1468         (q^28 - 2*q^26 + 2*q^22 - q^20, q^12),
     1469         (q^20 - 2*q^18 + 2*q^14 - q^12, q^14 - q^12),
     1470         (q^24 - q^22 - q^20 + q^18, 1/2*q^14 - 1/2*q^12),
     1471         (q^16 - q^14 - q^12 + q^10, 1/2*q^16 - q^14 + 1/2*q^12),
     1472         (q^16 - 2*q^14 + q^12, q^14 - q^12),
     1473         (q^16 - q^14, q^12)]
    14451474    """
    14461475    # Comments cite items in the paper "Similarity over rings of length two" by
    14471476    # Prasad, Singla, and Spallone.
    14481477    if q is None:
    14491478        q = FractionField(QQ['q']).gen()
    1450     case, data = input_parsing(input)
     1479    case, data = input_parsing(input_data)
    14511480    if case == 'par':
    14521481        la = data
    14531482        if len(la) == 0:
    def ext_orbit_centralizers(input, q = No 
    14821511                yield (q**(m + 5) - 2*q**(m + 4) + q**(m + 3), 2*q**(m + 1)) # (8.6.6) and (8.6.8)
    14831512            return
    14841513        elif max(la) == 2 and min(la) == 2:
    1485             for item in matrix_centralizer_cardinalities2(len(la), q = q, selftranspose = selftranspose):
     1514            for item in matrix_centralizer_cardinalities_length_two(len(la), q = q, selftranspose = selftranspose):
    14861515                yield item
    14871516        else:
    14881517            raise ValueError('partition %s not implemented for ExtOrbitClasses.orbit_centralizers'%(la))
    def ext_orbit_centralizers(input, q = No 
    14981527                yield(size, freq)
    14991528
    15001529
    1501 def matrix_centralizer_cardinalities2(n, q = None, selftranspose = False, invertible = False):
     1530def matrix_centralizer_cardinalities_length_two(n, q = None, selftranspose = False, invertible = False):
    15021531    r"""
    1503     Generate  pairs consisting of centralizer cardinalities of matrices over a
     1532    Generate pairs consisting of centralizer cardinalities of matrices over a
    15041533    principal ideal local ring of length two with residue field of order ``q``
    15051534    and their frequencies.
    15061535
     1536    INPUT:
     1537
     1538    - ``n`` -- the order
     1539    - ``q`` -- (default: `q`) an integer or an indeterminate
     1540    - ``selftranspose`` -- (default: ``False``) boolean stating if we only want
     1541      selftranspose type
     1542    - ``invertible`` -- (default: ``False``) boolean stating if we only want
     1543      invertible type
     1544
    15071545    TESTS::
    15081546
    1509         sage: from sage.combinat.similarity_class_type import matrix_centralizer_cardinalities2
    1510         sage: list(matrix_centralizer_cardinalities2(1))
     1547        sage: from sage.combinat.similarity_class_type import matrix_centralizer_cardinalities_length_two
     1548        sage: list(matrix_centralizer_cardinalities_length_two(1))
    15111549        [(q^2 - q, q^2)]
    1512         sage: list(matrix_centralizer_cardinalities2(2))
     1550        sage: list(matrix_centralizer_cardinalities_length_two(2))
    15131551        [(q^4 - 2*q^3 + q^2, 1/2*q^4 - 1/2*q^3),
    15141552        (q^4 - q^3, q^3),
    15151553        (q^6 - 2*q^5 + q^4, 1/2*q^3 - 1/2*q^2),
    def matrix_centralizer_cardinalities2(n, 
    15181556        (q^6 - q^4, 1/2*q^3 - 1/2*q^2),
    15191557        (q^4 - q^2, 1/2*q^4 - 1/2*q^3)]
    15201558        sage: from sage.combinat.similarity_class_type import dictionary_from_generator
    1521         sage: dictionary_from_generator(matrix_centralizer_cardinalities2(2, q = 2))
     1559        sage: dictionary_from_generator(matrix_centralizer_cardinalities_length_two(2, q = 2))
    15221560        {96: 4, 32: 4, 4: 4, 16: 2, 8: 8, 12: 4, 48: 2}
    15231561    """
    15241562    if q is None:
    def matrix_centralizer_cardinalities2(n, 
    15261564    for tau in SimilarityClassTypes(n):
    15271565        for pair in ext_orbit_centralizers(tau, q = q, selftranspose = selftranspose):
    15281566            yield (q**tau.centralizer_algebra_dim()*pair[0], tau.number_of_classes(invertible = invertible, q = q)*pair[1])
     1567