コード例 #1
0
def mul_Ty(tag, octad, sub, g):
    d = m24.octad_to_gcode(octad)
    c = m24.suboctad_to_cocode(sub, d)
    e = g.pl
    c1 = m24.ploop_cap(d, e) ^ c
    sub1 = m24.cocode_to_suboctad(c1, d)
    s = m24.scalar_prod(e, c)
    return s, tag, octad, sub1
コード例 #2
0
def index_suboctad(tag, i, index_type_T=3, a_indices_T=None):
    """Convert an index specifying an suboctad number

    0 <= 'i' < 64 is an index specifying the number of a suboctad
    in the Golay cocode. Here a suboctad is a Golay cocode word
    which can be represented a subset of of an octad. For each
    octad there is a lexicographic numbering of its suboctad, and
    index 'i' refers to that lexicographic numbering. 

    This index type occurs as the second index of tag T only,
    so the first index of that tag gives us a reference octad. 
    If 'i' is of type Cocode or GcVector, corresponding to a 
    Golay cocode word, that cocode word is taken if it fits into 
    the reference octad; otherwise we raise ValueError. 

    The function returns triple

      (index_type, a_indices, sign).

    Here index_type indicates whether the index has been selected
    ar random, or whether it refers to a slice, as in function 
    index_I().

    The index or the indices making up the slice are returned in
    the numpy array 'a_indices', as in function index_I(). In any
    case the numbers in that array are suboctad numbers.

    Parameters ('index_type_T', 'a_indices_T') must be the values 
    (index_type, a_indices) returned by function index_T(), when
    called with the first index for tag T.
    
    The second index of tag T is of this type. Parameter 'tag' is
    for compatibility with similar functions; it must be 'T'.		 
    """
    if isinstance(i, Integral):
        if 0 <= i < 64:
            return 0, i, 0
        raise IndexError(INDEX_ERROR_RANGE % ("Second ", tag))
    elif isinstance(i, str):
        if i in ["r", "n"]:
            return INDEX_IS_RANDOM, randint(0, 63), 0
        raise IndexError(INDEX_ERROR_RAND % tag)
    elif isinstance(i, slice):
        return INDEX_IS_SLICE, a_slice(i, 64), 0
    elif isinstance(i, (GCode, Cocode, GcVector)):
        if index_type_T == 0:
            gcode = mat24.octad_to_gcode(a_indices_T) & 0xfff
            if isinstance(i, GCode):
                cocode = mat24.ploop_cap(gcode, i)
            else:
                cocode = Cocode(i).cocode
            sub = mat24.cocode_to_suboctad(cocode, gcode)
            return 0, sub, 0
        err = "Second vector index for tag T must be integer here"
        raise TypeError(err)
    elif isinstance(i, Iterable):
        return index_iterable(index, 64, tag, 2)
    raise TypeError(INDEX_ERROR_TYPE % ("Second ", type(i), tag))
コード例 #3
0
def mul_Tp(tag, octad, sub, g):
    d = m24.octad_to_gcode(octad)
    c = m24.suboctad_to_cocode(sub, d)
    eps, pi, rep = g.cocode, g.perm, g.rep
    d1 = m24.op_ploop_autpl(d, rep)
    c1 = m24.op_cocode_perm(c, pi)
    s = d1 >> 12
    s ^= (eps >> 11) & 1 & m24.suboctad_weight(sub)
    octad1 = m24.gcode_to_octad(d1)
    sub1 = m24.cocode_to_suboctad(c1, d1)
    return s, tag, octad1, sub1
コード例 #4
0
def _as_suboctad(v1, o):
    d = m24.octad_to_gcode(o)
    c = m24.ploop_cap(v1, d)
    return m24.cocode_to_suboctad(c, d)
コード例 #5
0
def SubOctad(octad, suboctad=0):
    """Creates a suboctad as instance of class |XLeech2|

    :param octad:

      The first component of the pair *(octad, suboctad)* to be 
      created.

    :type octad: same as in function
      :py:class:`~mmgroup.Octad`

    :param suboctad:
    
      The second component of the pair 
      *(octad, suboctad)* to be created.

    :type suboctad: see table below for legal types


    :return: 

     The suboctad given by the pair *(octad, suboctad)* 

    :rtype: an instance of class |XLeech2|

    :raise:
        * TypeError if one of the arguments *octad* or *suboctad* 
          is not of correct type.
        * ValueError if argument *octad* or *suboctad* does not
          evaluate to an octad or to a correct suboctad,
          respectively.
    

    A *suboctad* is an even cocode element that can be represented
    as a subset of the octad given by the argument *octad*. 

    The raison d'etre of function ``SubOctad`` is that pairs
    *(octad, suboctad)* are used for indexing vectors in the
    representation of the monster group. Here we want to 
    number the octads from ``0`` to ``758`` and the suboctads
    form ``0`` to ``63``, depending on the octad. Note that
    every octad has ``64``  suboctads.

    Depending on its type parameter **suboctad** is  interpreted as follows:

    .. table:: Legal types for parameter ``suboctad``
      :widths: 20 80

      ===================== ================================================
      type                  Evaluates to
      ===================== ================================================
      ``int``               Here the suboctad with the number given 
                            in the argument is 
                            taken.  That numbering depends on the octad 
                            given in   the argument ``octad``. 
                            ``0 <= suboctad < 64`` must hold.                           

      ``list`` of ``int``   Such a list is converted to a bit vector
                            as in class |GcVector|,
                            and the cocode element corresponding to that
                            bit vector is taken.

       class |GCode|        The intersection of the octad given as the 
                            first argument and the Golay code word given
                            as the second argument is taken. 
  
       class |GcVector|     This is converted to a cocode element,
                            see class |Cocode|, and that cocode element 
                            is taken.

       class |Cocode|       That cocode element is taken as the suboctad.


      ``str``               Create random element depending on the string
                             | ``'r'``: Create arbitrary suboctad
      ===================== ================================================

    The numbering of the suboctads

    Suboctads are numbered for 0 to 63. Let ``[b0, b1,..., b7]`` be the 
    bits set in the octad of the pair ``(octad, suboctad)`` in natural 
    order. The following table shows the suboctad numbers for some 
    suboctads given as cocode elements. More suboctad numbers can be 
    obtained by combining suboctads and their corresponding numbers 
    with ``XOR``.

    .. table:: Suboctad numbers of some cocode elements
      :widths: 16 16 16 16 18 18

      =========== =========== =========== =========== =========== =========== 
      ``[b0,b1]`` ``[b0,b2]`` ``[b0,b3]`` ``[b0,b4]`` ``[b0,b5]`` ``[b0,b6]``
      ``s  = 1``  ``s  = 2``  ``s  = 4``  ``s  = 8``  ``s = 16``  ``s = 32``
      =========== =========== =========== =========== =========== =========== 

    E.g. ``[b0, b5, b6, b7]`` is equivalent to ``[b1, b2, b3, b4]`` 
    modulo the Golay code and has number ``s = 1 ^ 2 ^ 4 ^ 8 = 15``.

    """
    ploop = Octad(octad)
    gcode = ploop.value & 0xfff
    if isinstance(suboctad, str):
        suboctad_ = randint(0, 63)
    elif isinstance(suboctad, Integral):
        suboctad_ = suboctad & 0x3f
    elif isinstance(suboctad, GCode):
        value = mat24.ploop_cap(gcode, suboctad.value)
        suboctad_ = mat24.cocode_to_suboctad(value, gcode)
    else:
        value = Cocode(suboctad).cocode
        suboctad_ = mat24.cocode_to_suboctad(value, gcode)
    cocode = mat24.suboctad_to_cocode(suboctad_, gcode)
    if import_pending:
        complete_import()
    result = XLeech2(ploop, cocode)
    subtype = result.xsubtype
    assert subtype in [0x22, 0x42], (hex(subtype), hex(ploop), hex(cocode),
                                     hex(result.value))
    # complent a complement of an octad
    if subtype == 0x42:
        result.value ^= 0x800000
    return result
コード例 #6
0
ファイル: test_op_xy.py プロジェクト: Martin-Seysen/mmgroup
def as_suboctad(v1, d):
    c = m24.ploop_cap(v1, d)
    return m24.cocode_to_suboctad(c, d)