# HG changeset patch
# User Marco Streng
# Date 1279489122 7200
# Node ID 7fadb062f93110d6495bf815dc84d4724315635c
# Parent 1139fd5c5a44a4b005a484385ade564bd8ea1364
Trac 727: fix doctests, remove global field
diff r 1139fd5c5a44 r 7fadb062f931 doc/en/reference/plane_curves.rst
 a/doc/en/reference/plane_curves.rst Fri Jul 16 20:26:26 2010 +0200
+++ b/doc/en/reference/plane_curves.rst Sun Jul 18 23:38:42 2010 +0200
@@ 13,7 +13,6 @@
sage/schemes/plane_conics/constructor
sage/schemes/plane_conics/con_field
 sage/schemes/plane_conics/con_global_field
sage/schemes/plane_conics/con_number_field
sage/schemes/plane_conics/con_rational_field
sage/schemes/plane_conics/con_finite_field
diff r 1139fd5c5a44 r 7fadb062f931 sage/schemes/plane_conics/con_global_field.py
 a/sage/schemes/plane_conics/con_global_field.py Fri Jul 16 20:26:26 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ 1,129 +0,0 @@
r"""
Projective plane conics over a global field.

AUTHORS:

 Marco Streng (20090807)

 Nick Alexander (20080108)

"""
#*****************************************************************************
# Copyright (C) 2008 Nick Alexander
# Copyright (C) 2009 Marco Streng
#
# 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.
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
#*****************************************************************************

from con_field import ProjectiveConic_field

class ProjectiveConic_global_field(ProjectiveConic_field):
 r"""
 Create a projective plane conic curve over a global field.
 See ``Conic`` for full documentation.

 EXAMPLES::

 sage: K. = NumberField(x^3  2, 'a')
 sage: P. = K[]
 sage: Conic(X^2 + Y^2  a*Z^2)
 Projective Conic Curve over Number Field in a with defining polynomial x^3  2 defined by X^2 + Y^2 + (a)*Z^2

 TESTS::

 sage: K. = NumberField(x^3  3, 'a')
 sage: Conic([a, 1, 1])._test_pickling()
 """
 def __init__(self, A, f):
 r"""
 See ``Conic`` for full documentation.

 EXAMPLES:

 ::

 sage: Conic([1, 1, 1])
 Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2
 """
 ProjectiveConic_field.__init__(self, A, f)
 # a single prime such that self has no point over the completion
 self._local_obstruction = None
 # all finite primes such that self has no point over the completion
 self._finite_obstructions = None
 # all infinite primes such that self has no point over the completion
 self._infinite_obstructions = None


 def is_locally_solvable(self, p):
 r"""
 Returns ``True`` if and only if ``self`` has a solution over the completion
 of the base field `B` of self at ``p``. Here ``p`` is a finite prime
 or infinite place of `B`.

 EXAMPLES:

 An example over `\QQ` ::

 sage: C = Conic(QQ, [1,2,3])
 sage: C.is_locally_solvable(1)
 False
 sage: C.is_locally_solvable(2)
 False
 sage: C.is_locally_solvable(3)
 True

 An example over a number field ::

 sage: P. = QQ[]
 sage: K. = NumberField(x^3 + 5)
 sage: C = Conic(K, [1, 2, 3  a])
 sage: [p1, p2] = K.places()
 sage: C.is_locally_solvable(p1)
 Traceback (most recent call last):
 ...
 NotImplementedError: is_locally_solvable not yet implemented for conics over number fields, please implement it using generalized_hilbert_symbol of Trac 9334
 sage: C.is_locally_solvable(p2)
 Traceback (most recent call last):
 ...
 NotImplementedError: is_locally_solvable not yet implemented for conics over number fields, please implement it using generalized_hilbert_symbol of Trac 9334
 """
 raise NotImplementedError, "please implement is_locally_solvable for " \
 "conics over global field %s" % B

 def local_obstructions(self, finite = True, infinite = True, read_cache = True):
 r"""
 Returns the sequence of finite primes and/or infinite places
 such that self is locally solvable at those primes and places.

 If the base field is `\QQ`, then the infinite place is denoted `1`.

 The parameters ``finite`` and ``infinite`` (both ``True`` by default)
 are used to specify whether to look at finite and/or infinite places.
 Note that ``finite = True`` involves factorization of the determinant
 of self, hence may be slow.

 Local obstructions are cached. The parameter ``read_cache`` specifies
 whether to look at the cache before computing anything.

 EXAMPLES::

 sage: Conic(QQ, [1, 1, 1]).local_obstructions()
 [2, 1]
 sage: Conic(QQ, [1, 2, 3]).local_obstructions()
 []
 sage: Conic(QQ, [1, 2, 3, 4, 5, 6]).local_obstructions()
 [41, 1]

 """
 raise NotImplementedError, "please implement local_obstructions for " \
 "conics over global field %s" % B

diff r 1139fd5c5a44 r 7fadb062f931 sage/schemes/plane_conics/con_number_field.py
 a/sage/schemes/plane_conics/con_number_field.py Fri Jul 16 20:26:26 2010 +0200
+++ b/sage/schemes/plane_conics/con_number_field.py Sun Jul 18 23:38:42 2010 +0200
@@ 27,10 +27,10 @@
from sage.rings.all import is_RationalField
from sage.rings.number_field.number_field import is_NumberField
from sage.modules.free_module_element import vector
from con_global_field import ProjectiveConic_global_field
+from con_field import ProjectiveConic_field
from rnfisnorm import _rnfisnorm
class ProjectiveConic_number_field(ProjectiveConic_global_field):
+class ProjectiveConic_number_field(ProjectiveConic_field):
r"""
Create a projective plane conic curve over a number field.
See ``Conic`` for full documentation.
@@ 56,7 +56,13 @@
sage: Conic([1, 1, 1])
Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2
"""
 ProjectiveConic_global_field.__init__(self, A, f)
+ ProjectiveConic_field.__init__(self, A, f)
+ # a single prime such that self has no point over the completion
+ self._local_obstruction = None
+ # all finite primes such that self has no point over the completion
+ self._finite_obstructions = None
+ # all infinite primes such that self has no point over the completion
+ self._infinite_obstructions = None
def has_rational_point(self, point = False, obstruction = False,
@@ 154,6 +160,7 @@
sage: M. = NumberField(X^3+3*X+1)
sage: m = [[Q(b)(F.gen()) for b in a] for a in l for F in [K, L, M]]
sage: d = []
+ sage: c = []
sage: c = [Conic(a) for a in m if a != [0,0,0]] # long time: 1 second
sage: d = [C.has_rational_point(algorithm = 'rnfisnorm', point = True) for C in c] # long time: 15 seconds
sage: assert all([c[k].defining_polynomial()(Sequence(d[k][1])) == 0 for k in range(len(c)) if d[k][0]])
@@ 167,9 +174,8 @@
sage: M. = NumberField(x^5+3*x+1)
sage: m = [[F(b) for b in a] for a in l for F in [K, L, M]]
sage: c = [Conic(a) for a in m if a != [0,0,0] and a != [1,1,1] and a != [1,1,1]] # long time 0.4 seconds
 sage: r = randrange(0, 5)
 sage: assert all([C.has_rational_point(algorithm = 'rnfisnorm') for C in c[r::5]]) # long time: 0.7 seconds
 sage: assert all([C.defining_polynomial()(Sequence(C.has_rational_point(point = True)[1])) == 0 for C in c[r::5]]) # uses cache, long time if previous line isn't run
+ sage: assert all([C.has_rational_point(algorithm = 'rnfisnorm') for C in c]) # long time: 3.5 seconds
+ sage: assert all([C.defining_polynomial()(Sequence(C.has_rational_point(point = True)[1])) == 0 for C in c]) # uses cache, long time if previous line isn't run
"""
if read_cache:
if self._rational_point is not None:
diff r 1139fd5c5a44 r 7fadb062f931 sage/schemes/plane_conics/con_rational_field.py
 a/sage/schemes/plane_conics/con_rational_field.py Fri Jul 16 20:26:26 2010 +0200
+++ b/sage/schemes/plane_conics/con_rational_field.py Sun Jul 18 23:38:42 2010 +0200
@@ 126,7 +126,6 @@
and returns consistent answers for all algorithms. Check if all points returned are valid. ::
sage: l = Sequence(cartesian_product_iterator([[1, 0, 1] for i in range(6)]))
 sage: l += [[QQ(randrange(2,3)) for i in range(3)] for j in range(200)]
sage: c = [Conic(QQ, a) for a in l if a != [0,0,0] and a != (0,0,0,0,0,0)]
sage: d = []
sage: d = [[C]+[C.has_rational_point(algorithm = algorithm, read_cache = False, obstruction = (algorithm != 'rnfisnorm'), point = (algorithm != 'local')) for algorithm in ['local', 'qfsolve', 'rnfisnorm']] for C in c[::10]] # long time: 7 seconds
diff r 1139fd5c5a44 r 7fadb062f931 sage/schemes/plane_conics/constructor.py
 a/sage/schemes/plane_conics/constructor.py Fri Jul 16 20:26:26 2010 +0200
+++ b/sage/schemes/plane_conics/constructor.py Sun Jul 18 23:38:42 2010 +0200
@@ 41,7 +41,6 @@
from con_field import ProjectiveConic_field
from con_finite_field import ProjectiveConic_finite_field
from con_prime_finite_field import ProjectiveConic_prime_finite_field
from con_global_field import ProjectiveConic_global_field
from con_number_field import ProjectiveConic_number_field
from con_rational_field import ProjectiveConic_rational_field
diff r 1139fd5c5a44 r 7fadb062f931 sage/schemes/plane_conics/rnfisnorm.py
 a/sage/schemes/plane_conics/rnfisnorm.py Fri Jul 16 20:26:26 2010 +0200
+++ b/sage/schemes/plane_conics/rnfisnorm.py Sun Jul 18 23:38:42 2010 +0200
@@ 78,6 +78,7 @@
sage: from sage.schemes.plane_conics.rnfisnorm import _rnfisnorm
sage: _rnfisnorm(5/4, 1/5)
+ (True, (1/2, 1/5))
Absolute number fields are interpreted as relative fields over `\QQ`.