-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctors.py
724 lines (565 loc) · 27.5 KB
/
functors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
r"""
Functor construction for all spaces
AUTHORS:
- Jonas Jermann (2013): initial version
"""
#*****************************************************************************
# Copyright (C) 2013-2014 Jonas Jermann <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from sage.rings.all import ZZ, QQ, infinity
from sage.categories.functor import Functor
from sage.categories.pushout import ConstructionFunctor
from sage.categories.sets_cat import Sets
from sage.structure.parent import Parent
from sage.categories.commutative_additive_groups import CommutativeAdditiveGroups
from sage.categories.rings import Rings
from constructor import FormsSpace, FormsRing
from abstract_space import FormsSpace_abstract
from subspace import SubSpaceForms
def get_base_ring(ring, var_name="d"):
r"""
Return the base ring of the given ``ring``:
If ``ring`` is of the form ``FractionField(PolynomialRing(R,'d'))``:
Return ``R``.
If ``ring`` is of the form ``FractionField(R)``:
Return ``R``.
If ``ring`` is of the form ``PolynomialRing(R,'d')``:
Return ``R``.
Otherwise return ``ring``.
The base ring is used in the construction of the correponding
``FormsRing`` or ``FormsSpace``. In particular in the construction
of holomorphic forms of degree (0, 1). For (binary)
operations a general ring element is considered (coerced to)
a (constant) holomorphic form of degree (0, 1)
whose construction should be based on the returned base ring
(and not on ``ring``!).
If ``var_name`` (default: "d") is specified then this variable
name is used for the polynomial ring.
EXAMPLES::
sage: get_base_ring(ZZ) == ZZ
True
sage: get_base_ring(QQ) == ZZ
True
sage: get_base_ring(PolynomialRing(CC, 'd')) == CC
True
sage: get_base_ring(PolynomialRing(QQ, 'd')) == ZZ
True
sage: get_base_ring(FractionField(PolynomialRing(CC, 'd'))) == CC
True
sage: get_base_ring(FractionField(PolynomialRing(QQ, 'd'))) == ZZ
True
sage: get_base_ring(PolynomialRing(QQ, 'x')) == PolynomialRing(QQ, 'x')
True
"""
#from sage.rings.fraction_field import is_FractionField
from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
from sage.categories.pushout import FractionField as FractionFieldFunctor
base_ring = ring
#if (is_FractionField(base_ring)):
# base_ring = base_ring.base()
if (base_ring.construction() and base_ring.construction()[0] == FractionFieldFunctor()):
base_ring = base_ring.construction()[1]
if (is_PolynomialRing(base_ring) and base_ring.ngens()==1 and base_ring.variable_name()==var_name):
base_ring = base_ring.base()
if (base_ring.construction() and base_ring.construction()[0] == FractionFieldFunctor()):
base_ring = base_ring.construction()[1]
return base_ring
def ConstantFormsSpaceFunctor(group):
r"""
Construction functor for the space of constant forms.
When determening a common parent between a ring
and a forms ring or space this functor is first
applied to the ring.
EXAMPLES::
sage: ConstantFormsSpaceFunctor(4) == FormsSpaceFunctor("holo", 4, 0, 1)
True
sage: ConstantFormsSpaceFunctor(4)
ModularFormsFunctor(n=4, k=0, ep=1)
"""
return FormsSpaceFunctor("holo", group, QQ(0), ZZ(1))
class FormsSubSpaceFunctor(ConstructionFunctor):
r"""
Construction functor for forms sub spaces.
"""
rank = 10
def __init__(self, ambient_space_functor, basis):
r"""
Construction functor for the forms sub space
for the given ``basis`` inside the ambient space
which is constructed by the ``ambient_space_functor``.
The functor can only be applied to rings for which the basis
can be converted into the corresponding forms space
given by the ``ambient_space_functor`` applied to the ring.
See :meth:`__call__` for a description of the functor.
INPUT:
- ``ambient_space_functor`` - A FormsSpaceFunctor
- ``basis`` - A list of elements of some ambient space
over some base ring.
OUTPUT:
The construction functor for the corresponding forms sub space.
EXAMPLES::
sage: from space import ModularForms
sage: ambient_space = ModularForms(group=4, k=12, ep=1)
sage: ambient_space_functor = FormsSpaceFunctor("holo", group=4, k=12, ep=1)
sage: ambient_space_functor
ModularFormsFunctor(n=4, k=12, ep=1)
sage: el = ambient_space.gen(0).full_reduce()
sage: FormsSubSpaceFunctor(ambient_space_functor, [el])
FormsSubSpaceFunctor with 1 basis element for the ModularFormsFunctor(n=4, k=12, ep=1)
"""
Functor.__init__(self, Rings(), CommutativeAdditiveGroups())
if not isinstance(ambient_space_functor, FormsSpaceFunctor):
raise Exception("{} is not a FormsSpaceFunctor!".format(ambient_space_functor))
# TODO: canonical parameters? Some checks?
# The basis should have an associated base ring
# self._basis_ring = ...
# on call check if there is a coercion from self._basis_ring to R
self._ambient_space_functor = ambient_space_functor
self._basis = basis
def __call__(self, R):
r"""
Return the corresponding subspace of the ambient space
constructed by ``self._ambient_space`` with the basis ``self._basis``.
If the ambient space is not a forms space the ambient space is returned.
EXAMPLES::
sage: from space import CuspForms
sage: ambient_space = CuspForms(group=4, k=12, ep=1)
sage: ambient_space_functor = FormsSpaceFunctor("cusp", group=4, k=12, ep=1)
sage: el = ambient_space.gen(0)
sage: F = FormsSubSpaceFunctor(ambient_space_functor, [el])
sage: F
FormsSubSpaceFunctor with 1 basis element for the CuspFormsFunctor(n=4, k=12, ep=1)
sage: F(BaseFacade(ZZ))
Subspace of dimension 1 of CuspForms(n=4, k=12, ep=1) over Integer Ring
sage: F(BaseFacade(CC))
Subspace of dimension 1 of CuspForms(n=4, k=12, ep=1) over Complex Field with 53 bits of precision
sage: F(CC)
ModularFormsRing(n=4) over Complex Field with 53 bits of precision
sage: ambient_space_functor = FormsSpaceFunctor("holo", group=4, k=0, ep=1)
sage: F = FormsSubSpaceFunctor(ambient_space_functor, [1])
sage: F
FormsSubSpaceFunctor with 1 basis element for the ModularFormsFunctor(n=4, k=0, ep=1)
sage: F(BaseFacade(ZZ))
Subspace of dimension 1 of ModularForms(n=4, k=0, ep=1) over Integer Ring
sage: F(CC)
Subspace of dimension 1 of ModularForms(n=4, k=0, ep=1) over Complex Field with 53 bits of precision
"""
ambient_space = self._ambient_space_functor(R)
if isinstance(ambient_space, FormsSpace_abstract):
return SubSpaceForms(ambient_space, self._basis)
else:
return ambient_space
def __str__(self):
r"""
Return the string representation of ``self``.
EXAMPLES::
sage: from space import ModularForms
sage: ambient_space = ModularForms(group=4, k=12, ep=1)
sage: ambient_space_functor = FormsSpaceFunctor("holo", group=4, k=12, ep=1)
sage: FormsSubSpaceFunctor(ambient_space_functor, ambient_space.gens())
FormsSubSpaceFunctor with 2 basis elements for the ModularFormsFunctor(n=4, k=12, ep=1)
sage: FormsSubSpaceFunctor(ambient_space_functor, [ambient_space.gen(0)])
FormsSubSpaceFunctor with 1 basis element for the ModularFormsFunctor(n=4, k=12, ep=1)
"""
return "FormsSubSpaceFunctor with {} basis {} for the {}".format(len(self._basis), 'elements' if len(self._basis) != 1 else 'element', self._ambient_space_functor)
def merge(self, other):
r"""
Return the merged functor of ``self`` and ``other``.
If ``other`` is a ``FormsSubSpaceFunctor`` then
first the common ambient space functor is constructed by
merging the two corresponding functors.
If that ambient space functor is a FormsSpaceFunctor
and the basis agree the corresponding ``FormsSubSpaceFunctor``
is returned.
If ``other`` is not a ``FormsSubSpaceFunctor`` then ``self``
is merged as if it was its ambient space functor.
EXAMPLES::
sage: from space import ModularForms
sage: ambient_space = ModularForms(group=4, k=12, ep=1)
sage: ambient_space_functor1 = FormsSpaceFunctor("holo", group=4, k=12, ep=1)
sage: ambient_space_functor2 = FormsSpaceFunctor("cusp", group=4, k=12, ep=1)
sage: ss_functor1 = FormsSubSpaceFunctor(ambient_space_functor1, [ambient_space.gen(0)])
sage: ss_functor2 = FormsSubSpaceFunctor(ambient_space_functor2, [ambient_space.gen(0)])
sage: ss_functor3 = FormsSubSpaceFunctor(ambient_space_functor2, [2*ambient_space.gen(0)])
sage: merged_ambient = ambient_space_functor1.merge(ambient_space_functor2)
sage: merged_ambient
ModularFormsFunctor(n=4, k=12, ep=1)
sage: functor4 = FormsSpaceFunctor(["quasi", "cusp"], group=4, k=10, ep=-1)
sage: ss_functor1.merge(ss_functor1) is ss_functor1
True
sage: ss_functor1.merge(ss_functor2)
FormsSubSpaceFunctor with 1 basis element for the ModularFormsFunctor(n=4, k=12, ep=1)
sage: ss_functor1.merge(ss_functor2) == FormsSubSpaceFunctor(merged_ambient, [ambient_space.gen(0)])
True
sage: ss_functor1.merge(ss_functor3) == merged_ambient
True
sage: ss_functor1.merge(ambient_space_functor2) == merged_ambient
True
sage: ss_functor1.merge(functor4)
QuasiModularFormsRingFunctor(n=4, red_hom=True)
"""
if (self == other):
return self
elif isinstance(other, FormsSubSpaceFunctor):
merged_ambient_space_functor = self._ambient_space_functor.merge(other._ambient_space_functor)
if isinstance(merged_ambient_space_functor, FormsSpaceFunctor):
if (self._basis == other._basis):
basis = self._basis
return FormsSubSpaceFunctor(merged_ambient_space_functor, basis)
else:
#TODO: Or combine the basis to a new basis (which one?)
#basis = self._basis + other._basis
return merged_ambient_space_functor
# This includes the case when None is returned
else:
return merged_ambient_space_functor
else:
return self._ambient_space_functor.merge(other)
def __eq__(self, other):
r"""
Compare ``self`` and ``other``.
EXAMPLES::
sage: from space import ModularForms
sage: ambient_space = ModularForms(group=4, k=12, ep=1)
sage: ambient_space_functor1 = FormsSpaceFunctor("holo", group=4, k=12, ep=1)
sage: ss_functor1 = FormsSubSpaceFunctor(ambient_space_functor1, [ambient_space.gen(0)])
sage: ss_functor2 = FormsSubSpaceFunctor(ambient_space_functor1, [ambient_space.gen(1)])
sage: ss_functor1 == ss_functor2
False
"""
if ( type(self) == type(other)\
and self._ambient_space_functor == other._ambient_space_functor\
and self._basis == other._basis ):
return True
else:
return False
class FormsSpaceFunctor(ConstructionFunctor):
r"""
Construction functor for forms spaces.
Note: When the base ring is not a ``BaseFacade``
the functor is first merged with the ConstantFormsSpaceFunctor.
This case occurs in the pushout constructions
(when trying to find a common parent
between a forms space and a ring which
is not a ``BaseFacade``).
"""
from analytic_type import AnalyticType
AT = AnalyticType()
rank = 10
def __init__(self, analytic_type, group, k, ep):
r"""
Construction functor for the forms space
(or forms ring, see above) with
the given ``analytic_type``, ``group``,
weight ``k`` and multiplier ``ep``.
See :meth:`__call__` for a description of the functor.
INPUT:
- ``analytic_type`` - An element of ``AnalyticType()``.
- ``group`` - A Hecke Triangle group.
- ``k`` - A rational number, the weight of the space.
- ``ep`` - ``1`` or ``-1``, the multiplier of the space.
OUTPUT:
The construction functor for the corresponding forms space/ring.
EXAMPLES::
sage: FormsSpaceFunctor(["holo", "weak"], group=4, k=0, ep=-1)
WeakModularFormsFunctor(n=4, k=0, ep=-1)
"""
Functor.__init__(self, Rings(), CommutativeAdditiveGroups())
from space import canonical_parameters
(self._group, R, self._k, self._ep) = canonical_parameters(group, ZZ, k, ep)
self._analytic_type = self.AT(analytic_type)
def __call__(self, R):
r"""
If ``R`` is a ``BaseFacade(S)`` then return the corresponding
forms space with base ring ``get_base_ring(S)``.
If not then we first merge the functor with the ConstantFormsSpaceFunctor.
EXAMPLES::
sage: F = FormsSpaceFunctor(["holo", "weak"], group=4, k=0, ep=-1)
sage: F(BaseFacade(ZZ))
WeakModularForms(n=4, k=0, ep=-1) over Integer Ring
sage: F(BaseFacade(CC))
WeakModularForms(n=4, k=0, ep=-1) over Complex Field with 53 bits of precision
sage: F(CC)
WeakModularFormsRing(n=4) over Complex Field with 53 bits of precision
sage: F(CC).has_reduce_hom()
True
"""
if (isinstance(R, BaseFacade)):
R = get_base_ring(R._ring)
return FormsSpace(self._analytic_type, self._group, R, self._k, self._ep)
else:
R = BaseFacade(get_base_ring(R))
merged_functor = self.merge(ConstantFormsSpaceFunctor(self._group))
return merged_functor(R)
def __str__(self):
r"""
Return the string representation of ``self``.
EXAMPLES::
sage: F = FormsSpaceFunctor(["cusp", "quasi"], group=5, k=10/3, ep=-1)
sage: str(F)
'QuasiCuspFormsFunctor(n=5, k=10/3, ep=-1)'
sage: F
QuasiCuspFormsFunctor(n=5, k=10/3, ep=-1)
"""
return "{}FormsFunctor(n={}, k={}, ep={})".format(self._analytic_type.analytic_space_name(), self._group.n(), self._k, self._ep)
def merge(self, other):
r"""
Return the merged functor of ``self`` and ``other``.
It is only possible to merge instances of ``FormsSpaceFunctor``
and ``FormsRingFunctor``. Also only if they share the same group.
An ``FormsSubSpaceFunctors`` is replaced by its ambient space functor.
The analytic type of the merged functor is the extension
of the two analytic types of the functors.
The ``red_hom`` parameter of the merged functor
is the logical ``and`` of the two corresponding ``red_hom``
parameters (where a forms space is assumed to have it
set to ``True``).
Two ``FormsSpaceFunctor`` with different (k,ep) are merged to a
corresponding ``FormsRingFunctor``. Otherwise the corresponding
(extended) ``FormsSpaceFunctor`` is returned.
A ``FormsSpaceFunctor`` and ``FormsRingFunctor``
are merged to a corresponding (extended) ``FormsRingFunctor``.
Two ``FormsRingFunctors`` are merged to the corresponding
(extended) ``FormsRingFunctor``.
EXAMPLES::
sage: functor1 = FormsSpaceFunctor("holo", group=5, k=0, ep=1)
sage: functor2 = FormsSpaceFunctor(["quasi", "cusp"], group=5, k=10/3, ep=-1)
sage: functor3 = FormsSpaceFunctor(["quasi", "mero"], group=5, k=0, ep=1)
sage: functor4 = FormsRingFunctor("cusp", group=5, red_hom=False)
sage: functor5 = FormsSpaceFunctor("holo", group=4, k=0, ep=1)
sage: functor1.merge(functor1) is functor1
True
sage: functor1.merge(functor5) is None
True
sage: functor1.merge(functor2)
QuasiModularFormsRingFunctor(n=5, red_hom=True)
sage: functor1.merge(functor3)
QuasiMeromorphicModularFormsFunctor(n=5, k=0, ep=1)
sage: functor1.merge(functor4)
ModularFormsRingFunctor(n=5)
"""
if (self == other):
return self
if isinstance(other, FormsSubSpaceFunctor):
other = other._ambient_space_functor
if isinstance(other, FormsSpaceFunctor):
if not (self._group == other._group):
return None
analytic_type = self._analytic_type + other._analytic_type
if (self._k == other._k) and (self._ep == other._ep):
return FormsSpaceFunctor(analytic_type, self._group, self._k, self._ep)
else:
return FormsRingFunctor(analytic_type, self._group, True)
elif isinstance(other, FormsRingFunctor):
if not (self._group == other._group):
return None
red_hom = other._red_hom
analytic_type = self._analytic_type + other._analytic_type
return FormsRingFunctor(analytic_type, self._group, red_hom)
def __eq__(self, other):
r"""
Compare ``self`` and ``other``.
EXAMPLES::
sage: functor1 = FormsSpaceFunctor("holo", group=4, k=12, ep=1)
sage: functor2 = FormsSpaceFunctor("holo", group=4, k=12, ep=-1)
sage: functor1 == functor2
False
"""
if ( type(self) == type(other)\
and self._group == other._group\
and self._analytic_type == other._analytic_type\
and self._k == other._k\
and self._ep == other._ep ):
return True
else:
return False
class FormsRingFunctor(ConstructionFunctor):
r"""
Construction functor for forms rings.
Note: When the base ring is not a ``BaseFacade``
the functor is first merged with the ConstantFormsSpaceFunctor.
This case occurs in the pushout constructions.
(when trying to find a common parent
between a forms ring and a ring which
is not a ``BaseFacade``).
"""
from analytic_type import AnalyticType
AT = AnalyticType()
rank = 10
def __init__(self, analytic_type, group, red_hom):
r"""
Construction functor for the forms ring
with the given ``analytic_type``, ``group``
and variable ``red_hom``
See :meth:`__call__` for a description of the functor.
INPUT:
- ``analytic_type`` - An element of ``AnalyticType()``.
- ``group`` - A Hecke Triangle group.
- ``red_hom`` - A boolean variable for the parameter ``red_hom``
(also see ``FormsRing_abstract``).
OUTPUT:
The construction functor for the corresponding forms ring.
EXAMPLES::
sage: FormsRingFunctor(["quasi", "mero"], group=6, red_hom=False)
QuasiMeromorphicModularFormsRingFunctor(n=6)
sage: FormsRingFunctor(["quasi", "mero"], group=6, red_hom=True)
QuasiMeromorphicModularFormsRingFunctor(n=6, red_hom=True)
"""
Functor.__init__(self, Rings(), Rings())
from graded_ring import canonical_parameters
(self._group, R, red_hom) = canonical_parameters(group, ZZ, red_hom)
self._red_hom = bool(red_hom)
self._analytic_type = self.AT(analytic_type)
def __call__(self, R):
r"""
If ``R`` is a ``BaseFacade(S)`` then return the corresponding
forms ring with base ring ``get_base_ring(S)``.
If not then we first merge the functor with the ConstantFormsSpaceFunctor.
EXAMPLES::
sage: F = FormsRingFunctor(["quasi", "mero"], group=6, red_hom=False)
sage: F(BaseFacade(ZZ))
QuasiMeromorphicModularFormsRing(n=6) over Integer Ring
sage: F(BaseFacade(CC))
QuasiMeromorphicModularFormsRing(n=6) over Complex Field with 53 bits of precision
sage: F(CC)
QuasiMeromorphicModularFormsRing(n=6) over Complex Field with 53 bits of precision
sage: F(CC).has_reduce_hom()
False
"""
if (isinstance(R, BaseFacade)):
R = get_base_ring(R._ring)
return FormsRing(self._analytic_type, self._group, R, self._red_hom)
else:
R = BaseFacade(get_base_ring(R))
merged_functor = self.merge(ConstantFormsSpaceFunctor(self._group))
return merged_functor(R)
def __str__(self):
r"""
Return the string representation of ``self``.
EXAMPLES::
sage: str(FormsRingFunctor(["quasi", "mero"], group=6, red_hom=True))
'QuasiMeromorphicModularFormsRingFunctor(n=6, red_hom=True)'
sage: FormsRingFunctor(["quasi", "mero"], group=6, red_hom=False)
QuasiMeromorphicModularFormsRingFunctor(n=6)
"""
if (self._red_hom):
red_arg = ", red_hom=True"
else:
red_arg = ""
return "{}FormsRingFunctor(n={}{})".format(self._analytic_type.analytic_space_name(), self._group.n(), red_arg)
def merge(self, other):
r"""
Return the merged functor of ``self`` and ``other``.
It is only possible to merge instances of ``FormsSpaceFunctor``
and ``FormsRingFunctor``. Also only if they share the same group.
An ``FormsSubSpaceFunctors`` is replaced by its ambient space functor.
The analytic type of the merged functor is the extension
of the two analytic types of the functors.
The ``red_hom`` parameter of the merged functor
is the logical ``and`` of the two corresponding ``red_hom``
parameters (where a forms space is assumed to have it
set to ``True``).
Two ``FormsSpaceFunctor`` with different (k,ep) are merged to a
corresponding ``FormsRingFunctor``. Otherwise the corresponding
(extended) ``FormsSpaceFunctor`` is returned.
A ``FormsSpaceFunctor`` and ``FormsRingFunctor``
are merged to a corresponding (extended) ``FormsRingFunctor``.
Two ``FormsRingFunctors`` are merged to the corresponding
(extended) ``FormsRingFunctor``.
EXAMPLES::
sage: functor1 = FormsRingFunctor("mero", group=6, red_hom=True)
sage: functor2 = FormsRingFunctor(["quasi", "cusp"], group=6, red_hom=False)
sage: functor3 = FormsSpaceFunctor("weak", group=6, k=0, ep=1)
sage: functor4 = FormsRingFunctor("mero", group=5, red_hom=True)
sage: functor1.merge(functor1) is functor1
True
sage: functor1.merge(functor4) is None
True
sage: functor1.merge(functor2)
QuasiMeromorphicModularFormsRingFunctor(n=6)
sage: functor1.merge(functor3)
MeromorphicModularFormsRingFunctor(n=6, red_hom=True)
"""
if (self == other):
return self
if isinstance(other, FormsSubSpaceFunctor):
other = other._ambient_space_functor
if isinstance(other, FormsSpaceFunctor):
if not (self._group == other._group):
return None
red_hom = self._red_hom
analytic_type = self._analytic_type + other._analytic_type
return FormsRingFunctor(analytic_type, self._group, red_hom)
elif isinstance(other, FormsRingFunctor):
if not (self._group == other._group):
return None
red_hom = self._red_hom & other._red_hom
analytic_type = self._analytic_type + other._analytic_type
return FormsRingFunctor(analytic_type, self._group, red_hom)
def __eq__(self, other):
r"""
Compare ``self`` and ``other``.
EXAMPLES::
sage: functor1 = FormsRingFunctor("holo", group=4, red_hom=True)
sage: functor2 = FormsRingFunctor("holo", group=4, red_hom=False)
sage: functor1 == functor2
False
"""
if ( type(self) == type(other)\
and self._group == other._group\
and self._analytic_type == other._analytic_type\
and self._red_hom == other._red_hom ):
return True
else:
return False
from sage.structure.unique_representation import UniqueRepresentation
class BaseFacade(Parent, UniqueRepresentation):
r"""
BaseFacade of a ring.
This class is used to distinguish the construction of
constant elements (modular forms of weight 0) over the given ring
and the construction of ``FormsRing`` or ``FormsSpace``
based on the BaseFacade of the given ring.
If that distinction was not made then ring elements
couldn't be considered as constant modular forms
in e.g. binary operations. Instead the coercion model would
assume that the ring element lies in the common parent
of the ring element and e.g. a ``FormsSpace`` which
would give the ``FormsSpace`` over the ring. However
this is not correct, the ``FormsSpace`` might
(and probably will) not even contain the (constant)
ring element. Hence we use the ``BaseFacade`` to
distinguish the two cases.
Since the ``BaseFacade`` of a ring embedds into that ring,
a common base (resp. a coercion) between the two (or even a
more general ring) can be found, namely the ring
(not the ``BaseFacade`` of it).
"""
def __init__(self, ring):
r"""
BaseFacade of ``ring`` (see above).
EXAMPLES::
sage: BaseFacade(ZZ)
BaseFacade(Integer Ring)
sage: ZZ.has_coerce_map_from(BaseFacade(ZZ))
True
sage: CC.has_coerce_map_from(BaseFacade(ZZ))
True
"""
Parent.__init__(self, facade=ring, category=Rings())
self._ring = get_base_ring(ring)
# The BaseFacade(R) coerces/embeds into R, used in pushout
self.register_embedding(self.Hom(self._ring,Sets())(lambda x: x))
def __repr__(self):
r"""
Return the string representation of ``self``.
EXAMPLES::
sage: BaseFacade(ZZ)
BaseFacade(Integer Ring)
"""
return "BaseFacade({})".format(self._ring)