Ticket #13130: trac_13130_rings_for_projective_space_v2.patch
File trac_13130_rings_for_projective_space_v2.patch, 47.7 KB (added by , 11 years ago) |
---|
-
sage/schemes/elliptic_curves/ell_point.py
# HG changeset patch # User Ben Hutz # Date 1342523999 14400 # Node ID f5f08c8e1e33507fe95a7ae363538e995d896b5c # Parent 90cdc6a8ad4e4bed83142b4ca0e6c551acd73204 Trac 13130: Ring support for projective space points and morphisms diff --git a/sage/schemes/elliptic_curves/ell_point.py b/sage/schemes/elliptic_curves/ell_point.py
a b 153 153 Standard comparison function for points on elliptic curves, to 154 154 allow sorting and equality testing. 155 155 156 NOTES: 157 158 - __eq__ and __ne__ are implemented in SchemeMorphism_point_projective_ring 159 156 160 EXAMPLES: 157 161 sage: E=EllipticCurve(QQ,[1,1]) 158 162 sage: P=E(0,1) … … 374 378 """ 375 379 Comparison function for points to allow sorting and equality testing. 376 380 381 NOTES: 382 383 - __eq__ and __ne__ are implemented in SchemeMorphism_point_projective_field 384 377 385 EXAMPLES:: 378 386 379 387 sage: E = EllipticCurve('45a') -
sage/schemes/generic/homset.py
diff --git a/sage/schemes/generic/homset.py b/sage/schemes/generic/homset.py
a b 21 21 - William Stein (2006): initial version. 22 22 23 23 - Volker Braun (2011-08-11): significant improvement and refactoring. 24 25 - Ben Hutz (June 2012): added support for projective ring 24 26 """ 25 27 26 28 … … 45 47 from sage.schemes.generic.spec import Spec, is_Spec 46 48 from sage.schemes.generic.morphism import ( 47 49 SchemeMorphism, 48 SchemeMorphism_structure_map, SchemeMorphism_spec, 49 SchemeMorphism_point_affine, 50 SchemeMorphism_point_projective_ring, 51 SchemeMorphism_point_projective_field ) 50 SchemeMorphism_structure_map, 51 SchemeMorphism_spec ) 52 52 53 53 54 54 def is_SchemeHomset(H): … … 716 716 sage: SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2)) 717 717 Set of rational points of Projective Space of dimension 2 over Integer Ring 718 718 """ 719 def _element_constructor_(self, *v, **kwds):720 r"""721 The element constructor.722 723 This is currently not implemented.724 725 EXAMPLES::726 727 sage: from sage.schemes.generic.homset import SchemeHomset_points_projective_ring728 sage: Hom = SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2))729 sage: Hom(1,2,3)730 Traceback (most recent call last):731 ...732 NotImplementedError733 734 TESTS::735 736 sage: Hom._element_constructor_(1,2,3)737 Traceback (most recent call last):738 ...739 NotImplementedError740 """741 check = kwds.get('check', True)742 raise NotImplementedError743 719 744 720 def points(self, B=0): 745 721 """ … … 750 726 - `B` -- integer (optional, default=0). The bound for the 751 727 coordinates. 752 728 753 OUTPUT:754 755 This is currently not implemented and will raise ``NotImplementedError``.756 757 729 EXAMPLES:: 758 730 759 731 sage: from sage.schemes.generic.homset import SchemeHomset_points_projective_ring 760 732 sage: Hom = SchemeHomset_points_projective_ring(Spec(ZZ), ProjectiveSpace(ZZ,2)) 761 sage: Hom.points(5) 762 Traceback (most recent call last): 763 ... 764 NotImplementedError 733 sage: Hom.points(3) 734 [(0 : 0 : 1), (0 : 1 : -3), (0 : 1 : -2), (0 : 1 : -1), (0 : 1 : 0), (0 735 : 1 : 1), (0 : 1 : 2), (0 : 1 : 3), (0 : 2 : -3), (0 : 2 : -1), (0 : 2 : 736 1), (0 : 2 : 3), (0 : 3 : -2), (0 : 3 : -1), (0 : 3 : 1), (0 : 3 : 2), 737 (1 : -3 : -3), (1 : -3 : -2), (1 : -3 : -1), (1 : -3 : 0), (1 : -3 : 1), 738 (1 : -3 : 2), (1 : -3 : 3), (1 : -2 : -3), (1 : -2 : -2), (1 : -2 : -1), 739 (1 : -2 : 0), (1 : -2 : 1), (1 : -2 : 2), (1 : -2 : 3), (1 : -1 : -3), 740 (1 : -1 : -2), (1 : -1 : -1), (1 : -1 : 0), (1 : -1 : 1), (1 : -1 : 2), 741 (1 : -1 : 3), (1 : 0 : -3), (1 : 0 : -2), (1 : 0 : -1), (1 : 0 : 0), (1 742 : 0 : 1), (1 : 0 : 2), (1 : 0 : 3), (1 : 1 : -3), (1 : 1 : -2), (1 : 1 : 743 -1), (1 : 1 : 0), (1 : 1 : 1), (1 : 1 : 2), (1 : 1 : 3), (1 : 2 : -3), 744 (1 : 2 : -2), (1 : 2 : -1), (1 : 2 : 0), (1 : 2 : 1), (1 : 2 : 2), (1 : 745 2 : 3), (1 : 3 : -3), (1 : 3 : -2), (1 : 3 : -1), (1 : 3 : 0), (1 : 3 : 746 1), (1 : 3 : 2), (1 : 3 : 3), (2 : -3 : -3), (2 : -3 : -2), (2 : -3 : 747 -1), (2 : -3 : 0), (2 : -3 : 1), (2 : -3 : 2), (2 : -3 : 3), (2 : -2 : 748 -3), (2 : -2 : -1), (2 : -2 : 1), (2 : -2 : 3), (2 : -1 : -3), (2 : -1 : 749 -2), (2 : -1 : -1), (2 : -1 : 0), (2 : -1 : 1), (2 : -1 : 2), (2 : -1 : 750 3), (2 : 0 : -3), (2 : 0 : -1), (2 : 0 : 1), (2 : 0 : 3), (2 : 1 : -3), 751 (2 : 1 : -2), (2 : 1 : -1), (2 : 1 : 0), (2 : 1 : 1), (2 : 1 : 2), (2 : 752 1 : 3), (2 : 2 : -3), (2 : 2 : -1), (2 : 2 : 1), (2 : 2 : 3), (2 : 3 : 753 -3), (2 : 3 : -2), (2 : 3 : -1), (2 : 3 : 0), (2 : 3 : 1), (2 : 3 : 2), 754 (2 : 3 : 3), (3 : -3 : -2), (3 : -3 : -1), (3 : -3 : 1), (3 : -3 : 2), 755 (3 : -2 : -3), (3 : -2 : -2), (3 : -2 : -1), (3 : -2 : 0), (3 : -2 : 1), 756 (3 : -2 : 2), (3 : -2 : 3), (3 : -1 : -3), (3 : -1 : -2), (3 : -1 : -1), 757 (3 : -1 : 0), (3 : -1 : 1), (3 : -1 : 2), (3 : -1 : 3), (3 : 0 : -2), (3 758 : 0 : -1), (3 : 0 : 1), (3 : 0 : 2), (3 : 1 : -3), (3 : 1 : -2), (3 : 1 759 : -1), (3 : 1 : 0), (3 : 1 : 1), (3 : 1 : 2), (3 : 1 : 3), (3 : 2 : -3), 760 (3 : 2 : -2), (3 : 2 : -1), (3 : 2 : 0), (3 : 2 : 1), (3 : 2 : 2), (3 : 761 2 : 3), (3 : 3 : -2), (3 : 3 : -1), (3 : 3 : 1), (3 : 3 : 2)] 765 762 """ 766 raise NotImplementedError # fixed when _element_constructor_ is defined.767 763 R = self.value_ring() 768 764 if R == ZZ: 769 765 if not B > 0: 770 766 raise TypeError, "A positive bound B (= %s) must be specified."%B 771 from sage.schemes.generic.rational_point simport enum_projective_rational_field767 from sage.schemes.generic.rational_point import enum_projective_rational_field 772 768 return enum_projective_rational_field(self,B) 773 769 else: 774 770 raise TypeError, "Unable to enumerate points over %s."%R -
sage/schemes/generic/morphism.py
diff --git a/sage/schemes/generic/morphism.py b/sage/schemes/generic/morphism.py
a b 55 55 56 56 - Volker Braun (2011-08-08): Renamed classes, more documentation, misc 57 57 cleanups. 58 59 - Ben Hutz (June 2012): added support for projective ring 58 60 """ 59 61 60 62 # Historical note: in trac #11599, V.B. renamed … … 73 75 #***************************************************************************** 74 76 75 77 76 from sage.rings.infinity import infinity77 78 from sage.structure.element import AdditiveGroupElement, RingElement, Element, generic_power 78 79 from sage.structure.sequence import Sequence 79 80 from sage.categories.homset import Homset 80 81 from sage.rings.all import is_RingHomomorphism, is_CommutativeRing, Integer 81 82 from point import is_SchemeTopologicalPoint 82 import scheme 83 from sage.rings.infinity import infinity 84 import scheme 85 86 from sage.rings.arith import gcd, lcm 87 from sage.categories.gcd_domains import GcdDomains 88 from sage.rings.quotient_ring import QuotientRing_generic 89 83 90 84 91 85 92 def is_SchemeMorphism(f): … … 705 712 Some checks are performed to make sure the given polynomials 706 713 define a morphism:: 707 714 708 sage: R.<x,y> = QQ[]709 sage: P1 = ProjectiveSpace(R)710 sage: H = P1.Hom(P1)711 sage: f = H([x^2, x*y])712 Traceback (most recent call last):713 ...714 ValueError: polys (=[x^2, x*y]) must not have common factors715 716 715 sage: f = H([exp(x),exp(y)]) 717 716 Traceback (most recent call last): 718 717 ... … … 745 744 polys = [source_ring(poly) for poly in polys] 746 745 except TypeError: 747 746 raise TypeError, "polys (=%s) must be elements of %s"%(polys,source_ring) 748 from sage.rings.quotient_ring import QuotientRing_generic749 747 if isinstance(source_ring, QuotientRing_generic): 750 748 lift_polys = [f.lift() for f in polys] 751 749 else: 752 750 lift_polys = polys 753 from sage.schemes.generic.projective_space import is_ProjectiveSpace754 if is_ProjectiveSpace(target):755 # if the codomain is a subscheme of projective space,756 # then we need to make sure that polys have no common757 # zeros758 if isinstance(source_ring, QuotientRing_generic):759 # if the coordinate ring of the domain is a760 # quotient by an ideal, we need to check that the761 # gcd of polys and the generators of the ideal is 1762 gcd_polys = lift_polys + list(source_ring.defining_ideal().gens())763 else:764 # if the domain is affine space, we just need to765 # check the gcd of polys766 gcd_polys = polys767 from sage.rings.arith import gcd768 if gcd(gcd_polys) != 1:769 raise ValueError, "polys (=%s) must not have common factors"%polys770 751 polys = Sequence(lift_polys) 771 polys.set_immutable()772 752 # Todo: check that map is well defined (how?) 773 753 self.__polys = polys 774 SchemeMorphism.__init__(self, parent) 754 SchemeMorphism.__init__(self, parent) 775 755 776 756 def defining_polynomials(self): 777 757 """ … … 792 772 """ 793 773 return self.__polys 794 774 795 def __call__(self, x ):775 def __call__(self, x,check=True): 796 776 """ 797 777 Apply this morphism to a point in the domain. 798 778 … … 837 817 Traceback (most recent call last): 838 818 ... 839 819 TypeError: Argument v (=(0,)) must have 2 coordinates. 820 821 :: 822 823 It is possible to avoid the checks on the resulting point which can be useful for indeterminacies, 824 but be careful!! 825 826 sage: PS.<x,y>=ProjectiveSpace(QQ,1) 827 sage: H=Hom(PS,PS) 828 sage: f=H([x^3,x*y^2]) 829 sage: P=PS(0,1) 830 sage: f(P,check=False) 831 (0 : 0) 832 840 833 """ 841 834 dom = self.domain() 842 835 x = dom(x) 843 836 P = [f(x._coords) for f in self.defining_polynomials()] 844 return self.codomain() (P)837 return self.codomain().point(P,check) 845 838 846 839 847 840 def _repr_defn(self): … … 866 859 o = self.codomain().ambient_space()._repr_generic_point(self.defining_polynomials()) 867 860 return "Defined on coordinates by sending %s to\n%s"%(i,o) 868 861 862 def __getitem__(self,i): 863 """ 864 returns the ith poly with self[i] 865 866 Examples:: 867 868 sage: P.<x,y>=ProjectiveSpace(QQ,1) 869 sage: H=Hom(P,P) 870 sage: f=H([3/5*x^2,6*y^2]) 871 sage: f[1] 872 6*y^2 873 """ 874 return(self.__polys[i]) 875 876 def scale_by(self,t): 877 """ 878 Scales each coordiantes by a factor of t. A TypeError occurs if the point is not in the coordinate_ring of the parent after scaling. 879 880 Examples:: 881 882 sage: R.<t>=PolynomialRing(QQ) 883 sage: P.<x,y>=ProjectiveSpace(R,1) 884 sage: H=Hom(P,P) 885 sage: f=H([3/5*x^2,6*y^2]) 886 sage: f.scale_by(5/3*t); f 887 Scheme endomorphism of Projective Space of dimension 1 over Univariate 888 Polynomial Ring in t over Rational Field 889 Defn: Defined on coordinates by sending (x : y) to 890 (t*x^2 : 10*t*y^2) 891 """ 892 if t==0: 893 raise ValueError, "Cannot scale by 0" 894 R=self.domain().coordinate_ring() 895 for i in range(self.codomain().dimension()+1): 896 self.__polys[i]=R(self.__polys[i]*t) 897 898 def normalize_coordinates(self): 899 """ 900 Removes the gcd of the coordinate functions. Also, scales to clear any denominators from the coefficients. 901 This is done in place. 902 903 Input: none 904 905 Output: none 906 907 Examples:: 908 909 sage: P.<x,y>=ProjectiveSpace(QQ,1) 910 sage: H=Hom(P,P) 911 sage: f=H([5/4*x^3,5*x*y^2]) 912 sage: f.normalize_coordinates(); f 913 Scheme endomorphism of Projective Space of dimension 1 over Rational 914 Field 915 Defn: Defined on coordinates by sending (x : y) to 916 (x^2 : 4*y^2) 917 918 Notes: 919 920 -gcd raises an attribute error if the base_ring does not support gcds. 921 """ 922 #computes the gcd of the coordinates as elements of the coordinate_ring and checks if the leading coefficients are all negative 923 GCD = gcd(self[0],self[1]) 924 index=2 925 if self[0].lc()>0 or self[1].lc() >0: 926 neg=0 927 else: 928 neg=1 929 while GCD!=1 and index < self.codomain().dimension()+1: 930 if self[index].lc()>0: 931 neg=0 932 GCD=gcd(GCD,self[index]) 933 index+=+1 934 935 if GCD != 1: 936 R=self.domain().base_ring() 937 if neg==1: 938 self.scale_by(R(-1)/GCD) 939 else: 940 self.scale_by(R(1)/GCD) 941 else: 942 if neg==1: 943 self.scale_by(-1) 944 945 #removes any denominators from the coefficients 946 LCM = lcm([self[i].denominator() for i in range(self.codomain().dimension()+1)]) 947 self.scale_by(LCM) 948 949 #removes any gcd of the coefficients. 950 GCD = gcd([self[i].content() for i in range(self.codomain().dimension()+1)]) 951 if GCD!=1: 952 self.scale_by(1/GCD) 869 953 870 954 class SchemeMorphism_polynomial_affine_space(SchemeMorphism_polynomial): 871 955 """ … … 889 973 """ 890 974 pass 891 975 892 class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial):893 """894 A morphism of schemes determined by rational functions that define895 what the morphism does on points in the ambient projective space.896 897 EXAMPLES::898 899 sage: R.<x,y> = QQ[]900 sage: P1 = ProjectiveSpace(R)901 sage: H = P1.Hom(P1)902 sage: H([y,2*x])903 Scheme endomorphism of Projective Space of dimension 1 over Rational Field904 Defn: Defined on coordinates by sending (x : y) to905 (y : 2*x)906 907 An example of a morphism between projective plane curves (see #10297)::908 909 sage: P2.<x,y,z> = ProjectiveSpace(QQ,2)910 sage: f = x^3+y^3+60*z^3911 sage: g = y^2*z-( x^3 - 6400*z^3/3)912 sage: C = Curve(f)913 sage: E = Curve(g)914 sage: xbar,ybar,zbar = C.coordinate_ring().gens()915 sage: H = C.Hom(E)916 sage: H([zbar,xbar-ybar,-(xbar+ybar)/80])917 Scheme morphism:918 From: Projective Curve over Rational Field defined by x^3 + y^3 + 60*z^3919 To: Projective Curve over Rational Field defined by -x^3 + y^2*z + 6400/3*z^3920 Defn: Defined on coordinates by sending (x : y : z) to921 (z : x - y : -1/80*x - 1/80*y)922 923 A more complicated example::924 925 sage: P2.<x,y,z> = ProjectiveSpace(2,QQ)926 sage: P1 = P2.subscheme(x-y)927 sage: H12 = P1.Hom(P2)928 sage: H12([x^2,x*z, z^2])929 Scheme morphism:930 From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by:931 x - y932 To: Projective Space of dimension 2 over Rational Field933 Defn: Defined on coordinates by sending (x : y : z) to934 (y^2 : y*z : z^2)935 936 We illustrate some error checking::937 938 sage: R.<x,y> = QQ[]939 sage: P1 = ProjectiveSpace(R)940 sage: H = P1.Hom(P1)941 sage: f = H([x-y, x*y])942 Traceback (most recent call last):943 ...944 ValueError: polys (=[x - y, x*y]) must be of the same degree945 946 sage: H([x-1, x*y+x])947 Traceback (most recent call last):948 ...949 ValueError: polys (=[x - 1, x*y + x]) must be homogeneous950 951 sage: H([exp(x),exp(y)])952 Traceback (most recent call last):953 ...954 TypeError: polys (=[e^x, e^y]) must be elements of955 Multivariate Polynomial Ring in x, y over Rational Field956 """957 958 def __init__(self, parent, polys, check=True):959 """960 The Python constructor.961 962 See :class:`SchemeMorphism_polynomial` for details.963 964 EXAMPLES::965 966 sage: P1.<x,y> = ProjectiveSpace(QQ,1)967 sage: H = P1.Hom(P1)968 sage: H([y,2*x])969 Scheme endomorphism of Projective Space of dimension 1 over Rational Field970 Defn: Defined on coordinates by sending (x : y) to971 (y : 2*x)972 """973 SchemeMorphism_polynomial.__init__(self, parent, polys, check)974 if check:975 # morphisms from projective space are always given by976 # homogeneous polynomials of the same degree977 polys = self.defining_polynomials()978 try:979 d = polys[0].degree()980 except AttributeError:981 polys = [f.lift() for f in polys]982 if not all([f.is_homogeneous() for f in polys]):983 raise ValueError, "polys (=%s) must be homogeneous"%polys984 degs = [f.degree() for f in polys]985 if not all([d==degs[0] for d in degs[1:]]):986 raise ValueError, "polys (=%s) must be of the same degree"%polys987 988 976 989 977 ############################################################################ 990 978 # Rational points on schemes, which we view as morphisms determined … … 1218 1206 X.extended_codomain()._check_satisfies_equations(v) 1219 1207 self._coords = tuple(v) 1220 1208 1209 class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): 1210 """ 1211 A morphism of schemes determined by rational functions that define 1212 what the morphism does on points in the ambient projective space. 1221 1213 1214 EXAMPLES:: 1215 1216 sage: R.<x,y> = QQ[] 1217 sage: P1 = ProjectiveSpace(R) 1218 sage: H = P1.Hom(P1) 1219 sage: H([y,2*x]) 1220 Scheme endomorphism of Projective Space of dimension 1 over Rational Field 1221 Defn: Defined on coordinates by sending (x : y) to 1222 (y : 2*x) 1223 1224 An example of a morphism between projective plane curves (see #10297):: 1225 1226 sage: P2.<x,y,z> = ProjectiveSpace(QQ,2) 1227 sage: f = x^3+y^3+60*z^3 1228 sage: g = y^2*z-( x^3 - 6400*z^3/3) 1229 sage: C = Curve(f) 1230 sage: E = Curve(g) 1231 sage: xbar,ybar,zbar = C.coordinate_ring().gens() 1232 sage: H = C.Hom(E) 1233 sage: H([zbar,xbar-ybar,-(xbar+ybar)/80]) 1234 Scheme morphism: 1235 From: Projective Curve over Rational Field defined by x^3 + y^3 + 60*z^3 1236 To: Projective Curve over Rational Field defined by -x^3 + y^2*z + 6400/3*z^3 1237 Defn: Defined on coordinates by sending (x : y : z) to 1238 (z : x - y : -1/80*x - 1/80*y) 1239 1240 A more complicated example:: 1241 1242 sage: P2.<x,y,z> = ProjectiveSpace(2,QQ) 1243 sage: P1 = P2.subscheme(x-y) 1244 sage: H12 = P1.Hom(P2) 1245 sage: H12([x^2,x*z, z^2]) 1246 Scheme morphism: 1247 From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 1248 x - y 1249 To: Projective Space of dimension 2 over Rational Field 1250 Defn: Defined on coordinates by sending (x : y : z) to 1251 (y^2 : y*z : z^2) 1252 1253 We illustrate some error checking:: 1254 1255 sage: R.<x,y> = QQ[] 1256 sage: P1 = ProjectiveSpace(R) 1257 sage: H = P1.Hom(P1) 1258 sage: f = H([x-y, x*y]) 1259 Traceback (most recent call last): 1260 ... 1261 ValueError: polys (=[x - y, x*y]) must be of the same degree 1262 1263 sage: H([x-1, x*y+x]) 1264 Traceback (most recent call last): 1265 ... 1266 ValueError: polys (=[x - 1, x*y + x]) must be homogeneous 1267 1268 sage: H([exp(x),exp(y)]) 1269 Traceback (most recent call last): 1270 ... 1271 TypeError: polys (=[e^x, e^y]) must be elements of 1272 Multivariate Polynomial Ring in x, y over Rational Field 1273 """ 1274 1275 def __init__(self, parent, polys, check=True): 1276 """ 1277 The Python constructor. 1278 1279 See :class:`SchemeMorphism_polynomial` for details. 1280 1281 EXAMPLES:: 1282 1283 sage: P1.<x,y> = ProjectiveSpace(QQ,1) 1284 sage: H = P1.Hom(P1) 1285 sage: H([y,2*x]) 1286 Scheme endomorphism of Projective Space of dimension 1 over Rational Field 1287 Defn: Defined on coordinates by sending (x : y) to 1288 (y : 2*x) 1289 """ 1290 SchemeMorphism_polynomial.__init__(self, parent, polys, check) 1291 if check: 1292 # morphisms from projective space are always given by 1293 # homogeneous polynomials of the same degree 1294 try: 1295 d = polys[0].degree() 1296 except AttributeError: 1297 polys = [f.lift() for f in polys] 1298 if not all([f.is_homogeneous() for f in polys]): 1299 raise ValueError, "polys (=%s) must be homogeneous"%polys 1300 degs = [f.degree() for f in polys] 1301 if not all([d==degs[0] for d in degs[1:]]): 1302 raise ValueError, "polys (=%s) must be of the same degree"%polys 1303 self._polys=polys 1304 1305 def __eq__(self,right): 1306 """ 1307 Tests the equality of two projective spaces. 1308 1309 Examples:: 1310 1311 sage: P1.<x,y> = ProjectiveSpace(RR,1) 1312 sage: P2.<x,y> = ProjectiveSpace(QQ,1) 1313 sage: P1==P2 1314 False 1315 1316 :: 1317 1318 sage: R.<x,y>=QQ[] 1319 sage: P1=ProjectiveSpace(R) 1320 sage: P2.<x,y>=ProjectiveSpace(QQ,1) 1321 sage: P1==P2 1322 True 1323 1324 """ 1325 n=len(self._polys) 1326 for i in range(0,n): 1327 for j in range(i+1,n): 1328 if self._polys[i]*right._polys[j] != self._polys[j]*right._polys[i]: 1329 return False 1330 return True 1331 1332 def __ne__(self,right): 1333 """ 1334 Tests the equality of two projective spaces. 1335 1336 Examples:: 1337 1338 sage: P1.<x,y> = ProjectiveSpace(RR,1) 1339 sage: P2.<x,y> = ProjectiveSpace(QQ,1) 1340 sage: P1!=P2 1341 True 1342 1343 :: 1344 1345 sage: R.<x,y>=QQ[] 1346 sage: P1=ProjectiveSpace(R) 1347 sage: P2.<x,y>=ProjectiveSpace(QQ,1) 1348 sage: P1!=P2 1349 False 1350 1351 """ 1352 n=len(self._polys) 1353 for i in range(0,n): 1354 for j in range(i+1,n): 1355 if self._polys[i]*right._polys[j] != self._polys[j]*right._polys[i]: 1356 return True 1357 return False 1358 1222 1359 #******************************************************************* 1223 1360 # Projective varieties 1224 1361 #******************************************************************* 1225 1362 class SchemeMorphism_point_projective_ring(SchemeMorphism_point): 1226 1363 """ 1227 A rational point of projective space over a ring (how?). 1228 1229 Currently this is not implemented. 1230 1231 EXAMPLES: 1232 1233 sage: from sage.schemes.generic.morphism import SchemeMorphism_point_projective_ring 1234 sage: SchemeMorphism_point_projective_ring(None, None) 1235 Traceback (most recent call last): 1236 ... 1237 NotImplementedError 1364 A rational point of projective space over a ring. 1365 1366 INPUT: 1367 1368 - ``X`` -- a subscheme of an ambient projective space 1369 over a field `K` 1370 1371 - ``v`` -- a list or tuple of coordinates in `K` 1372 1373 - ``check`` -- boolean (optional, default:``True``). Whether to 1374 check the input for consistency. 1375 1376 EXAMPLES:: 1377 1378 sage: P = ProjectiveSpace(2, ZZ) 1379 sage: P(2,3,4) 1380 (2 : 3 : 4) 1238 1381 1239 1382 """ 1383 1240 1384 def __init__(self, X, v, check=True): 1241 1385 """ 1242 The Python constructor 1386 The Python constructor. 1243 1387 1244 EXAMPLES: 1245 1246 sage: from sage.schemes.generic.morphism import SchemeMorphism_point_projective_ring 1247 sage: SchemeMorphism_point_projective_ring(None, None) 1388 See :class:`SchemeMorphism_point_projective_ring` for details. 1389 1390 EXAMPLES:: 1391 1392 sage: P = ProjectiveSpace(2, QQ) 1393 sage: P(2, 3/5, 4) 1394 (1/2 : 3/20 : 1) 1395 1396 :: 1397 1398 sage: P = ProjectiveSpace(1, ZZ) 1399 sage: P([0, 1]) 1400 (0 : 1) 1401 1402 :: 1403 1404 sage: P = ProjectiveSpace(1, ZZ) 1405 sage: P([0, 0, 1]) 1248 1406 Traceback (most recent call last): 1249 1407 ... 1250 NotImplementedError 1408 TypeError: v (=[0, 0, 1]) must have 2 components 1409 1410 :: 1411 1412 sage: P = ProjectiveSpace(3, QQ) 1413 sage: P(0,0,0,0) 1414 Traceback (most recent call last): 1415 ... 1416 ValueError: [0, 0, 0, 0] does not define a valid point since all entries are 0 1417 1418 :: 1419 1420 It is possible to avoid the possibly time consuming checks, but be careful!! 1421 1422 sage: P = ProjectiveSpace(3, QQ) 1423 sage: P.point([0,0,0,0],check=False) 1424 (0 : 0 : 0 : 0) 1425 1426 :: 1427 1428 sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 1429 sage: X=P.subscheme([x^2-y*z]) 1430 sage: X([2,2,2]) 1431 (2 : 2 : 2) 1251 1432 """ 1252 raise NotImplementedError 1433 SchemeMorphism.__init__(self, X) 1434 if check: 1435 from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field 1436 d = X.codomain().ambient_space().ngens() 1437 if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): 1438 v = list(v) 1439 elif v is infinity: 1440 v = [0] * (d) 1441 v[1] = 1 1442 if not isinstance(v,(list,tuple)): 1443 raise TypeError, \ 1444 "Argument v (= %s) must be a scheme point, list, or tuple."%str(v) 1445 if len(v) != d and len(v) != d-1: 1446 raise TypeError, "v (=%s) must have %s components"%(v, d) 1447 1448 R = X.value_ring() 1449 v = Sequence(v, R) 1450 if len(v) == d-1: # very common special case 1451 v.append(1) 1452 1453 n = len(v) 1454 all_zero = True 1455 for i in range(n): 1456 last = n-1-i 1457 if v[last]: 1458 all_zero = False 1459 break 1460 if all_zero: 1461 raise ValueError, "%s does not define a valid point since all entries are 0"%repr(v) 1462 1463 X.extended_codomain()._check_satisfies_equations(v) 1253 1464 1465 if isinstance(X.codomain().base_ring(), QuotientRing_generic): 1466 lift_coords = [P.lift() for P in v] 1467 else: 1468 lift_coords = v 1469 v = Sequence(lift_coords) 1470 1471 self._coords = v 1472 1473 def __eq__(self,right): 1474 """ 1475 Tests the proejctive equality of two points. 1476 1477 Examples:: 1478 1479 sage: PS=ProjectiveSpace(ZZ,1,'x') 1480 sage: P=PS([1,2]) 1481 sage: Q=PS([2,4]) 1482 sage: P==Q 1483 True 1484 1485 :: 1486 1487 sage: PS=ProjectiveSpace(ZZ,1,'x') 1488 sage: P=PS([1,2]) 1489 sage: Q=PS([1,0]) 1490 sage: P==Q 1491 False 1492 1493 :: 1494 1495 sage: PS=ProjectiveSpace(Zp(5),1,'x') 1496 sage: P=PS([0,1]) 1497 sage: P==0 1498 True 1499 1500 :: 1501 1502 sage: R.<t>=PolynomialRing(QQ) 1503 sage: PS=ProjectiveSpace(R,1,'x') 1504 sage: P=PS([t,1+t^2]) 1505 sage: Q=PS([t^2, t+t^3]) 1506 sage: P==Q 1507 True 1508 1509 :: 1510 1511 sage: PS=ProjectiveSpace(ZZ,2,'x') 1512 sage: P=PS([0,1,2]) 1513 sage: P==0 1514 False 1254 1515 1516 :: 1517 1518 sage: PS=ProjectiveSpace(ZZ,1,'x') 1519 sage: P=PS([2,1]) 1520 sage: PS2=ProjectiveSpace(Zp(7),1,'x') 1521 sage: Q=PS2([2,1]) 1522 sage: P==Q 1523 False 1524 1525 :: 1526 1527 sage: PS=ProjectiveSpace(ZZ.quo(6),2,'x') 1528 sage: P=PS([2,4,1]) 1529 sage: Q=PS([0,1,3]) 1530 sage: P==Q 1531 False 1532 1533 :: 1534 1535 sage: R.<z>=PolynomialRing(QQ) 1536 sage: K.<t>=NumberField(z^2+5) 1537 sage: OK=K.ring_of_integers() 1538 sage: t=OK.gen(1) 1539 sage: PS.<x,y>=ProjectiveSpace(OK,1) 1540 sage: P=PS(2,1+t) 1541 sage: Q=PS(1-t,3) 1542 sage: P==Q 1543 True 1544 1545 """ 1546 if not isinstance(right, SchemeMorphism_point): 1547 try: 1548 right = self.codomain()(right) 1549 except TypeError: 1550 return False 1551 if self.codomain()!=right.codomain(): 1552 return False 1553 n=len(self._coords) 1554 for i in range(0,n): 1555 for j in range(i+1,n): 1556 if self._coords[i]*right._coords[j] != self._coords[j]*right._coords[i]: 1557 return False 1558 return True 1559 1560 def __ne__(self,right): 1561 """ 1562 Tests the proejctive equality of two points. 1563 1564 Examples:: 1565 1566 sage: PS=ProjectiveSpace(ZZ,1,'x') 1567 sage: P=PS([1,2]) 1568 sage: Q=PS([2,4]) 1569 sage: P!=Q 1570 False 1571 1572 :: 1573 1574 sage: PS=ProjectiveSpace(ZZ,1,'x') 1575 sage: P=PS([1,2]) 1576 sage: Q=PS([1,0]) 1577 sage: P!=Q 1578 True 1579 1580 :: 1581 1582 sage: PS=ProjectiveSpace(Zp(5),1,'x') 1583 sage: P=PS([0,1]) 1584 sage: P!=0 1585 False 1586 1587 :: 1588 1589 sage: R.<t>=PolynomialRing(QQ) 1590 sage: PS=ProjectiveSpace(R,1,'x') 1591 sage: P=PS([t,1+t^2]) 1592 sage: Q=PS([t^2, t+t^3]) 1593 sage: P!=Q 1594 False 1595 1596 :: 1597 1598 sage: PS=ProjectiveSpace(ZZ,2,'x') 1599 sage: P=PS([0,1,2]) 1600 sage: P!=0 1601 True 1602 1603 :: 1604 1605 sage: PS=ProjectiveSpace(ZZ,1,'x') 1606 sage: P=PS([2,1]) 1607 sage: PS2=ProjectiveSpace(Zp(7),1,'x') 1608 sage: Q=PS2([2,1]) 1609 sage: P!=Q 1610 True 1611 1612 :: 1613 1614 sage: PS=ProjectiveSpace(ZZ.quo(6),2,'x') 1615 sage: P=PS([2,4,1]) 1616 sage: Q=PS([0,1,3]) 1617 sage: P!=Q 1618 True 1619 """ 1620 if not isinstance(right, SchemeMorphism_point): 1621 try: 1622 right = self.codomain()(right) 1623 except TypeError: 1624 return True 1625 if self.codomain()!=right.codomain(): 1626 return True 1627 n=len(self._coords) 1628 for i in range(0,n): 1629 for j in range(i+1,n): 1630 if self._coords[i]*right._coords[j] != self._coords[j]*right._coords[i]: 1631 return True 1632 return False 1633 1634 def scale_by(self,t): 1635 """ 1636 Scale the coordinates of the point by t. A TypeError occurs if the point is not in the base_ring of the codomain after scaling. 1637 1638 Examples:: 1639 1640 sage: R.<t>=PolynomialRing(QQ) 1641 sage: P=ProjectiveSpace(R,2,'x') 1642 sage: p=P([3/5*t^3,6*t, t]) 1643 sage: p.scale_by(1/t); p 1644 (3/5*t^2 : 6 : 1) 1645 1646 """ 1647 if t==0: 1648 raise ValueError, "Cannot scale by 0" 1649 R=self.codomain().base_ring() 1650 for i in range(len(self._coords)): 1651 self._coords[i]=R(self._coords[i]*t) 1652 1653 def normalize_coordinates(self): 1654 """ 1655 Removes common factors from the coordinates of self (including -1). 1656 1657 Examples:: 1658 1659 sage: P=ProjectiveSpace(ZZ,2,'x') 1660 sage: p=P([-5,-15,-20]) 1661 sage: p.normalize_coordinates(); p 1662 (1 : 3 : 4) 1663 1664 :: 1665 1666 sage: P=ProjectiveSpace(Zp(7),2,'x') 1667 sage: p=P([-5,-15,-2]) 1668 sage: p.normalize_coordinates(); p 1669 (5 + O(7^20) : 1 + 2*7 + O(7^20) : 2 + O(7^20)) 1670 1671 :: 1672 1673 sage: R.<t>=PolynomialRing(QQ) 1674 sage: P=ProjectiveSpace(R,2,'x') 1675 sage: p=P([3/5*t^3,6*t, t]) 1676 sage: p.normalize_coordinates(); p 1677 (3/5*t^2 : 6 : 1) 1678 """ 1679 # if isinstance(self.codomain().base_ring(),QutientRing) 1680 R=self.codomain().base_ring() 1681 GCD = R(gcd(self[0],self[1])) 1682 index=2 1683 if self[0]>0 or self[1] >0: 1684 neg=0 1685 else: 1686 neg=1 1687 while GCD!=1 and index < len(self._coords): 1688 if self[index]>0: 1689 neg=0 1690 GCD=R(gcd(GCD,self[index])) 1691 index+=+1 1692 if GCD != 1: 1693 if neg==1: 1694 self.scale_by(R(-1)/GCD) 1695 else: 1696 self.scale_by(R(1)/GCD) 1697 else: 1698 if neg==1: 1699 self.scale_by(R(-1)) 1700 1255 1701 class SchemeMorphism_point_projective_field(SchemeMorphism_point_projective_ring): 1256 1702 """ 1257 1703 A rational point of projective space over a field. … … 1271 1717 sage: P = ProjectiveSpace(3, RR) 1272 1718 sage: P(2,3,4,5) 1273 1719 (0.400000000000000 : 0.600000000000000 : 0.800000000000000 : 1.00000000000000) 1274 1275 Not all homogeneous coordinates are allowed to vanish simultaneously:: 1720 """ 1276 1721 1277 sage: P = ProjectiveSpace(3, QQ)1278 sage: P(0,0,0,0)1279 Traceback (most recent call last):1280 ...1281 ValueError: [0, 0, 0, 0] does not define a valid point since all entries are 01282 """1283 1722 def __init__(self, X, v, check=True): 1284 1723 """ 1285 1724 The Python constructor. 1286 1287 See :class:`SchemeMorphism_point_projective_field` for details. 1725 1726 See :class:`SchemeMorphism_point_projective_ring` for details. 1727 1728 This function still normalized points so that the rightmost non-zero coordinate is 1. The is to maintain current functionality with current 1729 implementations of curves in projectives space (plane, connic, elliptic, etc). The class:`SchemeMorphism_point_projective_ring` is for general use. 1288 1730 1289 1731 EXAMPLES:: 1290 1291 sage: P = ProjectiveSpace(2, CDF) 1292 sage: P(2+I, 3-I, 4+5*I) 1293 (0.317073170732 - 0.146341463415*I : 0.170731707317 - 0.463414634146*I : 1.0) 1732 1733 sage: P = ProjectiveSpace(2, QQ) 1734 sage: P(2, 3/5, 4) 1735 (1/2 : 3/20 : 1) 1736 1737 :: 1738 1739 sage: P = ProjectiveSpace(3, QQ) 1740 sage: P(0,0,0,0) 1741 Traceback (most recent call last): 1742 ... 1743 ValueError: [0, 0, 0, 0] does not define a valid point since all entries are 0 1744 1745 :: 1746 1747 sage: P.<x, y, z> = ProjectiveSpace(2, QQ) 1748 sage: X=P.subscheme([x^2-y*z]) 1749 sage: X([2,2,2]) 1750 (1 : 1 : 1) 1294 1751 """ 1295 1752 SchemeMorphism.__init__(self, X) 1296 1753 if check: … … 1306 1763 "Argument v (= %s) must be a scheme point, list, or tuple."%str(v) 1307 1764 if len(v) != d and len(v) != d-1: 1308 1765 raise TypeError, "v (=%s) must have %s components"%(v, d) 1309 #v = Sequence(v, X.base_ring())1766 1310 1767 R = X.value_ring() 1311 1768 v = Sequence(v, R) 1312 1769 if len(v) == d-1: # very common special case … … 1327 1784 break 1328 1785 if all_zero: 1329 1786 raise ValueError, "%s does not define a valid point since all entries are 0"%repr(v) 1330 1787 1331 1788 X.extended_codomain()._check_satisfies_equations(v) 1332 1789 1333 1790 self._coords = v 1334 1791 1792 def __eq__(self,right): 1793 """ 1794 Tests the equality of two points assuming they have been normalized to the rightmost non-zero coordinate is 1. 1795 1796 Examples:: 1797 1798 sage: PS=ProjectiveSpace(QQ,1,'x') 1799 sage: P=PS([1,2]) 1800 sage: Q=PS([2,4]) 1801 sage: P==Q 1802 True 1803 1804 :: 1805 1806 sage: PS=ProjectiveSpace(QQ,1,'x') 1807 sage: P=PS([1,2]) 1808 sage: Q=PS([1,0]) 1809 sage: P==Q 1810 False 1811 1812 :: 1813 1814 sage: PS=ProjectiveSpace(QQ,1,'x') 1815 sage: P=PS([0,1]) 1816 sage: P==0 1817 True 1818 1819 :: 1820 1821 sage: PS=ProjectiveSpace(QQ,2,'x') 1822 sage: P=PS([0,1,2]) 1823 sage: P==0 1824 False 1825 1826 :: 1827 1828 sage: PS=ProjectiveSpace(QQ,1,'x') 1829 sage: P=PS([2,1]) 1830 sage: PS2=ProjectiveSpace(RR,1,'x') 1831 sage: Q=PS2([2,1]) 1832 sage: P==Q 1833 False 1834 1835 :: 1836 1837 sage: PS=ProjectiveSpace(CC,1,'x') 1838 sage: P=PS([2,1]) 1839 sage: Q=PS([2,1]) 1840 sage: P==Q 1841 True 1842 1843 :: 1844 1845 sage: PS=ProjectiveSpace(ZZ.quo(5),2,'x') 1846 sage: P=PS([2,4,1]) 1847 sage: Q=PS([0,1,3]) 1848 sage: P==Q 1849 False 1850 1851 :: 1852 1853 sage: PS=ProjectiveSpace(Qp(13),1,'x') 1854 sage: P=PS([1/2,5]) 1855 sage: Q=PS([3,7]) 1856 sage: P==Q 1857 False 1858 1859 :: 1860 1861 sage: E=EllipticCurve(QQ,[1,1]) 1862 sage: P=E(0,1) 1863 sage: Q=P+P 1864 sage: P==Q 1865 False 1866 sage: Q+Q == 4*P 1867 True 1868 """ 1335 1869 1870 if not isinstance(right, SchemeMorphism_point): 1871 try: 1872 right = self.codomain()(right) 1873 except TypeError: 1874 return False 1875 if self.codomain()!=right.codomain(): 1876 return False 1877 return self._coords==right._coords 1878 1879 def __ne__(self,right): 1880 """ 1881 Tests the inequality of two points assuming they have been normalized to the rightmost non-zero coordinate is 1. 1882 1883 Examples:: 1884 1885 sage: PS=ProjectiveSpace(QQ,1,'x') 1886 sage: P=PS([1,2]) 1887 sage: Q=PS([2,4]) 1888 sage: P!=Q 1889 False 1890 1891 :: 1892 1893 sage: PS=ProjectiveSpace(QQ,1,'x') 1894 sage: P=PS([1,2]) 1895 sage: Q=PS([1,0]) 1896 sage: P!=Q 1897 True 1898 1899 :: 1900 1901 sage: PS=ProjectiveSpace(QQ,1,'x') 1902 sage: P=PS([0,1]) 1903 sage: P!=0 1904 False 1905 1906 :: 1907 1908 sage: PS=ProjectiveSpace(QQ,2,'x') 1909 sage: P=PS([0,1,2]) 1910 sage: P!=0 1911 True 1912 1913 :: 1914 sage: PS=ProjectiveSpace(QQ,1,'x') 1915 sage: P=PS([2,1]) 1916 sage: PS2=ProjectiveSpace(RR,1,'x') 1917 sage: Q=PS2([2,1]) 1918 sage: P!=Q 1919 True 1920 1921 :: 1922 1923 sage: PS=ProjectiveSpace(CC,1,'x') 1924 sage: P=PS([2,1]) 1925 sage: Q=PS([2,1]) 1926 sage: P!=Q 1927 False 1928 1929 :: 1930 1931 sage: PS=ProjectiveSpace(ZZ.quo(5),2,'x') 1932 sage: P=PS([2,4,1]) 1933 sage: Q=PS([0,1,3]) 1934 sage: P!=Q 1935 True 1936 1937 :: 1938 1939 sage: PS=ProjectiveSpace(Qp(13),1,'x') 1940 sage: P=PS([1/2,5]) 1941 sage: Q=PS([3,7]) 1942 sage: P!=Q 1943 True 1944 1945 :: 1946 1947 sage: E=EllipticCurve(QQ,[1,1]) 1948 sage: P=E(0,1) 1949 sage: Q=P+P 1950 sage: P!=Q 1951 True 1952 sage: Q+Q != 4*P 1953 False 1954 """ 1955 if not isinstance(right, SchemeMorphism_point): 1956 try: 1957 right = self.codomain()(right) 1958 except TypeError: 1959 return True 1960 if self.codomain()!=right.codomain(): 1961 return True 1962 return self._coords!=right._coords 1336 1963 1337 1964 #******************************************************************* 1338 1965 # Abelian varieties … … 1353 1980 """ 1354 1981 pass 1355 1982 1356 1357 1358 -
sage/schemes/generic/point.py
diff --git a/sage/schemes/generic/point.py b/sage/schemes/generic/point.py
a b 1 1 """ 2 2 Points on schemes 3 4 AUTHORS: 5 6 - William Stein (2006): initial version. 7 8 - Ben Hutz (June 2012): added support for projective ring 9 3 10 """ 4 11 5 12 #******************************************************************************* … … 69 76 ######################################################## 70 77 # Topological points on a scheme 71 78 ######################################################## 72 73 79 def is_SchemeTopologicalPoint(x): 74 80 return isinstance(x, SchemeTopologicalPoint) 75 81 76 82 class SchemeTopologicalPoint(SchemePoint): 77 83 pass 78 84 85 79 86 class SchemeTopologicalPoint_affine_open(SchemeTopologicalPoint): 80 87 def __init__(self, u, x): 81 88 """ -
sage/schemes/generic/projective_space.py
diff --git a/sage/schemes/generic/projective_space.py b/sage/schemes/generic/projective_space.py
a b 75 75 from sage.combinat.tuple import Tuples 76 76 77 77 from ambient_space import AmbientSpace 78 import homset 78 from homset import (SchemeHomset_points_projective_ring, SchemeHomset_points_projective_field) 79 79 import morphism 80 80 81 81 … … 140 140 sage: P.coordinate_ring() is R 141 141 True 142 142 143 :: 144 145 sage: ProjectiveSpace(3, Zp(5), 'y') 146 Projective Space of dimension 3 over 5-adic Ring with capped relative precision 20 147 148 :: 149 150 sage: ProjectiveSpace(2,QQ,'x,y,z') 151 Projective Space of dimension 2 over Rational Field 152 153 :: 154 155 sage: PS.<x,y>=ProjectiveSpace(1,CC) 156 sage: PS 157 Projective Space of dimension 1 over Complex Field with 53 bits of precision 158 143 159 Projective spaces are not cached, i.e., there can be several with 144 160 the same base ring and dimension (to facilitate gluing 145 161 constructions). … … 220 236 TypeError otherwise. 221 237 222 238 EXAMPLES:: 223 239 224 240 sage: P = ProjectiveSpace(2, ZZ) 225 241 sage: P._check_satisfies_equations([1, 1, 0]) 226 242 True 227 sage: P._check_satisfies_equations((0, 1, 0)) 243 244 :: 245 246 sage: P = ProjectiveSpace(1, QQ) 247 sage: P._check_satisfies_equations((1/2, 0)) 228 248 True 249 250 :: 251 252 sage: P = ProjectiveSpace(2, ZZ) 229 253 sage: P._check_satisfies_equations([0, 0, 0]) 230 254 Traceback (most recent call last): 231 255 ... 232 256 TypeError: The zero vector is not a point in projective space 233 sage: P._check_satisfies_equations([1, 2, 3, 4, 5]) 257 258 :: 259 260 sage: P = ProjectiveSpace(2, ZZ) 261 sage: P._check_satisfies_equations((1, 0)) 234 262 Traceback (most recent call last): 235 263 ... 236 TypeError: The list v=[1, 2, 3, 4, 5] must have 3 components 237 sage: P._check_satisfies_equations([1/2, 1, 1]) 264 TypeError: The list v=(1, 0) must have 3 components 265 266 :: 267 268 sage: P = ProjectiveSpace(2, ZZ) 269 sage: P._check_satisfies_equations([1/2, 0, 1]) 238 270 Traceback (most recent call last): 239 271 ... 240 TypeError: The components of v=[1/2, 1, 1] must be elements of Integer Ring 241 sage: P._check_satisfies_equations(5) 242 Traceback (most recent call last): 243 ... 244 TypeError: The argument v=5 must be a list or tuple 272 TypeError: The components of v=[1/2, 0, 1] must be elements of Integer Ring 245 273 """ 246 274 if not isinstance(v, (list, tuple)): 247 275 raise TypeError, 'The argument v=%s must be a list or tuple'%v … … 302 330 EXAMPLES:: 303 331 304 332 sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 305 sage: P._validate((x*y - z^2, x)) 306 (x*y - z^2, x) 333 sage: P._validate([x*y - z^2, x]) 334 [x*y - z^2, x] 335 336 :: 337 338 sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 307 339 sage: P._validate((x*y - z, x)) 308 340 Traceback (most recent call last): 309 341 ... 310 342 TypeError: x*y - z is not a homogeneous polynomial! 343 344 :: 345 346 sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 347 sage: P._validate(x*y - z) 348 Traceback (most recent call last): 349 ... 350 TypeError: The argument polynomials=x*y - z must be a list or tuple 311 351 """ 352 if not isinstance(polynomials, (list, tuple)): 353 raise TypeError, 'The argument polynomials=%s must be a list or tuple'%polynomials 312 354 for f in polynomials: 313 355 if not f.is_homogeneous(): 314 356 raise TypeError("%s is not a homogeneous polynomial!" % f) … … 376 418 sage: P2._point_homset(Spec(GF(3)), P2) 377 419 Set of rational points of Projective Space of dimension 2 over Finite Field of size 3 378 420 """ 379 return homset.SchemeHomset_points_projective_ring(*args, **kwds)421 return SchemeHomset_points_projective_ring(*args, **kwds) 380 422 381 423 def _point(self, *args, **kwds): 382 424 """ … … 478 520 return ProjectiveSpace(self.dimension_relative(), R, 479 521 self.variable_names()) 480 522 523 def dimension(self): 524 r""" 525 returns the dimension of the projective space 526 527 Input: None 528 529 Output: 530 531 - a positive integer, the dimension of self (`\mathbb{P}^N`returns `N`) 532 533 EXAMPLES:: 534 535 sage: ProjectiveSpace(2).dimension() 536 2 537 538 :: 539 540 sage: ProjectiveSpace(3,QQ,'x').dimension() 541 3 542 """ 543 return(self.dimension_relative()) 544 481 545 def is_projective(self): 482 546 """ 483 547 Return that this ambient space is projective n-space. … … 544 608 545 609 OUTPUT: 546 610 547 An ambient affine space with fixed projective_embedding map.611 - An ambient affine space with fixed projective_embedding map. 548 612 549 613 EXAMPLES:: 550 614 … … 596 660 sage: P2._point_homset(Spec(GF(3)), P2) 597 661 Set of rational points of Projective Space of dimension 2 over Finite Field of size 3 598 662 """ 599 return homset.SchemeHomset_points_projective_field(*args, **kwds)663 return SchemeHomset_points_projective_field(*args, **kwds) 600 664 601 665 def _point(self, *args, **kwds): 602 666 """ … … 732 796 1), (-1/2 : 1 : 1), (1/2 : 1 : 1), (-2 : 1 : 0), (-1 : 1 : 0), (0 : 1 : 733 797 0), (1 : 1 : 0), (2 : 1 : 0), (-1/2 : 1 : 0), (1/2 : 1 : 0), (1 : 0 : 734 798 0)] 799 735 800 736 801 .. note:: 737 802 -
sage/schemes/readme.py
diff --git a/sage/schemes/readme.py b/sage/schemes/readme.py
a b 144 144 :: 145 145 146 146 sage: P( [2, 1+t] ) 147 Traceback (most recent call last): 148 ... 149 NotImplementedError 147 (2 : t + 1 : 1) 150 148 151 149 In fact, we need a test ``R.ideal([2,1+t]) == R.ideal([1])`` in order 152 150 to make this meaningful.