def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose()*self.matrix()*y im = Conic(A) if Y == None: Y = im else: q = Y.defining_polynomial()/im.defining_polynomial() if not (q.numerator().is_constant() and q.denominator().is_constant()): raise ValueError, "The matrix x (= %s) does not define a " \ "map from self (= %s) to Y (= %s)" % \ (x, self, Y) x = Sequence(x*vector(self.ambient_space().gens())) return self.Hom(Y)(x, check = False) return ProjectiveCurve_generic.hom(self, x, Y)
def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) The identity map between two representations of the same conic: :: sage: C = Conic([1,2,3,4,5,6]) sage: D = Conic([2,4,6,8,10,12]) sage: C.hom(identity_matrix(3), D) Scheme morphism: From: Projective Conic Curve over Rational Field defined by x^2 + 2*x*y + 4*y^2 + 3*x*z + 5*y*z + 6*z^2 To: Projective Conic Curve over Rational Field defined by 2*x^2 + 4*x*y + 8*y^2 + 6*x*z + 10*y*z + 12*z^2 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) An example not over the rational numbers: :: sage: P.<t> = QQ[] sage: C = Conic([1,0,0,t,0,1/t]) sage: D = Conic([1/t^2, 0, -2/t^2, t, 0, (t + 1)/t^2]) sage: T = Matrix([[t,0,1],[0,1,0],[0,0,1]]) sage: C.hom(T, D) Scheme morphism: From: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by x^2 + t*y^2 + 1/t*z^2 To: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by 1/t^2*x^2 + t*y^2 + (-2/t^2)*x*z + ((t + 1)/t^2)*z^2 Defn: Defined on coordinates by sending (x : y : z) to (t*x + z : y : z) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose() * self.matrix() * y im = Conic(A) if Y is None: Y = im elif not Y == im: raise ValueError("The matrix x (= %s) does not define a " \ "map from self (= %s) to Y (= %s)" % \ (x, self, Y)) x = Sequence(x * vector(self.ambient_space().gens())) return self.Hom(Y)(x, check=False) return ProjectiveCurve_generic.hom(self, x, Y)
def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose()*self.matrix()*y im = Conic(A) if Y is None: Y = im else: q = Y.defining_polynomial()/im.defining_polynomial() if not (q.numerator().is_constant() and q.denominator().is_constant()): raise ValueError("The matrix x (= %s) does not define a " \ "map from self (= %s) to Y (= %s)" % \ (x, self, Y)) x = Sequence(x*vector(self.ambient_space().gens())) return self.Hom(Y)(x, check = False) return ProjectiveCurve_generic.hom(self, x, Y)
def hom(self, x, Y=None): r""" Return the scheme morphism from ``self`` to ``Y`` defined by ``x``. Here ``x`` can be a matrix or a sequence of polynomials. If ``Y`` is omitted, then a natural image is found if possible. EXAMPLES: Here are a few Morphisms given by matrices. In the first example, ``Y`` is omitted, in the second example, ``Y`` is specified. :: sage: c = Conic([-1, 1, 1]) sage: h = c.hom(Matrix([[1,1,0],[0,1,0],[0,0,1]])); h Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by -x^2 + 2*x*y + z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + y : y : z) sage: h([-1, 1, 0]) (0 : 1 : 0) sage: c = Conic([-1, 1, 1]) sage: d = Conic([4, 1, -1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), d) Scheme morphism: From: Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2 To: Projective Conic Curve over Rational Field defined by 4*x^2 + y^2 - z^2 Defn: Defined on coordinates by sending (x : y : z) to (1/2*z : y : x) ``ValueError`` is raised if the wrong codomain ``Y`` is specified: :: sage: c = Conic([-1, 1, 1]) sage: c.hom(Matrix([[0, 0, 1/2], [0, 1, 0], [1, 0, 0]]), c) Traceback (most recent call last): ... ValueError: The matrix x (= [ 0 0 1/2] [ 0 1 0] [ 1 0 0]) does not define a map from self (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) to Y (= Projective Conic Curve over Rational Field defined by -x^2 + y^2 + z^2) The identity map between two representations of the same conic: :: sage: C = Conic([1,2,3,4,5,6]) sage: D = Conic([2,4,6,8,10,12]) sage: C.hom(identity_matrix(3), D) Scheme morphism: From: Projective Conic Curve over Rational Field defined by x^2 + 2*x*y + 4*y^2 + 3*x*z + 5*y*z + 6*z^2 To: Projective Conic Curve over Rational Field defined by 2*x^2 + 4*x*y + 8*y^2 + 6*x*z + 10*y*z + 12*z^2 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) An example not over the rational numbers: :: sage: P.<t> = QQ[] sage: C = Conic([1,0,0,t,0,1/t]) sage: D = Conic([1/t^2, 0, -2/t^2, t, 0, (t + 1)/t^2]) sage: T = Matrix([[t,0,1],[0,1,0],[0,0,1]]) sage: C.hom(T, D) Scheme morphism: From: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by x^2 + t*y^2 + 1/t*z^2 To: Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by 1/t^2*x^2 + t*y^2 + (-2/t^2)*x*z + ((t + 1)/t^2)*z^2 Defn: Defined on coordinates by sending (x : y : z) to (t*x + z : y : z) """ if is_Matrix(x): from constructor import Conic y = x.inverse() A = y.transpose() * self.matrix() * y im = Conic(A) if Y is None: Y = im elif not Y == im: raise ValueError( "The matrix x (= %s) does not define a " "map from self (= %s) to Y (= %s)" % (x, self, Y) ) x = Sequence(x * vector(self.ambient_space().gens())) return self.Hom(Y)(x, check=False) return ProjectiveCurve_generic.hom(self, x, Y)