示例#1
0
文件: homset.py 项目: shalec/sage
    def create_key_and_extra_args(self, X, Y, category=None, base=ZZ,
                                  check=True, as_point_homset=False):
        """
        Create a key that uniquely determines the Hom-set.

        INPUT:

        - ``X`` -- a scheme. The domain of the morphisms.

        - ``Y`` -- a scheme. The codomain of the morphisms.

        - ``category`` -- a category for the Hom-sets (default: schemes over
          given base).

        - ``base`` -- a scheme or a ring. The base scheme of domain
          and codomain schemes. If a ring is specified, the spectrum
          of that ring will be used as base scheme.

        - ``check`` -- boolean (default: ``True``).

        EXAMPLES::

            sage: A2 = AffineSpace(QQ,2)
            sage: A3 = AffineSpace(QQ,3)
            sage: A3.Hom(A2)    # indirect doctest
            Set of morphisms
              From: Affine Space of dimension 3 over Rational Field
              To:   Affine Space of dimension 2 over Rational Field
            sage: from sage.schemes.generic.homset import SchemeHomsetFactory
            sage: SHOMfactory = SchemeHomsetFactory('test')
            sage: key, extra = SHOMfactory.create_key_and_extra_args(A3,A2,check=False)
            sage: key
            (..., ..., Category of schemes over Integer Ring, False)
            sage: extra
            {'X': Affine Space of dimension 3 over Rational Field,
             'Y': Affine Space of dimension 2 over Rational Field,
             'base_ring': Integer Ring,
             'check': False}
        """
        if isinstance(X, CommutativeRing):
            X = AffineScheme(X)
        if isinstance(Y, CommutativeRing):
            Y = AffineScheme(Y)
        if is_AffineScheme(base):
            base_spec = base
            base_ring = base.coordinate_ring()
        elif isinstance(base, CommutativeRing):
            base_spec = AffineScheme(base)
            base_ring = base
        else:
            raise ValueError('base must be a commutative ring or its spectrum')
        if not category:
            from sage.categories.schemes import Schemes
            category = Schemes(base_spec)
        key = tuple([id(X), id(Y), category, as_point_homset])
        extra = {'X':X, 'Y':Y, 'base_ring':base_ring, 'check':check}
        return key, extra
示例#2
0
    def __init__(self, n, R, names):
        """
        EXAMPLES::

            sage: AffineSpace(3, Zp(5), 'y')
            Affine Space of dimension 3 over 5-adic Ring with capped relative precision 20
        """
        AmbientSpace.__init__(self, n, R)
        self._assign_names(names)
        AffineScheme.__init__(self, self.coordinate_ring(), R)
示例#3
0
    def __init__(self, n, R, names):
        """
        EXAMPLES::

            sage: AffineSpace(3, Zp(5), 'y')
            Affine Space of dimension 3 over 5-adic Ring with capped relative precision 20
        """
        AmbientSpace.__init__(self, n, R)
        self._assign_names(names)
        AffineScheme.__init__(self, self.coordinate_ring(), R)
示例#4
0
    def __init__(self, base_ring=None):
        """
        EXAMPLES::

            sage: from sage.schemes.generic.spec import SpecFunctor
            sage: SpecFunctor()
            Spec functor from Category of commutative rings to Category of schemes
            sage: SpecFunctor(QQ)
            Spec functor from Category of commutative rings to
             Category of schemes over Rational Field
        """
        from sage.categories.all import CommutativeAlgebras, CommutativeRings, Schemes

        if base_ring is None:
            domain = CommutativeRings()
            codomain = Schemes()
        elif base_ring in CommutativeRings():
            # We would like to use CommutativeAlgebras(base_ring) as
            # the domain; we use CommutativeRings() instead because
            # currently many algebras are not yet considered to be in
            # CommutativeAlgebras(base_ring) by the category framework.
            domain = CommutativeRings()
            codomain = Schemes(AffineScheme(base_ring))
        else:
            raise TypeError('base (= {}) must be a commutative ring'.format(base_ring))
        self._base_ring = base_ring
        super(SpecFunctor, self).__init__(domain, codomain)
示例#5
0
    def __init__(self, n, R, names, ambient_projective_space, default_embedding_index):
        """
        EXAMPLES::

            sage: AffineSpace(3, Zp(5), 'y')
            Affine Space of dimension 3 over 5-adic Ring with capped relative precision 20
        """
        AmbientSpace.__init__(self, n, R)
        self._assign_names(names)
        AffineScheme.__init__(self, self.coordinate_ring(), R)

        index = default_embedding_index
        if index is not None:
            index = int(index)

        self._default_embedding_index = index
        self._ambient_projective_space = ambient_projective_space
示例#6
0
    def _apply_functor(self, A):
        """
        Apply the Spec functor to the commutative ring ``A``.

        EXAMPLES::

            sage: from sage.schemes.generic.spec import SpecFunctor
            sage: F = SpecFunctor()
            sage: F(RR) # indirect doctest
            Spectrum of Real Field with 53 bits of precision
        """
        # The second argument of AffineScheme defaults to None.
        # However, AffineScheme has unique representation, so there is
        # a difference between calling it with or without explicitly
        # giving this argument.
        if self._base_ring is None:
            return AffineScheme(A)
        return AffineScheme(A, self._base_ring)
示例#7
0
文件: spec.py 项目: Etn40ff/sage
    def _apply_functor(self, A):
        """
        Apply the Spec functor to the commutative ring ``A``.

        EXAMPLES::

            sage: from sage.schemes.generic.spec import SpecFunctor
            sage: F = SpecFunctor()
            sage: F(RR) # indirect doctest
            Spectrum of Real Field with 53 bits of precision
        """
        return AffineScheme(A, self._base_ring)
示例#8
0
文件: spec.py 项目: chos9/sage
    def __init__(self, R, S=None):
        """
        Construct the spectrum of the ring ``R``.

        See :class:`Spec` for details.

        EXAMPLES::

            sage: Spec(ZZ)
            Spectrum of Integer Ring
        """
        if not is_CommutativeRing(R):
            raise TypeError, "R (=%s) must be a commutative ring"%R
        self.__R = R
        if not S is None:
            if not is_CommutativeRing(S):
                raise TypeError, "S (=%s) must be a commutative ring"%S
            try:
                S.hom(R)
            except TypeError:
                raise ValueError, "There must be a natural map S --> R, but S = %s and R = %s"%(S,R)
        AffineScheme.__init__(self, S)
示例#9
0
    def __init__(self, R, S=None):
        """
        Construct the spectrum of the ring ``R``.

        See :class:`Spec` for details.

        EXAMPLES::

            sage: Spec(ZZ)
            Spectrum of Integer Ring
        """
        if not is_CommutativeRing(R):
            raise TypeError("R (=%s) must be a commutative ring"%R)
        self.__R = R
        if not S is None:
            if not is_CommutativeRing(S):
                raise TypeError("S (=%s) must be a commutative ring"%S)
            try:
                S.hom(R)
            except TypeError:
                raise ValueError("There must be a natural map S --> R, but S = %s and R = %s"%(S,R))
        AffineScheme.__init__(self, S)