Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Refactor conic curves
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Aug 22, 2022
1 parent dabe765 commit 3947c02
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
44 changes: 17 additions & 27 deletions src/sage/schemes/plane_conics/con_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
- Nick Alexander (2008-01-08)
"""
#*****************************************************************************
# Copyright (C) 2008 Nick Alexander <ncalexander@gmail.com>
# Copyright (C) 2009/2010 Marco Streng <marco.streng@gmail.com>
# *****************************************************************************
# Copyright (C) 2008 Nick Alexander <ncalexander@gmail.com>
# Copyright (C) 2009/2010 Marco Streng <marco.streng@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
# Distributed under the terms of the GNU General Public License (GPL)
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# The full text of the GPL is available at:
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
#*****************************************************************************
# http://www.gnu.org/licenses/
# *****************************************************************************

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

Expand All @@ -35,12 +35,12 @@
from sage.matrix.constructor import Matrix
from sage.structure.element import is_Matrix

from sage.schemes.curves.projective_curve import ProjectivePlaneCurve
from sage.schemes.curves.projective_curve import ProjectivePlaneCurve_field

from sage.categories.fields import Fields
_Fields = Fields()

class ProjectiveConic_field(ProjectivePlaneCurve):
class ProjectiveConic_field(ProjectivePlaneCurve_field):
r"""
Create a projective plane conic curve over a field.
See ``Conic`` for full documentation.
Expand Down Expand Up @@ -68,17 +68,14 @@ def __init__(self, A, f):
sage: c = Conic([1, 1, 1]); c
Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2
"""
ProjectivePlaneCurve.__init__(self, A, f)
super().__init__(A, f)
self._coefficients = [f[(2,0,0)], f[(1,1,0)], f[(1,0,1)],
f[(0,2,0)], f[(0,1,1)], f[(0,0,2)]]
self._parametrization = None
self._diagonal_matrix = None

self._rational_point = None




def _repr_type(self):
r"""
Returns ``'Projective Conic'``, which is the first part of the
Expand Down Expand Up @@ -128,7 +125,7 @@ def base_extend(self, S):
# if (and only if) there is no point in the cache.
pt = con.point(pt)
return con
return ProjectivePlaneCurve.base_extend(self, S)
return super().base_extend(S)

def cache_point(self, p):
r"""
Expand Down Expand Up @@ -168,7 +165,6 @@ def coefficients(self):
"""
return self._coefficients


def derivative_matrix(self):
r"""
Gives the derivative of the defining polynomial of
Expand Down Expand Up @@ -702,7 +698,7 @@ def hom(self, x, Y=None):
(x, self, Y))
x = Sequence(x*vector(self.ambient_space().gens()))
return self.Hom(Y)(x, check = False)
return ProjectivePlaneCurve.hom(self, x, Y)
return super().hom(x, Y)

def is_diagonal(self):
r"""
Expand Down Expand Up @@ -743,7 +739,6 @@ def is_smooth(self):
return self.defining_polynomial()([e, c, b]) != 0
return self.determinant() != 0


def _magma_init_(self, magma):
"""
Internal function. Returns a string to initialize this
Expand Down Expand Up @@ -782,7 +777,6 @@ def _magma_init_(self, magma):
magma_coeffs = [coeffs[i]._magma_init_(magma) for i in [0, 3, 5, 1, 4, 2]]
return 'Conic([%s|%s])' % (kmn,','.join(magma_coeffs))


def matrix(self):
r"""
Returns a matrix `M` such that `(x, y, z) M (x, y, z)^t`
Expand Down Expand Up @@ -959,12 +953,11 @@ def point(self, v, check=True):
"""
if is_Vector(v):
v = Sequence(v)
p = ProjectivePlaneCurve.point(self, v, check=check)
p = super().point(v, check=check)
if self._rational_point is None:
self._rational_point = p
return p


def random_rational_point(self, *args1, **args2):
r"""
Return a random rational point of the conic ``self``.
Expand Down Expand Up @@ -1013,7 +1006,6 @@ def random_rational_point(self, *args1, **args2):
y = B.random_element(*args1, **args2)
return par[0]([x,y])


def rational_point(self, algorithm = 'default', read_cache = True):
r"""
Return a point on ``self`` defined over the base field.
Expand Down Expand Up @@ -1135,7 +1127,6 @@ def rational_point(self, algorithm = 'default', read_cache = True):
raise ValueError("Conic %s has no rational points over %s!" % \
(self, self.ambient_space().base_ring()))


def singular_point(self):
r"""
Returns a singular rational point of ``self``
Expand Down Expand Up @@ -1192,7 +1183,6 @@ def symmetric_matrix(self):
[ b/2, d , e/2 ],
[ c/2, e/2, f ]])


def upper_triangular_matrix(self):
r"""
The upper-triangular matrix `M` such that `(x y z) M (x y z)^t`
Expand Down
9 changes: 7 additions & 2 deletions src/sage/schemes/projective/projective_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ def __call__(self, x):
- ``x`` -- a point in the domain of definition
OUTPUT: a point in the codomain
OUTPUT: the image of the point ``x`` under the morphism
TESTS::
Expand All @@ -2266,7 +2266,12 @@ def __call__(self, x):
sage: _ == C([0, -1, 2])
True
"""
for m in self.representatives():
try:
reprs = self.representatives()
except NotImplementedError:
reprs = [self.defining_polynomials()]

for m in reprs:
try:
return super(SchemeMorphism_polynomial_projective_subscheme_field, m).__call__(x)
except ValueError:
Expand Down

0 comments on commit 3947c02

Please sign in to comment.