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

Commit

Permalink
20697: Added documentation and made curve string labels match class n…
Browse files Browse the repository at this point in the history
…ames.
  • Loading branch information
Grayson Jorgenson committed Jun 1, 2016
1 parent 3b5fdf8 commit 8541591
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/sage/schemes/affine/affine_space.py
Expand Up @@ -946,9 +946,9 @@ def curve(self,F):
sage: A.<x,y,z> = AffineSpace(QQ, 3)
sage: A.curve([y - x^4, z - y^5])
Affine Space Curve over Rational Field defined by -x^4 + y, -y^5 + z
Affine Curve over Rational Field defined by -x^4 + y, -y^5 + z
"""
from sage.schemes.plane_curves.constructor import Curve
from sage.schemes.curves.constructor import Curve
return Curve(F, self)

class AffineSpace_finite_field(AffineSpace_field):
Expand Down
78 changes: 73 additions & 5 deletions src/sage/schemes/curves/affine_curve.py
@@ -1,5 +1,19 @@
"""
Affine plane curves over a general ring
Affine curves over fields.
EXAMPLES:
We can construct curves in either an affine plane::
sage: A.<x,y> = AffineSpace(QQ, 2)
sage: C = Curve([y - x^2], A); C
Affine Plane Curve over Rational Field defined by -x^2 + y
or in higher dimensional affine space::
sage: A.<x,y,z,w> = AffineSpace(QQ, 4)
sage: C = Curve([y - x^2, z - w^3, w - y^4], A); C
Affine Curve over Rational Field defined by -x^2 + y, -w^3 + z, -y^4 + w
AUTHORS:
Expand Down Expand Up @@ -36,9 +50,37 @@

class AffineCurve(Curve_generic, AlgebraicScheme_subscheme_affine):
def _repr_type(self):
return "Affine Space"
r"""
Return a string representation of the type of this curve.
EXAMPLES::
sage: A.<x,y,z,w> = AffineSpace(QQ, 4)
sage: C = Curve([x - y, z - w, w - x], A)
sage: C._repr_type()
'Affine'
"""
return "Affine"

def __init__(self, A, X):
r"""
Initialization function.
EXAMPLES::
sage: R.<v> = QQ[]
sage: K.<u> = NumberField(v^2 + 3)
sage: A.<x,y,z> = AffineSpace(K, 3)
sage: C = Curve([z - u*x^2, y^2], A); C
Affine Curve over Number Field in u with defining polynomial v^2 + 3
defined by (-u)*x^2 + z, y^2
::
sage: A.<x,y,z> = AffineSpace(GF(7), 3)
sage: C = Curve([x^2 - z, z - 8*x], A); C
Affine Curve over Finite Field of size 7 defined by x^2 - z, -x + z
"""
if not is_AffineSpace(A):
raise TypeError("A (=%s) must be an affine space"%A)
Curve_generic.__init__(self, A, X)
Expand All @@ -48,12 +90,38 @@ def __init__(self, A, X):

class AffinePlaneCurve(AffineCurve):
def __init__(self, A, f):
r"""
Initialization function.
EXAMPLES::
sage: A.<x,y> = AffineSpace(QQ, 2)
sage: C = Curve([x^3 - y^2], A); C
Affine Plane Curve over Rational Field defined by x^3 - y^2
::
sage: A.<x,y> = AffineSpace(CC, 2)
sage: C = Curve([y^2 + x^2], A); C
Affine Plane Curve over Complex Field with 53 bits of precision defined
by x^2 + y^2
"""
if not (is_AffineSpace(A) and A.dimension != 2):
raise TypeError("Argument A (= %s) must be an affine plane."%A)
Curve_generic.__init__(self, A, [f])

def _repr_type(self):
return "Affine"
r"""
Return a string representation of the type of this curve.
EXAMPLES::
sage: A.<x,y> = AffineSpace(QQ, 2)
sage: C = Curve([y - 7/2*x^5 + x - 3], A)
sage: C._repr_type()
'Affine Plane'
"""
return "Affine Plane"

def divisor_of_function(self, r):
"""
Expand Down Expand Up @@ -239,7 +307,7 @@ def rational_points(self, algorithm="enum"):
sage: A.<x,y> = AffineSpace(2,GF(9,'a'))
sage: C = Curve(x^2 + y^2 - 1)
sage: C
Affine Curve over Finite Field in a of size 3^2 defined by x^2 + y^2 - 1
Affine Plane Curve over Finite Field in a of size 3^2 defined by x^2 + y^2 - 1
sage: C.rational_points()
[(0, 1), (0, 2), (1, 0), (2, 0), (a + 1, a + 1), (a + 1, 2*a + 2), (2*a + 2, a + 1), (2*a + 2, 2*a + 2)]
"""
Expand Down Expand Up @@ -346,7 +414,7 @@ def rational_points(self, algorithm="enum"):
sage: x, y = (GF(5)['x,y']).gens()
sage: f = y^2 - x^9 - x
sage: C = Curve(f); C
Affine Curve over Finite Field of size 5 defined by -x^9 + y^2 - x
Affine Plane Curve over Finite Field of size 5 defined by -x^9 + y^2 - x
sage: C.rational_points(algorithm='bn')
[(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)]
sage: C = Curve(x - y + 1)
Expand Down
32 changes: 16 additions & 16 deletions src/sage/schemes/curves/constructor.py
@@ -1,5 +1,5 @@
"""
Plane curve constructors
General curve constructors.
AUTHORS:
Expand Down Expand Up @@ -78,7 +78,7 @@ def Curve(F, A=None):
sage: x,y,z = QQ['x,y,z'].gens()
sage: C = Curve(x^3 + y^3 + z^3); C
Projective Curve over Rational Field defined by x^3 + y^3 + z^3
Projective Plane Curve over Rational Field defined by x^3 + y^3 + z^3
sage: C.genus()
1
Expand All @@ -88,20 +88,20 @@ def Curve(F, A=None):
sage: x,y = GF(7)['x,y'].gens()
sage: C = Curve(y^2 + x^3 + x^10); C
Affine Curve over Finite Field of size 7 defined by x^10 + x^3 + y^2
Affine Plane Curve over Finite Field of size 7 defined by x^10 + x^3 + y^2
sage: C.genus()
0
sage: x, y = QQ['x,y'].gens()
sage: Curve(x^3 + y^3 + 1)
Affine Curve over Rational Field defined by x^3 + y^3 + 1
Affine Plane Curve over Rational Field defined by x^3 + y^3 + 1
EXAMPLE: A projective space curve
::
sage: x,y,z,w = QQ['x,y,z,w'].gens()
sage: C = Curve([x^3 + y^3 - z^3 - w^3, x^5 - y*z^4]); C
Projective Space Curve over Rational Field defined by x^3 + y^3 - z^3 - w^3, x^5 - y*z^4
Projective Curve over Rational Field defined by x^3 + y^3 - z^3 - w^3, x^5 - y*z^4
sage: C.genus()
13
Expand All @@ -111,7 +111,7 @@ def Curve(F, A=None):
sage: x,y,z = QQ['x,y,z'].gens()
sage: C = Curve([y^2 + x^3 + x^10 + z^7, x^2 + y^2]); C
Affine Space Curve over Rational Field defined by x^10 + z^7 + x^3 + y^2, x^2 + y^2
Affine Curve over Rational Field defined by x^10 + z^7 + x^3 + y^2, x^2 + y^2
sage: C.genus()
47
Expand All @@ -123,7 +123,7 @@ def Curve(F, A=None):
sage: Curve((x-y)*(x+y))
Projective Conic Curve over Rational Field defined by x^2 - y^2
sage: Curve((x-y)^2*(x+y)^2)
Projective Curve over Rational Field defined by x^4 - 2*x^2*y^2 + y^4
Projective Plane Curve over Rational Field defined by x^4 - 2*x^2*y^2 + y^4
EXAMPLE: A union of curves is a curve.
Expand All @@ -133,7 +133,7 @@ def Curve(F, A=None):
sage: C = Curve(x^3 + y^3 + z^3)
sage: D = Curve(x^4 + y^4 + z^4)
sage: C.union(D)
Projective Curve over Rational Field defined by
Projective Plane Curve over Rational Field defined by
x^7 + x^4*y^3 + x^3*y^4 + y^7 + x^4*z^3 + y^4*z^3 + x^3*z^4 + y^3*z^4 + z^7
The intersection is not a curve, though it is a scheme.
Expand Down Expand Up @@ -203,24 +203,24 @@ def Curve(F, A=None):
raise TypeError("F (=%s) must consist of a single nonconstant polynomial to define a plane curve"%(F,))
if is_AffineSpace(A):
if n > 2:
return AffineSpaceCurve_generic(A, F)
return AffineCurve(A, F)
k = A.base_ring()
if is_FiniteField(k):
if k.is_prime_field():
return AffineCurve_prime_finite_field(A, F[0])
return AffineCurve_finite_field(A, F[0])
return AffineCurve_generic(A, F[0])
return AffinePlaneCurve_prime_finite_field(A, F[0])
return AffinePlaneCurve_finite_field(A, F[0])
return AffinePlaneCurve(A, F[0])
elif is_ProjectiveSpace(A):
if not all([f.is_homogeneous() for f in F]):
raise TypeError("polynomials defining a curve in a projective space must be homogeneous")
if n > 2:
return ProjectiveSpaceCurve_generic(A, F)
return ProjectiveCurve(A, F)
k = A.base_ring()
if is_FiniteField(k):
if k.is_prime_field():
return ProjectiveCurve_prime_finite_field(A, F[0])
return ProjectiveCurve_finite_field(A, F[0])
return ProjectiveCurve_generic(A, F[0])
return ProjectivePlaneCurve_prime_finite_field(A, F[0])
return ProjectivePlaneCurve_finite_field(A, F[0])
return ProjectivePlaneCurve(A, F[0])

if is_AlgebraicScheme(F):
return Curve(F.defining_polynomials(), F.ambient_space())
Expand Down
23 changes: 20 additions & 3 deletions src/sage/schemes/curves/curve.py
@@ -1,5 +1,5 @@
"""
Generic plane curves
Generic plane curves.
"""

from sage.misc.all import latex
Expand All @@ -13,6 +13,8 @@

class Curve_generic(AlgebraicScheme_subscheme):
r"""
Generic curve class.
EXAMPLES::
sage: A.<x,y,z> = AffineSpace(QQ,3)
Expand All @@ -23,26 +25,41 @@ class Curve_generic(AlgebraicScheme_subscheme):

def _repr_(self):
"""
Return a string representation of this curve.
EXAMPLES::
sage: A.<x,y,z> = AffineSpace(QQ,3)
sage: C = Curve([x-y,z-2])
sage: C
Affine Space Curve over Rational Field defined by x - y, z - 2
Affine Curve over Rational Field defined by x - y, z - 2
sage: P.<x,y,z> = ProjectiveSpace(QQ,2)
sage: C = Curve(x-y)
sage: C
Projective Curve over Rational Field defined by x - y
Projective Plane Curve over Rational Field defined by x - y
"""
return "%s Curve over %s defined by %s"%(
self._repr_type(), self.base_ring(), ', '.join([str(x) for x in self.defining_polynomials()]))

def _repr_type(self):
r"""
Return a string representation of the type of this curve.
EXAMPLES::
sage: P.<x,y,z,w> = ProjectiveSpace(QQ, 3)
sage: C = Curve([w^3 - z^3, w*x - x^2])
sage: from sage.schemes.curves.curve import Curve_generic
sage: Curve_generic._repr_type(C)
'Generic'
"""
return "Generic"

def _latex_(self):
"""
Return a latex representation of this curve.
EXAMPLES::
sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens()
Expand Down

0 comments on commit 8541591

Please sign in to comment.