Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/dynamics/flat_surfaces/quadratic_strata.py
8817 views
1
r"""
2
Strata of quadratic differentials on Riemann surfaces
3
"""
4
from sage.structure.sage_object import SageObject
5
from sage.rings.integer import Integer
6
from sage.rings.rational import Rational
7
8
class QuadraticStratum(SageObject):
9
r"""
10
Stratum of quadratic differentials.
11
"""
12
def __init__(self, *l):
13
"""
14
TESTS::
15
16
sage: a = QuadraticStratum(-1,-1,-1,-1)
17
sage: loads(dumps(a)) == a
18
True
19
sage: QuadraticStratum([])
20
Traceback (most recent call last):
21
...
22
ValueError: the list must be non empty !
23
"""
24
if isinstance(l[0], list) or isinstance(l[0], tuple):
25
if not l[0]:
26
raise ValueError("the list must be non empty !")
27
self._zeroes = []
28
for (i, j) in l.iteritems():
29
i = Integer(i)
30
j = Integer(j)
31
self._zeroes += [i]*j
32
else:
33
for i in l:
34
i = Integer(i)
35
self._zeroes = sorted(list(l), reverse=True)
36
37
38
self._genus = sum(l)/4 + 1
39
self._genus = Integer(self._genus)
40
41
def __repr__(self):
42
r"""
43
TESTS::
44
45
sage: a = QuadraticStratum(-1,-1,-1,-1)
46
sage: print a
47
Q(-1, -1, -1, -1)
48
"""
49
return "Q(" + str(self._zeroes)[1:-1] + ")"
50
51
def __str__(self):
52
r"""
53
TESTS::
54
55
sage: a = QuadraticStratum(-1,-1,-1,-1)
56
sage: print a
57
Q(-1, -1, -1, -1)
58
"""
59
return "Q(" + str(self._zeroes)[1:-1] + ")"
60
61
def __eq__(self, other):
62
r"""
63
TESTS::
64
65
sage: QuadraticStratum(0) == QuadraticStratum(0)
66
True
67
sage: QuadraticStratum(4) == QuadraticStratum(0)
68
False
69
"""
70
return type(self) == type(other) and self._zeroes == other._zeroes
71
72
def __ne__(self, other):
73
r"""
74
TESTS::
75
76
sage: QuadraticStratum(0) != QuadraticStratum(0)
77
False
78
sage: QuadraticStratum(4) != QuadraticStratum(0)
79
True
80
"""
81
return type(self) != type(other) or self._zeroes != other._zeroes
82
83
def genus(self):
84
r"""
85
Returns the genus.
86
87
EXAMPLES:
88
89
::
90
91
sage: QuadraticStratum(-1,-1,-1,-1).genus()
92
0
93
"""
94
return self._genus
95
96