Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563580 views
1
#ifndef ARITH_TYPEDEF
2
#define ARITH_TYPEDEF 1
3
4
/*============================================================*\
5
|| ||
6
|| Enthaelt die noetigen Typendeklaraionen fuer Langzahl- ||
7
|| arithmetik, Arithmetik in Fp, Fq, abelschen Zahlkoerpern ||
8
|| und p_adische Koerper. ||
9
|| ||
10
\*============================================================*/
11
12
typedef long polynom_Fp;
13
typedef long padic;
14
typedef long Fq;
15
typedef unsigned long lang;
16
typedef int boolean;
17
typedef struct { unsigned long low, hi; } prod;
18
typedef struct { lang st, nd, rd; } hipos;
19
typedef struct { int z; int n; } bruch;
20
typedef struct { lang z; lang n; } rational;
21
typedef struct { lang f1, f2, g1, g2; } pair;
22
typedef struct { int f1, f2, g1, g2; } spair;
23
24
typedef struct { int len; char *string; } padicchar;
25
typedef struct { int len; char *string; } langchar;
26
typedef struct { int len; char *string; } Fqchar;
27
28
/*============================================================*\
29
|| ||
30
|| Definition und Deklaration der Additions- und Multiplika- ||
31
|| tionstabelle der Fp-Arithmetik. ||
32
|| (schneller, aber nicht kompatibel zur Fq-Arithmetik) ||
33
|| ||
34
\*============================================================*/
35
36
#define SHORTPRIME_LIMIT 300 /* Grenze fuer Rechnen mit Tabelle */
37
#define MIDDLEPRIME_LIMIT 8192 /* Grenze fuer Cech-Logarithmen */
38
#define LONGPRIME_LIMIT 1000000000 /* Obergrenze fuer Arithmetik */
39
40
typedef struct {
41
int s_number, *s_primes; /* Anzahl kleiner Pz; Liste der ... */
42
int l_number, *l_primes; /* Anzahl grosser Pz; Liste der ... */
43
int *s_kind, *l_kind; /* Art der Pz: -1 : Primzahl,
44
1 : Primzahlpotenz, 0 sonst */
45
int ***ADD, ***MUL; /* Rechen-Tabellen fuer kleine Pz. */
46
int **LOG, **EXP; /* p-Logarithmen fuer grosse Pz. */
47
} table;
48
49
table *prime_table;
50
51
int **P_ADD, **P_MUL; /* aktuelle Rechen_Tabelle */
52
int *P_LOG, *P_EXP; /* aktuelle p-Logarithmen */
53
int (*S)(int, int), (*P)(int, int); /* aktuelle Funktion */
54
int (*min_mod_factor)(int, int); /* Verallgemeinerung von a/b */
55
int act_prime; /* aktuelle Primzahl */
56
int act_prime_code; /* Aktuelle Kodierung (s.o.) */
57
58
/*============================================================*\
59
|| ||
60
|| Definition der Typen fuer die p_adische Arithmetik. ||
61
|| ||
62
\*============================================================*/
63
64
typedef struct {
65
boolean init_done;
66
char *name;
67
long list_num; /* die eigene Koerperkennung */
68
long padic_p, p_halbe;
69
long padic_e, padic_f;
70
long padic_ef; /* erspart die Rechnung von e*f */
71
long padic_ef_plus1; /* e*f+1 */
72
long padic_f_plus1; /* f+1 */
73
long padic_2f; /* 2*f */
74
long padic_2f_1; /* 2*f+1 */
75
long padic_2e_1; /* 2*e+1 */
76
long padic_e2f_1; /* e*(2*f-1) */
77
long padic_2e_12f_1; /* (2*e-1)*(2*f-1) */
78
long padic_cd; /* cd = Rechentiefe */
79
long padic_cd_plus1; /* cd+1 */
80
polynom_Fp f_poly; /* unverzweigtes Polynom */
81
polynom_Fp e_poly; /* Eisensteinpolynom */
82
boolean f_poly_is_Conway; /* Polynom automatisch bestimmt */
83
long **f_mat; /* Reduktionsmatrix der unv. Erweiterung */
84
long **e_mat; /* Reduktionsmatrix der verzw. Erweiterung */
85
long **mult_mat; /* e_mat (x) f_mat , d. h. Kroneckerprodukt */
86
padic *padicmulvec;
87
long ***diag_f_mat; /*Blockdiagonalmatrix zum Invert. unv. Ausdr. */
88
long **inv_mat; /*Diese Matrix wird beim Invertieren gebraucht */
89
long **inv_mat_inv; /* Die invertierte inv_mat_matrix */
90
long *a_inv_vec; /* Zum Invertieren,falls padic_e>1 */
91
long *b_inv_vec; /* " */
92
long *c_inv_vec; /* " */
93
long *a_vec; /* Zum Invertieren, falls padic_f>1 */
94
long *b_vec; /* " */
95
long *c_vec; /* " */
96
long *cb0_vec; /* " */
97
long **a_mat; /* Zum Invertieren, falls f>1 und e>1 */
98
long **b_mat; /* " */
99
long **c_mat; /* " */
100
long *sum_vec; /* " */
101
padic y_inversp; /* wird zum schiften bei div gebraucht, falls e>1
102
y_inversp erhaelt den Wert y^(-1)*p */
103
padic ypsilon;
104
lang *modvec;
105
boolean GEMISCHT; /* Flag: TRUE = echt gemischte Erweiterung, d. h.
106
das Eisensteinpolynom steht in eisen_mat
107
da es verzweigte Koeffizienten hat */
108
long **eisen_mat; /* Das Eisensteinpolynom im gemischten Fall
109
Der Matrixeintrag eisen_mat[i][j] ist der
110
Koeffizient e_{i,j}*x^j*y^i des Eisensteinpolys */
111
} padic_field_TYP;
112
113
/*============================================================*\
114
|| ||
115
|| Typendefinition fuer die Arithmetik in endlichen Koerpern. ||
116
|| ||
117
\*============================================================*/
118
119
typedef struct {
120
char *name; /* Der eigene Name als Matrixkopf: F[p,f,...] */
121
long list_num; /* die eigene Koerperkennung */
122
boolean init_done_Fq;
123
long Fq_p, Fq_p_halbe;
124
long Fq_f, Fq_f_plus1;
125
long Fq_2f, Fq_2f_1;
126
long Fq_q, Fq_q_1; /* Anzahl der Elemante, -1 in Fq */
127
Fq Fqmulvec;
128
long **f_mat_Fq;
129
long ***diag_f_mat_Fq;
130
long *a_vec_Fq;
131
long **inv_mat_Fq; /*Diese Matrix muss beim Invert.invert. werden */
132
long **inv_mat_inv_Fq; /* Die invertierte inv_mat_matrix */
133
polynom_Fp f_poly_Fq;
134
boolean listtyp; /* Flag ueber Art der Multiplikation */
135
boolean f_poly_is_Conway; /* Polynom automatisch bestimmt */
136
Fq *Fq_list_etoz; /* speichert n -> a fuer Fq_pr^n=a */
137
long *Fq_list_ztoe; /* speichert lex(a) -> n fuer Fq_pr^n=a */
138
Fq Fq_pr; /* Ein primitives Element */
139
} finite_field_TYP;
140
141
142
/*============================================================*\
143
|| ||
144
|| Typedefinitions for the cyclotomic fields and the Galois- ||
145
|| groups of those (sub-)fields. ||
146
|| ||
147
|| There is no special type-definition for the elements of a ||
148
|| cyclotomic field, and the cyclotomic numbers which are ||
149
|| integers are represented as 'lang'. The others are vectors ||
150
|| of integers with the following structure: ||
151
|| ||
152
|| /------------------------------------------\ ||
153
|| | Code | field+base| kgv | c_1 | ... | c_n | ||
154
|| \------------------------------------------/ ||
155
|| ^identification ^ ||
156
|| number for coefficients for basis ||
157
|| field & base vectors. ||
158
|| ||
159
|| The code number has the following structure: ||
160
|| code-bits from long-integer code \ ||
161
|| | ||
162
|| identifier for cyclotomics | | ||
163
|| /------------------------------------------------\ ||
164
|| | length | 0 s | 1 0 | 0 0| ||
165
|| \------------------------------------------------/ ||
166
|| vector length = rank of field | ||
167
|| s = 1: coefficients are integers --/ ||
168
|| ||
169
\*============================================================*/
170
171
/*============================================================*\
172
|| Typedefinition for elements of a Galoisgroup. The elements ||
173
|| are given by the image (= exponent) of e_n, and the order ||
174
|| of the automorphism. ||
175
\*============================================================*/
176
177
typedef struct { int image, order; } Galois_element;
178
179
/*============================================================*\
180
|| Typedefinition for a abelian Galoisgroup. It contains the ||
181
|| order, the order of the cyclotomic field, and the genera- ||
182
|| tors in normal form. ||
183
\*============================================================*/
184
185
typedef struct { int group_order, field_order;
186
int gen_num;
187
Galois_element *gen; } Galois_group;
188
189
/*============================================================*\
190
|| Typedefinition for the equivalence-classes Ci in [TB]. ||
191
|| It contains the number of classes, the classes, sorted in ||
192
|| ascending order of d_i, and for each d_i the standard ||
193
|| primitive roots (indexed). ||
194
\*============================================================*/
195
196
typedef struct { int num_class;
197
int **classes; } Ci_class;
198
199
/*============================================================*\
200
|| Summand of a base element, contains exponent and ||
201
|| coefficient of the root. ||
202
\*============================================================*/
203
204
typedef struct s_summand summand;
205
struct s_summand { int exponent;
206
lang coeff;
207
summand *next;};
208
209
/*============================================================*\
210
|| Entry of a multiplication table, contains the row, col and ||
211
|| coefficient. The definition is recursiv, so the muliplica- ||
212
|| tion matrix can be stored as a recursiv list. ||
213
\*============================================================*/
214
typedef struct s_entry table_entry;
215
struct s_entry { int col;
216
lang coeff;
217
table_entry *next;} ;
218
219
/*============================================================*\
220
|| Typedefinition for a subfield-base. It contains the order ||
221
|| of a primitive root, the number and the list of base- ||
222
|| vectors, given as linear combinations of the roots, and ||
223
|| the multiplication tables for this base. The coefficients ||
224
|| in the base and in the tables can be cyclotomic numbers. ||
225
|| In the list substitute the linear combinations for those ||
226
|| roots which are not basic elements are given (if possible).||
227
|| Here the exponents refers to the basic vectors, not to the ||
228
|| root exponents. ||
229
|| The i-th entry in the multiplication table points to the ||
230
|| multiplication table for the i-th coefficient of the ||
231
|| product. ||
232
\*============================================================*/
233
234
typedef struct { int root_order, rank;
235
prod *order_primes;
236
summand *base, *substitute;
237
table_entry **mult_table; } field_BASE;
238
239
typedef struct s_field cyclo_field_TYP;
240
241
/*============================================================*\
242
|| Allgemeiner Typ fuer Koerper; dient zur globalen Verwaltung||
243
\*============================================================*/
244
245
typedef struct {
246
int Typ, list_num;
247
char *name;
248
cyclo_field_TYP *CF;
249
padic_field_TYP *PF;
250
finite_field_TYP *FF;
251
} field_TYP;
252
253
/*============================================================*\
254
|| Weitere aufbauende Definitionen: ||
255
|| Definition des matrix_TYP`s, ||
256
|| ||
257
\*============================================================*/
258
typedef struct {
259
lang **Z, **N;
260
int **SZ, **SN;
261
table_entry **ZC;
262
} array_TYP;
263
264
typedef struct {
265
boolean Typ ,
266
Integral ,
267
Symmetric,
268
Diagonal ,
269
Scalar ,
270
Sparse,
271
Permutation,
272
Monomial;
273
int Max_Entry ; /* Maximaler Eintrag in short-integer-Matrizen*/
274
} flag_TYP;
275
276
typedef struct {
277
flag_TYP flags;
278
int cols, rows, prime;
279
lang kgv;
280
char *name; /* Name des Koerpers */
281
int field_num; /* Nummer des Koerpers in allgemeiner Liste */
282
array_TYP array;
283
} matrix_TYP;
284
285
/*============================================================*\
286
|| Typedefinition for a cyclotomic field. It contains vectors ||
287
|| for bases, subfields, supfields and those created field ||
288
|| which are not sub/sup-field. Furthermore it contains the ||
289
|| Galoisgroup, and, if the field is a subfield of a cyclo- ||
290
|| tomic field, it contains a pointer to the cyclotomic field ||
291
|| (conductor), and the group which fixes this field. ||
292
|| Often the conductor field is not need arithmetically, so ||
293
|| there is also a pointer to the conductor_base. ||
294
|| ||
295
|| The matrix (m)_{ij} contains the base-change coefficient ||
296
|| from the i-th base to the j-th base. ||
297
|| ||
298
|| There is also space for various flags. ||
299
|| ||
300
\*============================================================*/
301
302
struct s_field { int list_num, base_num;
303
int supfield_num, subfield_num, parfield_num;
304
int root_order, rank, flags;
305
char *name;
306
field_BASE **bases, *con_base;
307
field_BASE **rel_bases;
308
matrix_TYP **base_change;
309
matrix_TYP **norms;
310
Ci_class *base_classes;
311
field_TYP **supfields, **subfields, **parfields;
312
field_TYP *conductor;
313
Galois_group *Act_group, *Fix_group;
314
};
315
316
/*============================================================*\
317
|| ||
318
|| Typendefinition fuer Polynome. ||
319
|| fac_num enthaelt die Anzahl der gefundenen Faktoren. ||
320
|| Diese werden in factors abgelegt. ||
321
|| *.hi enthealt jeweils den Exponenten, *.low den entspre- ||
322
|| chenden Koeffizienten. ||
323
|| Die Exponenten sind absteigend geordnet. ||
324
|| 'factorize' ist 'TRUE', falls alle Faktoren irreduzibel ||
325
|| sind, also das Polynom vollstaendig faktorisiert ist. ||
326
|| ||
327
\*============================================================*/
328
typedef struct {
329
int fac_num, grad;
330
boolean factorize;
331
prod **factors;
332
} polynom;
333
334
typedef struct {
335
long deg; /* Grad des Polynoms */
336
padic *kof; /* Die Koeffizenten des Polynoms, wobei
337
kof[0] den x^0-Term usw. beinhaltet */
338
} padicpoly;
339
340
/* Definition fuer das Arbeiten mit Worten */
341
typedef struct s_wordchain word_chain;
342
343
struct s_wordchain { word_chain *prev, *next;
344
int name, coeff;};
345
#endif
346
347