Example #1
0
    def list_of_elements_of_multiplicative_group(self):
        """
        Return a list of all invertible elements, as python ints.

        EXAMPLES::

            sage: R = Zmod(12)
            sage: L = R.list_of_elements_of_multiplicative_group(); L
            [1, 5, 7, 11]
            sage: type(L[0])
            <... 'int'>
            sage: Zmod(1).list_of_elements_of_multiplicative_group()
            [0]
        """
        import sage.rings.fast_arith as a
        if self.__order <= 46340:  # todo: don't hard code
            gcd = a.arith_int().gcd_int
        elif self.__order <= 2147483647:  # todo: don't hard code
            gcd = a.arith_llong().gcd_longlong
        else:
            raise NotImplementedError(
                "list_of_elements_of_multiplicative_group() is not implemented for large moduli"
            )
        N = self.__order
        # Don't use N.coprime_integers() here because we want Python ints
        return [i for i in range(N) if gcd(i, N) == 1]
Example #2
0
 def list_of_elements_of_multiplicative_group(self):
     import sage.rings.fast_arith as a
     if self.__order <= 46340:   # todo: don't hard code
         gcd = a.arith_int().gcd_int
     elif self.__order <= 2147483647:   # todo: don't hard code
         gcd = a.arith_llong().gcd_longlong
     else:
         raise MemoryError, "creating the list would exhaust memory."
     N = self.__order
     H = [i for i in range(N) if gcd(i, N) == 1]
     return H
Example #3
0
 def list_of_elements_of_multiplicative_group(self):
     import sage.rings.fast_arith as a
     if self.__order <= 46340:  # todo: don't hard code
         gcd = a.arith_int().gcd_int
     elif self.__order <= 2147483647:  # todo: don't hard code
         gcd = a.arith_llong().gcd_longlong
     else:
         raise MemoryError, "creating the list would exhaust memory."
     N = self.__order
     H = [i for i in range(N) if gcd(i, N) == 1]
     return H
Example #4
0
    def list_of_elements_of_multiplicative_group(self):
        """
        Return a list of all invertible elements, as python ints.

        EXAMPLES::

            sage: R = Zmod(12)
            sage: L = R.list_of_elements_of_multiplicative_group(); L
            [1, 5, 7, 11]
            sage: type(L[0])
            <... 'int'>
        """
        import sage.rings.fast_arith as a
        if self.__order <= 46340:   # todo: don't hard code
            gcd = a.arith_int().gcd_int
        elif self.__order <= 2147483647:   # todo: don't hard code
            gcd = a.arith_llong().gcd_longlong
        else:
            raise MemoryError("creating the list would exhaust memory")
        N = self.__order
        return [i for i in range(N) if gcd(i, N) == 1]
Example #5
0
    def list_of_elements_of_multiplicative_group(self):
        """
        Returns a list of all invertible elements, as python ints.

        EXAMPLES::

            sage: R = Zmod(12)
            sage: L = R.list_of_elements_of_multiplicative_group(); L
            [1, 5, 7, 11]
            sage: type(L[0])
            <type 'int'>
        """
        import sage.rings.fast_arith as a
        if self.__order <= 46340:   # todo: don't hard code
            gcd = a.arith_int().gcd_int
        elif self.__order <= 2147483647:   # todo: don't hard code
            gcd = a.arith_llong().gcd_longlong
        else:
            raise MemoryError, "creating the list would exhaust memory."
        N = self.__order
        H = [i for i in range(N) if gcd(i, N) == 1]
        return H