コード例 #1
0
    def __call__(self, im_gens, check=True):
        """
        Create a homomorphism.

        EXAMPLES::

            sage: R.<x,y> = PolynomialRing(QQ, 2)
            sage: S.<a,b> = R.quotient(x^2 + y^2)
            sage: H = S.Hom(R)
            sage: phi = H([b,a]); phi
            Ring morphism:
              From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
              To:   Multivariate Polynomial Ring in x, y over Rational Field
              Defn: a |--> b
                    b |--> a

        """
        if isinstance(im_gens, morphism.RingHomomorphism_from_quotient):
            return morphism.RingHomomorphism_from_quotient(
                self, im_gens._phi())
        try:
            pi = self.domain().cover()
            phi = pi.domain().hom(im_gens, check=check)
            return morphism.RingHomomorphism_from_quotient(self, phi)
        except (NotImplementedError, ValueError), err:
            try:
                return self._coerce_impl(im_gens)
            except TypeError:
                raise TypeError, "images do not define a valid homomorphism"
コード例 #2
0
ファイル: homset.py プロジェクト: thalespaiva/sagelib
 def __call__(self, im_gens, check=True):
     if isinstance(im_gens, morphism.RingHomomorphism_from_quotient):
         return morphism.RingHomomorphism_from_quotient(
             self, im_gens._phi())
     try:
         pi = self.domain().cover()
         phi = pi.domain().hom(im_gens, check=check)
         return morphism.RingHomomorphism_from_quotient(self, phi)
     except (NotImplementedError, ValueError), err:
         try:
             return self._coerce_impl(im_gens)
         except TypeError:
             raise TypeError, "images do not define a valid homomorphism"
コード例 #3
0
ファイル: homset.py プロジェクト: thalespaiva/sagelib
 def _coerce_impl(self, x):
     if not isinstance(x, morphism.RingHomomorphism_from_quotient):
         raise TypeError
     if x.parent() is self:
         return x
     if x.parent() == self:
         return morphism.RingHomomorphism_from_quotient(self, x._phi())
     raise TypeError
コード例 #4
0
    def _coerce_impl(self, x):
        """
        Check to see if we can coerce ``x`` into a homomorphism with the
        correct rings.

        EXAMPLES::

            sage: R.<x,y> = PolynomialRing(QQ, 2)
            sage: S.<a,b> = R.quotient(x^2 + y^2)
            sage: H = S.Hom(R)
            sage: phi = H([b,a])
            sage: R2.<x,y> = PolynomialRing(ZZ, 2)
            sage: H2 = Hom(R2, S)
            sage: H2(phi) # indirect doctest
            Composite map:
              From: Multivariate Polynomial Ring in x, y over Integer Ring
              To:   Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
              Defn:   Conversion map:
                      From: Multivariate Polynomial Ring in x, y over Integer Ring
                      To:   Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
                    then
                      Composite map:
                      From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
                      To:   Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
                      Defn:   Ring morphism:
                              From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
                              To:   Multivariate Polynomial Ring in x, y over Rational Field
                              Defn: a |--> b
                                    b |--> a
                            then
                              Conversion map:
                              From: Multivariate Polynomial Ring in x, y over Rational Field
                              To:   Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)

        """
        if not isinstance(x, morphism.RingHomomorphism_from_quotient):
            raise TypeError
        if x.parent() is self:
            return x
        if x.parent() == self:
            return morphism.RingHomomorphism_from_quotient(self, x._phi())
        raise TypeError