CoCalc Public Fileswww / tables / magma_src / ModFrm / arithmetic.mOpen with one click!
Author: William A. Stein
1
freeze;
2
3
/****-*-magma-* EXPORT DATE: 2004-03-08 ************************************
4
5
MODFORM: Modular Forms in MAGMA
6
7
William A. Stein
8
9
FILE: arithmetic.m
10
11
$Header: /home/was/magma/packages/modform/code/RCS/arithmetic.m,v 1.6 2002/04/15 07:26:44 was Exp $
12
13
$Log: arithmetic.m,v $
14
Revision 1.6 2002/04/15 07:26:44 was
15
...
16
17
Revision 1.5 2002/04/15 07:25:00 was
18
Made * more flexible for f*T.
19
20
Revision 1.4 2001/06/30 03:12:29 was
21
Changed '+' slightly.
22
23
Revision 1.3 2001/05/30 18:53:33 was
24
Done.
25
26
Revision 1.2 2001/05/16 04:11:36 was
27
*** empty log message ***
28
29
Revision 1.1 2001/05/16 03:50:39 was
30
Initial revision
31
32
33
***************************************************************************/
34
35
import "predicates.m" : Element;
36
37
function CreateModularFormFromOperation(op,g,h)
38
assert op in {"*", "-", "+", "scalar"};
39
if Type(g) eq ModFrmElt then
40
assert BaseRing(Parent(g)) eq BaseRing(Parent(h));
41
end if;
42
assert Type(h) eq ModFrmElt;
43
f := HackobjCreateRaw(ModFrmElt);
44
f`created_from := <op,g,h>;
45
if op eq "scalar" then
46
f`parent := Parent(h);
47
return f;
48
end if;
49
Mg := Parent(g);
50
Mh := Parent(h);
51
N := LCM(Level(Mg), Level(Mh));
52
if IsRingOfAllModularForms(Mg) then
53
M := Mg;
54
elif IsRingOfAllModularForms(Mh) then
55
M := Mh;
56
else
57
case op:
58
when "*":
59
k := Weight(g) + Weight(h);
60
if IsGamma0(Mg) and IsGamma0(Mh) then
61
M := ModularForms(N,k);
62
else
63
M := ModularForms(Gamma1(N),k);
64
end if;
65
when "+":
66
if Weight(g) eq Weight(h) then
67
if IsGamma0(Mg) and IsGamma0(Mh) then
68
M := ModularForms(N,Weight(g));
69
else
70
M := ModularForms(Gamma1(N),Weight(g));
71
end if;
72
else
73
M := ModularForms();
74
end if;
75
else:
76
error "CreateModularFormFromOperation -- Invalid operation.";
77
end case;
78
end if;
79
f`parent := BaseExtend(M,BaseRing(Mg));
80
return f;
81
end function;
82
83
84
intrinsic '+'(f::ModFrmElt,g::ModFrmElt) -> ModFrmElt
85
{}
86
require BaseRing(Parent(f)) eq BaseRing(Parent(g)) :
87
"Arguments 1 and 2 have incompatible coefficient rings.";
88
89
if AmbientSpace(Parent(f)) ne AmbientSpace(Parent(g)) then
90
return CreateModularFormFromOperation("+",f,g);
91
end if;
92
93
M := Parent(f);
94
if M eq Parent(g) then
95
return M!(Element(f)+Element(g));
96
else
97
A := AmbientSpace(M);
98
return A!f + A!g;
99
end if;
100
101
end intrinsic;
102
103
intrinsic '-'(f::ModFrmElt,g::ModFrmElt) -> ModFrmElt
104
{}
105
require BaseRing(Parent(f)) eq BaseRing(Parent(g)) :
106
"Arguments 1 and 2 have incompatible coefficient rings.";
107
108
return f+ (-1)*g;
109
end intrinsic;
110
111
intrinsic '-'(f::ModFrmElt, g::RngSerPowElt) -> RngSerPowElt
112
{}
113
t, _ := IsCoercible(Parent(g),PowerSeries(f,1));
114
require t : "The q-expansion of argument 1 must be coercible into the parent of argument 2.";
115
return f+(-g);
116
end intrinsic;
117
118
intrinsic '-'(g::RngSerPowElt, f::ModFrmElt) -> RngSerPowElt
119
{}
120
t, _ := IsCoercible(Parent(g),PowerSeries(f,1));
121
require t : "The q-expansion of argument 1 must be coercible into the parent of argument 2.";
122
return g+(-f);
123
end intrinsic;
124
125
intrinsic '-'(f::ModFrmElt) -> ModFrmElt
126
{}
127
return (-1)*f;
128
end intrinsic;
129
130
intrinsic '+'(g::RngSerPowElt, f::ModFrmElt) -> RngSerPowElt
131
{}
132
t, _ := IsCoercible(Parent(g),PowerSeries(f,1));
133
require t : "The q-expansion of argument 1 must be coercible into the parent of argument 2.";
134
return f+g;
135
end intrinsic;
136
137
intrinsic '+'(f::ModFrmElt, g::RngSerPowElt) -> RngSerPowElt
138
{}
139
t, _ := IsCoercible(Parent(g),PowerSeries(f,1));
140
require t : "The q-expansion of argument 1 must be coercible into the parent of argument 2.";
141
if RelativePrecision(g) ne -1 then
142
_, ff := IsCoercible(Parent(g),PowerSeries(f,AbsolutePrecision(g)));
143
return ff + g;
144
else
145
_, ff := IsCoercible(Parent(g),PowerSeries(f));
146
return ff + g;
147
end if;
148
end intrinsic;
149
150
intrinsic '*'(f::ModFrmElt, T::AlgMatElt) -> ModFrmElt
151
{}
152
require Degree(Parent(T)) eq Dimension(Parent(Element(f))) :
153
"The degrees of arguments 1 and 2 are incompatible.";
154
Rf := BaseRing(Parent(f));
155
RT := BaseRing(Parent(T));
156
if Type(Rf) ne Type(RT) then
157
if Type(Rf) eq RngInt then
158
f := BaseExtend(Parent(f),RT)!Eltseq(f);
159
end if;
160
if Type(RT) eq RngInt then
161
T := BaseExtend(Parent(T),Rf)!Eltseq(T);
162
end if;
163
end if;
164
return Parent(f)!(Element(f)*T);
165
end intrinsic;
166
167
168
intrinsic '*'(f::ModFrmElt, x::RngElt) -> ModFrmElt
169
{}
170
require x in BaseRing(Parent(f)) :
171
"Argument 1 must be in the base ring of the parent of argument 2.";
172
return x*f;
173
end intrinsic;
174
175
intrinsic '*'(x::RngElt, f::ModFrmElt) -> ModFrmElt
176
{}
177
M := Parent(f);
178
require x in BaseRing(M) : "Argument 1 must be in the base ring of the parent of argument 2.";
179
180
/* if not (x in BaseRing(M)) then
181
M2 := BaseExtend(M, Parent(x));
182
bang in the element ...
183
*/
184
return M!(x*Element(f));
185
end intrinsic;
186
187
intrinsic '/'(f::ModFrmElt, x::RngElt) -> ModFrmElt
188
{}
189
require x ne 0 : "Division by zero.";
190
require 1/x in BaseRing(Parent(f)) : "Argument 2 is not in the base ring of argument 1.";
191
return (1/x)*f;
192
end intrinsic;
193
194
intrinsic '^'(f::ModFrmElt, n::RngElt) -> ModFrmElt
195
{}
196
requirege n, 1;
197
g := f;
198
for i in [2..n] do // very bad.
199
g := g * f;
200
end for;
201
return g;
202
end intrinsic;
203
204
intrinsic '*'(f::ModFrmElt,g::ModFrmElt) -> ModFrmElt
205
{}
206
require BaseRing(Parent(f)) eq BaseRing(Parent(g)) :
207
"Arguments 1 and 2 have incompatible coefficient rings.";
208
return CreateModularFormFromOperation("*",f,g);
209
end intrinsic;
210
211
212
213