56
56
sage: cl2 * cl2.order() == Cl.zero()
57
57
True
58
58
sage: Cl.abelian_group()
59
- Additive abelian group isomorphic to Z/21 embedded in Form Class Group of Discriminant -431
59
+ Additive abelian group isomorphic to Z/21 embedded in
60
+ Form Class Group of Discriminant -431
60
61
sage: Cl.gens() # random
61
62
[Class of 5*x^2 + 3*x*y + 22*y^2]
62
63
sage: Cl.gens()[0].order()
86
87
87
88
from sage .misc .prandom import randrange
88
89
from sage .rings .integer_ring import ZZ
89
- from sage .rings .finite_rings .integer_mod_ring import Zmod
90
90
from sage .rings .finite_rings .integer_mod import Mod
91
- from sage .rings .polynomial .polynomial_ring import polygen
92
91
from sage .arith .misc import random_prime
93
- from sage .matrix .constructor import matrix
94
92
from sage .groups .generic import order_from_multiple , multiple
95
93
from sage .groups .additive_abelian .additive_abelian_wrapper import AdditiveAbelianGroupWrapper
96
94
from sage .quadratic_forms .binary_qf import BinaryQF
@@ -124,7 +122,7 @@ class BQFClassGroup(Parent, UniqueRepresentation):
124
122
Form Class Group of Discriminant -484
125
123
"""
126
124
127
- def __init__ (self , D , * , check = True ):
125
+ def __init__ (self , D , * , check = True ) -> None :
128
126
r"""
129
127
Construct the class group for a given discriminant `D`.
130
128
@@ -159,7 +157,8 @@ def _element_constructor_(self, F, *, check=True):
159
157
Class of 16*x^2 + 5*x*y + 16*y^2
160
158
"""
161
159
if isinstance (F , BQFClassGroup_element ):
162
- if check and F .parent () is not self : # class group is unique parent
160
+ if check and F .parent () is not self :
161
+ # class group is unique parent
163
162
raise ValueError ('quadratic form has incorrect discriminant' )
164
163
return F
165
164
if F == 0 :
@@ -170,8 +169,10 @@ def _element_constructor_(self, F, *, check=True):
170
169
171
170
def zero (self ):
172
171
r"""
173
- Return the neutral element of this group, i.e., the class of the
174
- principal binary quadratic form of the respective discriminant.
172
+ Return the neutral element of this group.
173
+
174
+ This is the class of the principal binary quadratic form of
175
+ the respective discriminant.
175
176
176
177
EXAMPLES::
177
178
@@ -219,7 +220,7 @@ def random_element(self):
219
220
b = - b
220
221
return self (BinaryQF ([a , b , c ]))
221
222
222
- def __hash__ (self ):
223
+ def __hash__ (self ) -> int :
223
224
r"""
224
225
Return a hash value for this form class group.
225
226
@@ -230,7 +231,7 @@ def __hash__(self):
230
231
"""
231
232
return hash (('BQFClassGroup' , self ._disc ))
232
233
233
- def _repr_ (self ):
234
+ def _repr_ (self ) -> str :
234
235
r"""
235
236
Return a string describing this form class group.
236
237
@@ -299,7 +300,8 @@ def abelian_group(self):
299
300
sage: Cl.order()
300
301
16
301
302
sage: G = Cl.abelian_group(); G
302
- Additive abelian group isomorphic to Z/4 + Z/2 + Z/2 embedded in Form Class Group of Discriminant -3108
303
+ Additive abelian group isomorphic to Z/4 + Z/2 + Z/2 embedded in
304
+ Form Class Group of Discriminant -3108
303
305
sage: G.gens() # random
304
306
(Class of 11*x^2 + 4*x*y + 71*y^2,
305
307
Class of 6*x^2 + 6*x*y + 131*y^2,
@@ -314,25 +316,25 @@ def abelian_group(self):
314
316
gens = [BinaryQF (g ) for g in gens ]
315
317
return AdditiveAbelianGroupWrapper (self , gens , ords )
316
318
317
- def gens (self ) -> list :
319
+ def gens (self ) -> tuple :
318
320
r"""
319
321
Return a generating set of this form class group.
320
322
321
323
EXAMPLES::
322
324
323
325
sage: Cl = BQFClassGroup(-4*419)
324
326
sage: Cl.gens()
325
- [ Class of 3*x^2 + 2*x*y + 140*y^2]
327
+ ( Class of 3*x^2 + 2*x*y + 140*y^2,)
326
328
327
329
::
328
330
329
331
sage: Cl = BQFClassGroup(-4*777)
330
332
sage: Cl.gens() # random
331
- [ Class of 11*x^2 + 4*x*y + 71*y^2,
333
+ ( Class of 11*x^2 + 4*x*y + 71*y^2,
332
334
Class of 6*x^2 + 6*x*y + 131*y^2,
333
- Class of 2*x^2 + 2*x*y + 389*y^2]
335
+ Class of 2*x^2 + 2*x*y + 389*y^2)
334
336
"""
335
- return [ g .element () for g in self .abelian_group ().gens ()]
337
+ return tuple ( g .element () for g in self .abelian_group ().gens ())
336
338
337
339
def _coerce_map_from_ (self , other ):
338
340
r"""
@@ -345,7 +347,7 @@ def _coerce_map_from_(self, other):
345
347
346
348
sage: G = BQFClassGroup(-4*117117)
347
349
sage: H = BQFClassGroup(-4*77)
348
- sage: proj = G.hom(H); proj # implicit doctest
350
+ sage: proj = G.hom(H); proj # indirect doctest
349
351
Coercion morphism:
350
352
From: Form Class Group of Discriminant -468468
351
353
To: Form Class Group of Discriminant -308
@@ -376,19 +378,19 @@ class BQFClassGroup_element(AdditiveGroupElement):
376
378
EXAMPLES::
377
379
378
380
sage: F = BinaryQF([22, 91, 99])
379
- sage: F.form_class() # implicit doctest
381
+ sage: F.form_class() # indirect doctest
380
382
Class of 5*x^2 - 3*x*y + 22*y^2
381
383
382
384
::
383
385
384
386
sage: Cl = BQFClassGroup(-4*419)
385
387
sage: Cl.zero()
386
388
Class of x^2 + 419*y^2
387
- sage: Cl.gens()[0] # implicit doctest
389
+ sage: Cl.gens()[0] # indirect doctest
388
390
Class of 3*x^2 + 2*x*y + 140*y^2
389
391
"""
390
392
391
- def __init__ (self , F , parent , * , check = True , reduce = True ):
393
+ def __init__ (self , F , parent , * , check = True , reduce = True ) -> None :
392
394
r"""
393
395
Constructor for classes of binary quadratic forms.
394
396
@@ -515,7 +517,7 @@ def __mul__(self, other):
515
517
516
518
__rmul__ = __mul__
517
519
518
- def __eq__ (self , other ):
520
+ def __eq__ (self , other ) -> bool :
519
521
r"""
520
522
Test two form classes for equality.
521
523
@@ -535,7 +537,7 @@ def __eq__(self, other):
535
537
# as well as hashing.
536
538
return self ._form == other ._form
537
539
538
- def __ne__ (self , other ):
540
+ def __ne__ (self , other ) -> bool :
539
541
r"""
540
542
Test two form classes for inequality.
541
543
@@ -551,7 +553,7 @@ def __ne__(self, other):
551
553
"""
552
554
return self ._form != other ._form
553
555
554
- def __lt__ (self , other ):
556
+ def __lt__ (self , other ) -> bool :
555
557
r"""
556
558
Compare two form classes according to the lexicographic ordering
557
559
on their coefficient lists.
@@ -599,7 +601,7 @@ def is_zero(self) -> bool:
599
601
"""
600
602
return not self
601
603
602
- def __repr__ (self ) -> str :
604
+ def _repr_ (self ) -> str :
603
605
r"""
604
606
Return a string representation of this form class.
605
607
@@ -611,7 +613,7 @@ def __repr__(self) -> str:
611
613
"""
612
614
return f'Class of { self ._form } '
613
615
614
- def __hash__ (self ):
616
+ def __hash__ (self ) -> int :
615
617
r"""
616
618
Return a hash value for this form class.
617
619
@@ -698,7 +700,7 @@ class representative `[a,b,c]` satisfying `f^2 \mid a` and `f \mid b`
698
700
sage: proj(elt) == proj2(proj1(elt))
699
701
True
700
702
"""
701
- def __init__ (self , G , H ):
703
+ def __init__ (self , G , H ) -> None :
702
704
r"""
703
705
Initialize this morphism between class groups of binary
704
706
quadratic forms.
0 commit comments