예제 #1
0
파일: glue.py 프로젝트: sageb0t/testsage
 def __init__(self, f, g, check=True):
     if check:
         if not morphism.is_SchemeMorphism(f):
             raise TypeError, "f (=%s) must be a scheme morphism"%f
         if not morphism.is_SchemeMorphism(g):
             raise TypeError, "g (=%s) must be a scheme morphism"%g
         if f.domain() != g.domain():
             raise ValueError, "f (=%s) and g (=%s) must have the same domain"%(f,g)
     self.__f = f
     self.__g = g
예제 #2
0
파일: glue.py 프로젝트: sajedel/testsage
 def __init__(self, f, g, check=True):
     if check:
         if not morphism.is_SchemeMorphism(f):
             raise TypeError, "f (=%s) must be a scheme morphism" % f
         if not morphism.is_SchemeMorphism(g):
             raise TypeError, "g (=%s) must be a scheme morphism" % g
         if f.domain() != g.domain():
             raise ValueError, "f (=%s) and g (=%s) must have the same domain" % (
                 f, g)
     self.__f = f
     self.__g = g
예제 #3
0
파일: divisor.py 프로젝트: chos9/sage
    def __init__(self, v, parent=None, check=True, reduce=True):
        """
        Construct a divisor on a curve.

        INPUT:

        - ``v`` -- a list of pairs ``(c, P)``, where ``c`` is an
           integer and ``P`` is a point on a curve. The P's must all
           lie on the same curve.


        - To create the divisor 0 use ``[(0, P)]``, so as to give the curve.

        EXAMPLES::

            sage: E = EllipticCurve([0, 0, 1, -1, 0])
            sage: P = E(0,0)
            sage: from sage.schemes.generic.divisor import Divisor_curve
            sage: from sage.schemes.generic.divisor_group import DivisorGroup
            sage: Divisor_curve([(1,P)], parent=DivisorGroup(E))
            (x, y)
        """
        from sage.schemes.generic.divisor_group import DivisorGroup_generic, DivisorGroup_curve
        if not isinstance(v, (list, tuple)):
            v = [(1,v)]

        if parent is None:
            if len(v) > 0:
                t = v[0]
                if isinstance(t, tuple) and len(t) == 2:
                    try:
                        C = t[1].scheme()
                    except (TypeError, AttributeError):
                        raise TypeError, \
                              "Argument v (= %s) must consist of multiplicities and points on a scheme."
                else:
                    try:
                        C = t.scheme()
                    except TypeError:
                        raise TypeError, \
                              "Argument v (= %s) must consist of multiplicities and points on a scheme."
                parent = DivisorGroup(C)
            else:
                raise TypeError, \
                      "Argument v (= %s) must consist of multiplicities and points on a scheme."
        else:
            if not isinstance(parent, DivisorGroup_curve):
                raise TypeError, "parent (of type %s) must be a DivisorGroup_curve"%type(parent)
            C = parent.scheme()

        if len(v) < 1:
            check = False
        know_points = False
        if check:
            w = []
            points = []
            know_points = True
            for t in v:
                if isinstance(t, tuple) and len(t) == 2:
                    n = ZZ(t[0])
                    I = t[1]
                    points.append((n,I))
                else:
                    n = ZZ(1)
                    I = t
                if is_SchemeMorphism(I):
                    I = CurvePointToIdeal(C,I)
                else:
                    know_points = False
                w.append((n,I))
            v = w
        Divisor_generic.__init__(
            self, v, check=False, reduce=True, parent=parent)

        if know_points:
            self._points = points
예제 #4
0
    def __init__(self, v, parent=None, check=True, reduce=True):
        """
        Construct a divisor on a curve.

        INPUT:

        - ``v`` -- a list of pairs ``(c, P)``, where ``c`` is an
           integer and ``P`` is a point on a curve. The P's must all
           lie on the same curve.


        - To create the divisor 0 use ``[(0, P)]``, so as to give the curve.

        EXAMPLES::

            sage: E = EllipticCurve([0, 0, 1, -1, 0])
            sage: P = E(0,0)
            sage: from sage.schemes.generic.divisor import Divisor_curve
            sage: from sage.schemes.generic.divisor_group import DivisorGroup
            sage: Divisor_curve([(1,P)], parent=DivisorGroup(E))
            (x, y)
        """
        from sage.schemes.generic.divisor_group import DivisorGroup_generic, DivisorGroup_curve
        if not isinstance(v, (list, tuple)):
            v = [(1, v)]

        if parent is None:
            if len(v) > 0:
                t = v[0]
                if isinstance(t, tuple) and len(t) == 2:
                    try:
                        C = t[1].scheme()
                    except (TypeError, AttributeError):
                        raise TypeError(
                            "Argument v (= %s) must consist of multiplicities and points on a scheme."
                        )
                else:
                    try:
                        C = t.scheme()
                    except TypeError:
                        raise TypeError(
                            "Argument v (= %s) must consist of multiplicities and points on a scheme."
                        )
                parent = DivisorGroup(C)
            else:
                raise TypeError(
                    "Argument v (= %s) must consist of multiplicities and points on a scheme."
                )
        else:
            if not isinstance(parent, DivisorGroup_curve):
                raise TypeError(
                    "parent (of type %s) must be a DivisorGroup_curve" %
                    type(parent))
            C = parent.scheme()

        if len(v) < 1:
            check = False
        know_points = False
        if check:
            w = []
            points = []
            know_points = True
            for t in v:
                if isinstance(t, tuple) and len(t) == 2:
                    n = ZZ(t[0])
                    I = t[1]
                    points.append((n, I))
                else:
                    n = ZZ(1)
                    I = t
                if is_SchemeMorphism(I):
                    I = CurvePointToIdeal(C, I)
                else:
                    know_points = False
                w.append((n, I))
            v = w
        Divisor_generic.__init__(self,
                                 v,
                                 check=False,
                                 reduce=True,
                                 parent=parent)

        if know_points:
            self._points = points