Beispiel #1
0
    def __init__(self, R, I, names, category=None):
        """
        Create the quotient ring of `R` by the twosided ideal `I`.

        INPUT:

        -  ``R`` -- a ring.

        -  ``I`` -- a twosided ideal of `R`.

        - ``names`` -- a list of generator names.

        EXAMPLES::

            sage: F.<x,y,z> = FreeAlgebra(QQ, implementation='letterplace')
            sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F
            sage: Q.<a,b,c> = F.quo(I); Q
            Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x*y + y*z, x*x + x*y - y*x - y*y)
            sage: a*b
            -b*c
            sage: a^3
            -b*c*a - b*c*b - b*c*c

        """
        if R not in _Rings:
            raise TypeError(
                "The first argument must be a ring, but %s is not" % R)
        if I not in R.ideal_monoid():
            raise TypeError(
                "The second argument must be an ideal of the given ring, but %s is not"
                % I)
        self.__R = R
        self.__I = I
        #sage.structure.parent_gens.ParentWithGens.__init__(self, R.base_ring(), names)
        ##
        # Unfortunately, computing the join of categories, which is done in
        # check_default_category, is very expensive.
        # However, we don't just want to use the given category without mixing in
        # some quotient stuff - unless Parent.__init__ was called
        # previously, in which case the quotient ring stuff is just
        # a vaste of time. This is the case for FiniteField_prime_modn.
        if not self._is_category_initialized():
            if category is None:
                try:
                    commutative = R.is_commutative()
                except (AttributeError, NotImplementedError):
                    commutative = False
                if commutative:
                    category = check_default_category(
                        _CommutativeRingsQuotients, category)
                else:
                    category = check_default_category(_RingsQuotients,
                                                      category)
            ring.Ring.__init__(self,
                               R.base_ring(),
                               names=names,
                               category=category)
Beispiel #2
0
    def __init__(self, R, I, names, category=None):
        """
        Create the quotient ring of `R` by the twosided ideal `I`.

        INPUT:

        -  ``R`` -- a ring.

        -  ``I`` -- a twosided ideal of `R`.

        - ``names`` -- a list of generator names.

        EXAMPLES::

            sage: F.<x,y,z> = FreeAlgebra(QQ, implementation='letterplace')
            sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F
            sage: Q.<a,b,c> = F.quo(I); Q
            Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x*y + y*z, x*x + x*y - y*x - y*y)
            sage: a*b
            -b*c
            sage: a^3
            -b*c*a - b*c*b - b*c*c

        """
        if R not in _Rings:
            raise TypeError("The first argument must be a ring, but %s is not"%R)
        if I not in R.ideal_monoid():
            raise TypeError("The second argument must be an ideal of the given ring, but %s is not"%I)
        self.__R = R
        self.__I = I
        #sage.structure.parent_gens.ParentWithGens.__init__(self, R.base_ring(), names)
        ##
        # Unfortunately, computing the join of categories, which is done in
        # check_default_category, is very expensive.
        # However, we don't just want to use the given category without mixing in
        # some quotient stuff - unless Parent.__init__ was called
        # previously, in which case the quotient ring stuff is just
        # a vaste of time. This is the case for FiniteField_prime_modn.
        if not self._is_category_initialized():
            if category is None:
                try:
                    commutative = R.is_commutative()
                except (AttributeError, NotImplementedError):
                    commutative = False
                if commutative:
                    category = check_default_category(_CommutativeRingsQuotients,category)
                else:
                    category = check_default_category(_RingsQuotients,category)
            ring.Ring.__init__(self, R.base_ring(), names=names, category=category)
Beispiel #3
0
    def __init__(self, R, I, names, category=None):
        """
        Initialize ``self``.

        INPUT:

        -  ``R`` -- a ring that is a :class:`~sage.rings.ring.CommutativeRing`.

        -  ``I`` -- an ideal of `R`.

        - ``names`` -- a list of generator names.

        TESTS::

            sage: isinstance(ZZ.quo(2), sage.rings.ring.CommutativeRing)  # indirect doctest
            True
        """
        if not isinstance(R, ring.CommutativeRing):
            raise TypeError(
                "This class is for quotients of commutative rings only.\n    For non-commutative rings, use <sage.rings.quotient_ring.QuotientRing_nc>"
            )
        if not self._is_category_initialized():
            category = check_default_category(_CommutativeRingsQuotients,
                                              category)
        QuotientRing_nc.__init__(self, R, I, names, category=category)
Beispiel #4
0
    def __init__(self, base, prec, names, element_class, category=None):
        """
        Initializes self.

        EXAMPLES::

            sage: R = Zp(5) #indirect doctest
            sage: R.precision_cap()
            20

        In :trac:`14084`, the category framework has been implemented for p-adic rings::

            sage: TestSuite(R).run()
            sage: K = Qp(7)
            sage: TestSuite(K).run()

        TESTS::

            sage: R = Zp(5, 5, 'fixed-mod')
            sage: R._repr_option('element_is_atomic')
            False
        """
        self._prec = prec
        self.Element = element_class
        default_category = getattr(self, '_default_category', None)
        if self.is_field():
            category = CompleteDiscreteValuationFields()
        else:
            category = CompleteDiscreteValuationRings()
        if default_category is not None:
            category = check_default_category(default_category, category)
        Parent.__init__(self, base, names=(names,), normalize=False, category=category, element_constructor=element_class)
Beispiel #5
0
    def __init__(self, base, prec, names, element_class, category=None):
        """
        Initializes self.

        EXAMPLES::

            sage: R = Zp(5) #indirect doctest
            sage: R.precision_cap()
            20

        In :trac:`14084`, the category framework has been implemented for p-adic rings::

            sage: TestSuite(R).run()
            sage: K = Qp(7)
            sage: TestSuite(K).run()

        TESTS::

            sage: R = Zp(5, 5, 'fixed-mod')
            sage: R._repr_option('element_is_atomic')
            False
        """
        self._prec = prec
        self.Element = element_class
        default_category = getattr(self, '_default_category', None)
        if self.is_field():
            category = CompleteDiscreteValuationFields()
        else:
            category = CompleteDiscreteValuationRings()
        if default_category is not None:
            category = check_default_category(default_category, category)
        Parent.__init__(self, base, names=(names,), normalize=False, category=category, element_constructor=element_class)
Beispiel #6
0
 def __init__(self, R, I, names, category=None):
     """
     Create the quotient ring of `R` by the twosided ideal `I`.
     
     INPUT:
     
     -  ``R`` - a ring.
     -  ``I`` - a twosided ideal of `R`.
     - ``names`` - a list of generator names.
     
     """
     if R not in _Rings:
         raise TypeError, "The first argument must be a ring, but %s is not" % R
     if I not in R.ideal_monoid():
         raise TypeError, "The second argument must be an ideal of the given ring, but %s is not" % I
     self.__R = R
     self.__I = I
     #sage.structure.parent_gens.ParentWithGens.__init__(self, R.base_ring(), names)
     ##
     # Unfortunately, computing the join of categories, which is done in
     # check_default_category, is very expensive.
     # However, we don't just want to use the given category without mixing in
     # some quotient stuff - unless Parent.__init__ was called
     # previously, in which case the quotient ring stuff is just
     # a vaste of time. This is the case for FiniteField_prime_modn.
     if not self._is_category_initialized():
         if category is None:
             try:
                 commutative = R.is_commutative()
             except (AttributeError, NotImplementedError):
                 commutative = False
             if commutative:
                 category = check_default_category(
                     _CommutativeRingsQuotients, category)
             else:
                 category = check_default_category(_RingsQuotients,
                                                   category)
         ring.Ring.__init__(self,
                            R.base_ring(),
                            names=names,
                            category=category)
Beispiel #7
0
 def __init__(self, R, I, names, category=None):
     """
     Create the quotient ring of `R` by the twosided ideal `I`.
     
     INPUT:
     
     -  ``R`` - a ring.
     -  ``I`` - a twosided ideal of `R`.
     - ``names`` - a list of generator names.
     
     """
     if R not in _Rings:
         raise TypeError, "The first argument must be a ring, but %s is not"%R
     if I not in R.ideal_monoid():
         raise TypeError, "The second argument must be an ideal of the given ring, but %s is not"%I
     self.__R = R
     self.__I = I
     #sage.structure.parent_gens.ParentWithGens.__init__(self, R.base_ring(), names)
     ##
     # Unfortunately, computing the join of categories, which is done in
     # check_default_category, is very expensive.
     # However, we don't just want to use the given category without mixing in
     # some quotient stuff - unless Parent.__init__ was called
     # previously, in which case the quotient ring stuff is just
     # a vaste of time. This is the case for FiniteField_prime_modn.
     if not self._is_category_initialized():
         if category is None:
             try:
                 commutative = R.is_commutative()
             except (AttributeError, NotImplementedError):
                 commutative = False
             if commutative:
                 category = check_default_category(_CommutativeRingsQuotients,category)
             else:
                 category = check_default_category(_RingsQuotients,category)
         ring.Ring.__init__(self, R.base_ring(), names=names, category=category)
Beispiel #8
0
    def __init__(self, R, I, names, category=None):
        """
        INPUT:
        
        -  ``R`` - a ring that is of type <sage.rings.ring.CommutativeRing>.
        -  ``I`` - an ideal of `R`.
        - ``names`` - a list of generator names.

        TEST::

            sage: isinstance(ZZ.quo(2), sage.rings.ring.CommutativeRing)  # indirect doctest
            True

        """
        if not isinstance(R, sage.rings.commutative_ring.CommutativeRing):
            raise TypeError, "This class is for quotients of commutative rings only.\n    For non-commutative rings, use <sage.rings.quotient_ring.QuotientRing_nc>"
        if not self._is_category_initialized():
            category = check_default_category(_CommutativeRingsQuotients,category)
        QuotientRing_nc.__init__(self, R, I, names, category=category)