Module garoupa.algebra.cyclic.z

Classes

class Z (n, seed=None)
Expand source code
class Z(Group):
    def __init__(self, n, seed=None):
        """
        Usage:

        >>> G = Z(1414343245, seed=0)
        >>> G.comm_degree
        1
        >>> G, ~G
        (Z1414343245, 906691059)
        """
        sorted = lambda: (Nat(i, n) for i in range(n))
        super().__init__(Nat(0, n), sorted, seed)
        self.n = n

    @property
    def comm_degree(self):
        """Exact commutativity degree"""
        return 1

    def __iter__(self):
        while True:
            yield Nat(self.samplei(), self.n)

    def __repr__(self):
        return f"Z{self.n}"

    def replace(self, *args, **kwargs):
        """
        Usage:

        >>> G = Z(1414343245, seed=0)
        >>> ~G.replace(seed=1)
        144272509
        """
        dic = {"n": self.n, "seed": self.seed}
        dic.update(kwargs)
        return self.__class__(**dic)

Usage:

>>> G = Z(1414343245, seed=0)
>>> G.comm_degree
1
>>> G, ~G
(Z1414343245, 906691059)

Ancestors

Instance variables

prop comm_degree
Expand source code
@property
def comm_degree(self):
    """Exact commutativity degree"""
    return 1

Exact commutativity degree

Methods

def replace(self, *args, **kwargs)
Expand source code
def replace(self, *args, **kwargs):
    """
    Usage:

    >>> G = Z(1414343245, seed=0)
    >>> ~G.replace(seed=1)
    144272509
    """
    dic = {"n": self.n, "seed": self.seed}
    dic.update(kwargs)
    return self.__class__(**dic)

Usage:

>>> G = Z(1414343245, seed=0)
>>> ~G.replace(seed=1)
144272509

Inherited members