Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/ext/magma/latex/latex.m
8815 views
1
// Latex printing for MAGMA objects.
2
3
/***************************************************************
4
5
Copyright (C) 2006 William Stein <wstein@ucsd.edu>
6
2006 Jennifer Balakrishnan <jenb@mit.edu>
7
8
Distributed under the terms of the GNU General Public License (GPL)
9
10
***************************************************************/
11
12
/*
13
This converts MAGMA output to LaTeX. It's a work-in-progress that
14
currently handles a few basic types, matrices, polynomials,
15
power series, binary quadratic forms, elements of number fields,
16
finite fields, certain p-adic rings/fields, points, and elliptic curves.
17
*/
18
19
intrinsic Latex(x::RngIntElt) -> MonStgElt
20
{}
21
return Sprint(x);
22
end intrinsic;
23
24
intrinsic Latex(x::FldReElt) -> MonStgElt
25
{}
26
return Sprint(x);
27
end intrinsic;
28
29
intrinsic Latex(x::FldRatElt) -> MonStgElt
30
{}
31
if Denominator(x) eq 1 then
32
return Latex(Numerator(x));
33
end if;
34
return Sprintf("\\frac{%o}{%o}", Numerator(x), Denominator(x));
35
end intrinsic;
36
37
Letters:={@
38
"$.1",
39
"alpha",
40
"beta",
41
"gamma",
42
"delta",
43
"epsilon",
44
"varepsilon",
45
"zeta",
46
"eta",
47
"theta",
48
"theta",
49
"vartheta",
50
"iota",
51
"kappa",
52
"lambda",
53
"mu",
54
"nu",
55
"xi",
56
"pi",
57
"varpi",
58
"rho",
59
"varrho",
60
"sigma",
61
"varsigma",
62
"tau",
63
"upsilon",
64
"phi",
65
"varphi",
66
"chi",
67
"psi",
68
"omega",
69
"Gamma",
70
"Delta",
71
"Theta",
72
"Lambda",
73
"Xi",
74
"Pi",
75
"Sigma",
76
"Upsilon",
77
"Phi",
78
"Psi" @};
79
80
81
intrinsic Latex(x::RngPadElt) -> MonStgElt
82
{}
83
z := Integers()!x;
84
p := Prime(Parent(x));
85
l := p^(Degree(Parent(x)));
86
i := 0;
87
j :=AbsolutePrecision(x);
88
s := "";
89
if IsPrime(l) then
90
91
while z ne 0 and i eq 0 do
92
c := z mod p;
93
if c ne 0 then
94
s *:= Sprintf("%o+", c);
95
end if;
96
z := z div p;
97
i := i + 1;
98
end while;
99
100
while z ne 0 and i eq 1 do
101
c := z mod p;
102
if c ne 0 then
103
if c ne 1 then
104
s *:= Sprintf("%o\\cdot{}", c);
105
end if;
106
s *:= Sprintf("%o^{%o} + ", p, i);
107
end if;
108
z := z div p;
109
i := i + 1;
110
end while;
111
112
while z ne 0 and i lt Precision(Parent(x)) do
113
c := z mod p;
114
if c ne 0 then
115
if c ne 1 then
116
s *:= Sprintf("%o\\cdot{}", c);
117
end if;
118
s *:= Sprintf("%o^{%o} + ", p, i);
119
end if;
120
z := z div p;
121
i := i + 1;
122
end while;
123
124
else return Sprintf("\\mbox{\\rm %o}", x);
125
end if;
126
s *:= Sprintf("O(%o^{%o})", p, j);
127
return s;
128
end intrinsic;
129
130
intrinsic Latex(x::FldPadElt) -> MonStgElt
131
{}
132
v := Valuation(x);
133
z := RationalField()!x;
134
p := Prime(Parent(x));
135
l := p^(Degree(Parent(x)));
136
i := 0;
137
j :=AbsolutePrecision(x);
138
s := "";
139
if IsPrime(l) then
140
141
z:=Numerator(z);
142
while z ne 0 and i eq 0 do
143
c := z mod p;
144
if c ne 0 then
145
if c ne 1 then
146
s *:= Sprintf("%o", c);
147
end if;
148
if i+v ne 0 then
149
s*:= Sprintf("\\cdot{}%o^{%o} + ",p, i+v);
150
else if c ne 0 and c ne 1 then
151
s*:= Sprintf("+ ");
152
else if c eq 1 then
153
s*:= Sprintf("1 + ");
154
end if;
155
end if;
156
end if;
157
end if;
158
z := z div p;
159
i := i + 1;
160
end while;
161
162
while z ne 0 and i eq 1 do
163
c := z mod p;
164
if c ne 0 then
165
if c ne 1 then
166
s *:= Sprintf("%o", c);
167
end if;
168
if i+v ne 0 then
169
s *:= Sprintf("\\cdot{}%o^{%o} + ", p, i+v);
170
else if c ne 0 and c ne 1 then
171
s*:=Sprintf("+ ");
172
else if c eq 1 then
173
s*:=Sprintf("1 + ");
174
end if;
175
end if;
176
end if;
177
end if;
178
z := z div p;
179
i := i + 1;
180
end while;
181
182
while z ne 0 and i lt Precision(Parent(x)) do
183
c := z mod p;
184
if c ne 0 then
185
if c ne 1 then
186
s *:= Sprintf("%o", c);
187
end if;
188
if i+v ne 0 then
189
s *:= Sprintf("\\cdot{}%o^{%o} + ", p, i+v);
190
else if c ne 0 and c ne 1 then
191
s*:= Sprintf("+ ");
192
else if c eq 1 then
193
s*:= Sprintf("1 + ");
194
end if;
195
end if;
196
end if;
197
end if;
198
z := z div p;
199
i := i + 1;
200
end while;
201
else return Sprintf("\\text{%o}",x);
202
203
end if;
204
s *:= Sprintf("O(%o^{%o})", p, j);
205
return s;
206
end intrinsic;
207
208
209
210
211
function S(x)
212
if x gt 0 then
213
return "+";
214
end if;
215
if x lt 0 then
216
return "-";
217
end if;
218
if x eq 0 then
219
return "";
220
end if;
221
end function;
222
223
function Abs(x)
224
return Latex(AbsoluteValue(x));
225
end function;
226
227
intrinsic Latex(f::RngUPolElt) -> MonStgElt
228
{}
229
if Sprintf("%o",Parent(f).1) in Letters then
230
x:=Sprintf("\\%o",Parent(f).1);
231
else x:=Sprintf("%o",Parent(f).1);
232
end if;
233
v := Eltseq(f);
234
if v[1] ne 0 then
235
s :=Abs(v[1]);
236
else s:= "";
237
end if;
238
239
if s eq "" then
240
241
if AbsoluteValue(v[2]) eq 1 then
242
s:= Sprintf("%o",x) * s;
243
else if v[2] eq 0 then
244
s := S(v[1])*s;
245
else if v[2] ne 0 then
246
s := Abs(v[2]) * Sprintf("%o",x) *S(v[1])* s;
247
end if;
248
end if;
249
end if;
250
251
252
else if AbsoluteValue(v[2]) eq 1 then
253
s:= Sprintf("%o",x) * S(v[1])* s;
254
else if v[2] eq 0 then
255
s := S(v[1])*s;
256
else if v[2] ne 0 then
257
s := Abs(v[2]) * Sprintf("%o",x) *S(v[1])* s;
258
end if;
259
end if;
260
end if;
261
262
end if;
263
264
for i in [3..#v-1] do
265
if s eq "" then
266
267
if AbsoluteValue(v[i]) eq 1 then
268
s:= Sprintf("%o",x)* Sprintf("^{%o}", i-1) * S(v[i-1]) * s;
269
else
270
271
if v[i] eq 0 then
272
s := S(v[i-1])*s;
273
274
else
275
276
if v[i] ne 0 then
277
s := Abs(v[i]) * Sprintf("%o",x) * Sprintf("^{%o}", i-1) * S(v[i-1]) * s;
278
end if;
279
end if;
280
end if;
281
282
else
283
if AbsoluteValue(v[i]) eq 1 then
284
s:= Sprintf("%o",x) * Sprintf("^{%o}", i-1) * S(v[i-1]) * s;
285
else
286
287
if v[i] eq 0 then
288
s := S(v[i-1])*s;
289
290
else
291
292
if v[i] ne 0 then
293
s := Abs(v[i]) * Sprintf("%o",x)*Sprintf("^{%o}", i-1) *S(v[i-1])* s;
294
end if;
295
end if;
296
end if;
297
end if;
298
299
end for;
300
301
if #v eq 2 then
302
if S(v[2]) eq "-" then
303
s := S(v[2])*s;
304
end if;
305
end if;
306
307
if #v gt 2 then
308
if AbsoluteValue(v[#v]) eq 1 then
309
if S(v[#v]) eq "-" then
310
s:= Sprintf("-%o",x)* Sprintf("^{%o}", #v-1)*S(v[#v-1])*s;
311
else s:=Sprintf("%o",x)* Sprintf("^{%o}", #v-1)*S(v[#v-1])*s;
312
end if;
313
else
314
315
if v[#v] ne 0 then
316
if S(v[#v]) eq "-" then
317
s := S(v[#v])*Abs(v[#v])*Sprintf("x")
318
*Sprintf("^{%o}", #v-1) *S(v[#v-1])* s;
319
else s := Abs(v[#v])*Sprintf("%o",x)*Sprintf("^{%o}", #v-1) *S(v[#v-1])* s;
320
end if;
321
end if;
322
end if;
323
end if;
324
325
return s;
326
end intrinsic;
327
328
329
intrinsic Latex(f::RngSerElt) -> MonStgElt
330
{}
331
s:="";
332
n:=AbsolutePrecision(f);
333
d:=Degree(LeadingTerm(f));
334
v:=ElementToSequence(f);
335
m:=#v;
336
if Sprintf("%o",Parent(f).1) in Letters then
337
zn:=Sprintf("\\%o",Parent(f).1);
338
else zn:=Sprintf("%o",Parent(f).1);
339
end if;
340
341
if d eq 0 then
342
if v[1] ne 0 then
343
s:=s*Latex(v[1]);
344
end if;
345
346
if v[2] ne 0 then
347
if s eq "" then
348
if AbsoluteValue(v[2]) eq 1 then
349
if S(v[2]) eq "-" then
350
s:= s*S(v[2])*Sprintf("%o",zn);
351
else s:= s*Sprintf("%o",zn);
352
end if;
353
else if S(v[2]) eq "-" then
354
s:= s*S(v[2])*Abs(v[2])*Sprintf("%o",zn);
355
else s:= s*Abs(v[2])*Sprintf("%o",zn);
356
end if;
357
end if;
358
else if AbsoluteValue(v[2]) eq 1 then
359
s:= s*S(v[2])*Sprintf("%o",zn);
360
else s:= s*S(v[2])*Abs(v[2])*Sprintf("%o",zn);
361
end if;
362
end if;
363
end if;
364
365
for i in [3..m] do
366
if v[i] ne 0 then
367
if s eq "" then
368
if AbsoluteValue(v[i]) eq 1 then
369
if S(v[i]) eq "-" then
370
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i-1);
371
else s:= s*Sprintf("%o^{%o}",zn,i-1);
372
end if;
373
else if S(v[i]) eq "-" then
374
s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i-1);
375
else s:= s*Abs(v[i])*Sprintf("%o^{%o-1}",zn,i-1);
376
end if;
377
end if;
378
else if AbsoluteValue(v[i]) eq 1 then
379
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i-1);
380
else s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i-1);
381
end if;
382
end if;
383
end if;
384
end for;
385
386
else if d eq 1 then
387
388
if v[1] ne 0 then
389
if s eq "" then
390
if AbsoluteValue(v[1]) eq 1 then
391
if S(v[1]) eq "-" then
392
s:= s*S(v[1])*Sprintf("%o",zn);
393
else s:= s*Sprintf("%o",zn);
394
end if;
395
else if S(v[1]) eq "-" then
396
s:= s*S(v[1])*Abs(v[1])*Sprintf("%o",zn);
397
else s:= s*Abs(v[1])*Sprintf("%o",zn);
398
end if;
399
end if;
400
else if AbsoluteValue(v[1]) eq 1 then
401
s:= s*S(v[1])*Sprintf("%o",zn);
402
else s:= s*S(v[1])*Abs(v[1])*Sprintf("%o",zn);
403
end if;
404
end if;
405
end if;
406
407
for i in [2..m] do
408
if v[i] ne 0 then
409
if s eq "" then
410
if AbsoluteValue(v[i]) eq 1 then
411
if S(v[i]) eq "-" then
412
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i);
413
else s:= s*Sprintf("%o^{%o}",zn,i);
414
end if;
415
else if S(v[i]) eq "-" then
416
s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i);
417
else s:= s*Abs(v[i])*Sprintf("%o^{%o}",zn,i);
418
end if;
419
end if;
420
else if AbsoluteValue(v[i]) eq 1 then
421
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i);
422
else s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i);
423
end if;
424
end if;
425
end if;
426
end for;
427
else for i in [1..m] do
428
if v[i] ne 0 then
429
if s eq "" then
430
if AbsoluteValue(v[i]) eq 1 then
431
if S(v[i]) eq "-" then
432
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,d+i-1);
433
else s:= s*Sprintf("%o^{%o}",zn,d+i-1);
434
end if;
435
else if S(v[i]) eq "-" then
436
s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,d+i-1);
437
else s:= s*Abs(v[i])*Sprintf("%o^{%o}",zn,d+i-1);
438
end if;
439
end if;
440
else if AbsoluteValue(v[i]) eq 1 then
441
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,d+i-1);
442
else s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,d+i-1);
443
end if;
444
end if;
445
end if;
446
end for;
447
end if;
448
end if;
449
450
s:=s*Sprintf("+O(%o^{%o})",zn,n);
451
return s;
452
end intrinsic;
453
454
455
456
457
458
intrinsic Latex(E::CrvEll) -> MonStgElt
459
{}
460
v:=aInvariants(E);
461
462
s:="y^2";
463
464
if v[1] ne 0 then
465
if AbsoluteValue(v[1]) eq 1 then
466
s:=s*S(v[1])*Sprintf("xy");
467
else
468
s:= s*S(v[1])*Abs(v[1])*Sprintf("xy");
469
end if;
470
end if;
471
472
if v[3] ne 0 then
473
if AbsoluteValue(v[3]) eq 1 then
474
s:=s*S(v[3])*Sprintf("y");
475
else
476
s:=s*S(v[3])*Abs(v[3])*Sprintf("y");
477
end if;
478
end if;
479
480
s:=s*Sprintf("=x^3");
481
482
if v[2] ne 0 then
483
if AbsoluteValue(v[2]) eq 1 then
484
s:= s*S(v[2])*Sprintf("x^2");
485
else
486
s:=s*S(v[2])*Abs(v[2])*Sprintf("x^2");
487
end if;
488
end if;
489
490
if v[4] ne 0 then
491
if AbsoluteValue(v[4]) eq 1 then
492
s:=s*S(v[4])*Sprintf("x");
493
else
494
s:=s*S(v[4])*Abs(v[4])*Sprintf("x");
495
end if;
496
end if;
497
498
if v[5] ne 0 then
499
s:=s*S(v[5])*Abs(v[5]);
500
end if;
501
502
return s;
503
end intrinsic;
504
505
intrinsic Latex(f::FldFunRatElt) -> MonStgElt
506
{}
507
if Denominator(f) eq 1 then
508
return Latex(Numerator(f));
509
end if;
510
return Sprintf("\\frac{%o}{%o}", Latex(Numerator(f)), Latex(Denominator(f)));
511
end intrinsic;
512
513
intrinsic Latex(f::QuadBinElt) -> MonStgElt
514
{}
515
s:="";
516
if AbsoluteValue(f[1]) eq 1 then
517
if S(f[1]) eq "-" then
518
s:= s*Sprintf("-x^2");
519
else s:= s*Sprintf("x^2");
520
end if;
521
else
522
if S(f[1]) eq "-" then
523
s:= s*S(f[1])*Abs(f[1])*Sprintf("x^2");
524
else s:= s*Abs(f[1])*Sprintf("x^2");
525
end if;
526
end if;
527
528
if f[2] ne 0 then
529
if AbsoluteValue(f[2]) eq 1 then
530
s:=s*S(f[2])*Sprintf("xy");
531
else
532
s:=s*S(f[2])*Abs(f[2])*Sprintf("xy");
533
end if;
534
end if;
535
536
if AbsoluteValue(f[3]) eq 1 then
537
s:=s*S(f[3])*Sprintf("y^2");
538
else
539
s:= s*S(f[3])*Abs(f[3])*Sprintf("y^2");
540
end if;
541
return s;
542
end intrinsic;
543
544
545
intrinsic Latex(M::Mtrx) -> MonStgElt
546
{}
547
m:=NumberOfRows(M);
548
n:=NumberOfColumns(M);
549
s:=Sprintf("\\left(\\begin{array}{");
550
for i in [1..n] do
551
s := s * Sprintf("c");
552
end for;
553
s:= s * Sprintf("}");
554
for i in [1..m-1] do
555
for j in [1..n-1] do
556
s := s * Latex(M[i,j]) * Sprintf("&");
557
end for;
558
s := s * Latex(M[i,n]) * Sprintf("\\\\");
559
end for;
560
561
for j in [1..n-1] do
562
s := s * Latex(M[m,j]) * Sprintf("&");
563
end for;
564
s := s * Latex(M[m,n]) * "\\end{array}\\right)";
565
return s;
566
end intrinsic;
567
568
intrinsic Latex(P::PtEll) -> MonStgElt
569
{}
570
return Sprintf("(%o,%o)",Latex(P[1]),Latex(P[2]));
571
572
end intrinsic;
573
574
intrinsic Latex(P::Pt) -> MonStgElt
575
{}
576
n:=#Coordinates(P);
577
s:="(";
578
for i in [1..n-1] do
579
s:=s*Latex(P[i])*Sprintf(",");
580
end for;
581
s:=s*Latex(P[n])*Sprintf(")");
582
return s;
583
end intrinsic;
584
585
intrinsic Latex(a::FldQuadElt) -> MonStgElt
586
{}
587
s:="";
588
v:=ElementToSequence(a);
589
D:=Discriminant(Parent(a))/4;
590
591
if v[1] ne 0 then
592
s:=s*Latex(v[1]);
593
end if;
594
595
if v[2] ne 0 then
596
if s eq "" then
597
if AbsoluteValue(v[2]) eq 1 then
598
if S(v[2]) eq "-" then
599
s:= s*S(v[2])*Sprintf("\\sqrt{%o}",D);
600
else s:= s*Sprintf("\\sqrt{%o}",D);
601
end if;
602
else if S(v[2]) eq "-" then
603
s:= s*S(v[2])*Abs(v[2])*Sprintf("\\sqrt{%o}",D);
604
else s:= s*Abs(v[2])*Sprintf("\\sqrt{%o}",D);
605
end if;
606
end if;
607
else if AbsoluteValue(v[2]) eq 1 then
608
s:= s*S(v[2])*Sprintf("\\sqrt{%o}",D);
609
else s:= s*S(v[2])*Abs(v[2])*Sprintf("\\sqrt{%o}",D);
610
end if;
611
end if;
612
end if;
613
return s;
614
end intrinsic;
615
616
intrinsic Latex(a::FldCycElt) -> MonStgElt
617
{}
618
s:="";
619
v:=ElementToSequence(a);
620
n:=CyclotomicOrder(Parent(a));
621
zn:=Sprintf("\\zeta_{%o}",n);
622
m:=Degree(Parent(a));
623
624
if v[1] ne 0 then
625
s:=s*Latex(v[1]);
626
end if;
627
628
if v[2] ne 0 then
629
if s eq "" then
630
if AbsoluteValue(v[2]) eq 1 then
631
if S(v[2]) eq "-" then
632
s:= s*S(v[2])*Sprintf("%o",zn);
633
else s:= s*Sprintf("%o",zn);
634
end if;
635
else if S(v[2]) eq "-" then
636
s:= s*S(v[2])*Abs(v[2])*Sprintf("%o",zn);
637
else s:= s*Abs(v[2])*Sprintf("%o",zn);
638
end if;
639
end if;
640
else if AbsoluteValue(v[2]) eq 1 then
641
s:= s*S(v[2])*Sprintf("%o",zn);
642
else s:= s*S(v[2])*Abs(v[2])*Sprintf("%o",zn);
643
end if;
644
end if;
645
end if;
646
647
for i in [3..m-1] do
648
if v[i] ne 0 then
649
if s eq "" then
650
if AbsoluteValue(v[i]) eq 1 then
651
if S(v[i]) eq "-" then
652
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i-1);
653
else s:= s*Sprintf("%o^{%o}",zn,i-1);
654
end if;
655
else if S(v[i]) eq "-" then
656
s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i-1);
657
else s:= s*Abs(v[i])*Sprintf("%o^{%o-1}",zn,i-1);
658
end if;
659
end if;
660
else if AbsoluteValue(v[i]) eq 1 then
661
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i-1);
662
else s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i-1);
663
end if;
664
end if;
665
end if;
666
end for;
667
return s;
668
end intrinsic;
669
670
671
intrinsic Latex(a::FldNumElt) -> MonStgElt
672
{}
673
s:="";
674
v:=ElementToSequence(a);
675
n:=Degree(Parent(a));
676
677
if Sprintf("%o",Parent(a).1) in Letters then
678
zn:=Sprintf("\\%o",Parent(a).1);
679
else zn:=Sprintf("%o",Parent(a).1);
680
end if;
681
682
if v[1] ne 0 then
683
s:=s*Latex(v[1]);
684
end if;
685
686
if v[2] ne 0 then
687
if s eq "" then
688
if AbsoluteValue(v[2]) eq 1 then
689
if S(v[2]) eq "-" then
690
s:= s*S(v[2])*Sprintf("%o",zn);
691
else s:= s*Sprintf("%o",zn);
692
end if;
693
else if S(v[2]) eq "-" then
694
s:= s*S(v[2])*Abs(v[2])*Sprintf("%o",zn);
695
else s:= s*Abs(v[2])*Sprintf("%o",zn);
696
end if;
697
end if;
698
else if AbsoluteValue(v[2]) eq 1 then
699
s:= s*S(v[2])*Sprintf("%o",zn);
700
else s:= s*S(v[2])*Abs(v[2])*Sprintf("%o",zn);
701
end if;
702
end if;
703
end if;
704
705
for i in [3..n] do
706
if v[i] ne 0 then
707
if s eq "" then
708
if AbsoluteValue(v[i]) eq 1 then
709
if S(v[i]) eq "-" then
710
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i-1);
711
else s:= s*Sprintf("%o^{%o}",zn,i-1);
712
end if;
713
else if S(v[i]) eq "-" then
714
s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i-1);
715
else s:= s*Abs(v[i])*Sprintf("%o^{%o-1}",zn,i-1);
716
end if;
717
end if;
718
else if AbsoluteValue(v[i]) eq 1 then
719
s:= s*S(v[i])*Sprintf("%o^{%o}",zn,i-1);
720
else s:= s*S(v[i])*Abs(v[i])*Sprintf("%o^{%o}",zn,i-1);
721
end if;
722
end if;
723
end if;
724
end for;
725
return s;
726
end intrinsic;
727
728
intrinsic Latex(K::FldFin) -> MonStgElt
729
{}
730
p := Characteristic(K);
731
n := Degree(K);
732
s := Sprintf("\\mathbf{F}_{{%o}",p);
733
if n gt 1 then
734
s *:= Sprintf("^{%o}}",n);
735
else
736
s *:= "}";
737
end if;
738
return s;
739
end intrinsic;
740
741
intrinsic Latex(a::FldFinElt) -> MonStgElt
742
{}
743
s:="";
744
v:=ElementToSequence(a);
745
m:=#v;
746
n:=#(Parent(a));
747
if IsPrime(n) then
748
return Sprint(a);
749
else
750
if Sprintf("%o",Parent(a).1) in Letters then
751
zn:=Sprintf("\\%o",Parent(a).1);
752
else zn:=Sprintf("%o",Parent(a).1);
753
end if;
754
end if;
755
756
if v[1] ne (Parent(a))!0 then
757
s:=s*Sprintf("%o", v[1]);
758
end if;
759
760
if v[2] ne (Parent(a))!0 then
761
if s eq "" then
762
if v[2] eq Parent(a)!1 then
763
s:= s*Sprintf("%o",zn);
764
else
765
s:= s*Sprintf("%o%o",v[2],zn);
766
end if;
767
else
768
if v[2] eq Parent(a)!1 then
769
s:= s*Sprintf("+%o",zn);
770
else
771
s:= s*Sprintf("+%o%o",v[2],zn);
772
end if;
773
end if;
774
end if;
775
776
for i in [3..m] do
777
if v[i] ne Parent(a)!0 then
778
if s eq "" then
779
if v[i] eq Parent(a)!1 then
780
s:= s*Sprintf("%o^{%o}",zn,i-1);
781
else
782
s:= s*Sprintf("%o%o^{%o-1}",v[i],zn,i-1);
783
end if;
784
else
785
if v[i] eq Parent(a)!1 then
786
s:= s*Sprintf("+%o^{%o}",zn,i-1);
787
else s:= s*Sprintf("+%o%o^{%o}",v[i],zn,i-1);
788
end if;
789
end if;
790
end if;
791
end for;
792
return s;
793
end intrinsic;
794
795
intrinsic Latex(x::.) -> MonStgElt
796
{}
797
return Sprintf("\\mbox{\\rm %o}", x);
798
end intrinsic;
799
800
801
802
/*
803
804
These are the MAGMA types:
805
(*) indicates done
806
807
AlgAssElt
808
AlgAssVElt
809
AlgBasElt
810
AlgChtrElt
811
AlgClffElt
812
AlgExtElt
813
AlgFPElt
814
AlgFPEltOld
815
AlgFPGElt
816
AlgFPLieElt
817
AlgFinDElt
818
AlgFrElt
819
AlgGenElt
820
AlgGrpElt
821
AlgHckElt
822
AlgIUEElt
823
AlgInfDElt
824
AlgLieElt
825
AlgMatElt
826
AlgMatLieElt
827
AlgMatVElt
828
AlgPBWElt
829
AlgQUEElt
830
AlgQuatElt
831
AlgQuatOrdElt
832
AlgSymElt
833
AlgUEElt
834
AutCrvEll
835
CopElt
836
(*)CrvEll
837
DiffCrvElt
838
DiffFunElt
839
DivCrvElt
840
DivFunElt
841
DivNumElt
842
ExtReElt
843
FldACElt
844
FldAlgElt
845
FldComElt
846
(*)FldCycElt
847
FldElt
848
(*)FldFin
849
(*)FldFinElt
850
FldFracElt
851
FldFunElt
852
FldFunFracSchElt
853
FldFunFracSchEltOld
854
FldFunGElt
855
FldFunOrdElt
856
(*)FldFunRatElt
857
FldFunRatMElt
858
FldFunRatUElt
859
(*)FldNumElt
860
FldNumGElt
861
FldOrdElt
862
FldPadElt
863
FldPrElt
864
(*)FldQuadElt
865
(*)FldRatElt
866
(*)FldReElt
867
FldResLst
868
FldResLstElt
869
FldTimeElt
870
GenMPolBElt
871
GenMPolBGElt
872
GenMPolElt
873
GenMPolGElt
874
GenMPolResElt
875
GrpAbElt
876
GrpAbGenElt
877
GrpAtcElt
878
GrpAutoElt
879
GrpBBElt
880
GrpBrdElt
881
GrpCaygElt
882
GrpDrchElt
883
GrpDrchEltNew
884
GrpElt
885
GrpFPCosElt
886
GrpFPCoxElt
887
GrpFPDcosElt
888
GrpFPElt
889
GrpFrmlElt
890
GrpGPCElt
891
GrpGenElt
892
GrpLieAutoElt
893
GrpLieElt
894
GrpMatElt
895
GrpMatProjElt
896
GrpPCElt
897
GrpPSL2
898
GrpPSL2Elt
899
GrpPermDcosElt
900
GrpPermElt
901
GrpPermLcosElt
902
GrpPermRcosElt
903
GrpRWSElt
904
GrpSLPElt
905
HilbSpcElt
906
Infty
907
IsoCrvEll
908
LatElt
909
List
910
MPolElt
911
MapCrvEll
912
MapIsoCrvEll
913
ModAbVarElt
914
ModAlgBasElt
915
ModAlgElt
916
ModAltElt
917
ModBrdtElt
918
ModCycElt
919
ModDedElt
920
ModEDElt
921
ModExtElt
922
ModFldElt
923
ModFrmElt
924
ModGrpElt
925
ModHgnElt
926
ModHrmElt
927
ModLatElt
928
ModMPolElt
929
ModMatFldElt
930
ModMatGrpElt
931
ModMatRngElt
932
ModRngElt
933
ModRngMPolRedElt
934
ModSSElt
935
ModSymElt
936
ModThetaElt
937
ModTupAlgElt
938
ModTupFldElt
939
ModTupRngElt
940
MonAbElt
941
MonFPElt
942
MonOrdElt
943
MonPlcElt
944
MonRWSElt
945
MonStgElt
946
MonStgGenElt
947
(*)Mtrx
948
MtrxSpcElt
949
OFldComElt
950
OFldReElt
951
PicCrvElt
952
PicHypSngElt
953
PlcCrvElt
954
PlcFunElt
955
PlcNumElt
956
(*)Pt
957
(*)PtEll
958
PtGrp
959
PtHyp
960
(*)QuadBinElt
961
Rec
962
RecField
963
RecFrmt
964
Ref
965
RegExp
966
RegExpAlg
967
Rel
968
RelElt
969
RngCycElt
970
RngDiffElt
971
RngDiffOpElt
972
RngElt
973
RngFracElt
974
RngFrmElt
975
RngFunFracElt
976
RngFunFracSchElt
977
RngFunFracSchEltOld
978
RngFunFracSchOld
979
RngFunGElt
980
RngFunOrdElt
981
RngFunOrdGElt
982
RngFunOrdIdl
983
RngGalElt
984
RngHckElt
985
RngHckIdl
986
(*)RngIntElt
987
RngIntResElt
988
RngMPolElt
989
RngMPolResElt
990
RngMSerElt
991
RngOrdElt
992
RngOrdFracIdl
993
RngOrdIdl
994
RngOrdResElt
995
RngPadElt
996
RngPadResElt
997
RngPadResExtElt
998
RngPowLazElt
999
RngQuadElt
1000
RngQuadFracIdl
1001
RngQuadIdl
1002
RngReSubElt
1003
RngRelKElt
1004
RngSLPolElt
1005
(*)RngSerElt
1006
RngSerLaurElt
1007
RngSerPowElt
1008
RngSerPuisElt
1009
(*)RngUPolElt
1010
RngUPolResElt
1011
RngValElt
1012
RngWittElt
1013
SchGrpEll
1014
SeqEnum
1015
Set
1016
SetCspElt
1017
SetPtEll
1018
SgpFPElt
1019
SpcFldElt
1020
SpcHypElt
1021
SpcRngElt
1022
SubFldLatElt
1023
SubGrpLatElt
1024
SubModLatElt
1025
SymCrvEll
1026
UnusedMapCrvEll
1027
1028
*/
1029
1030