1freeze;
2
3/****-*-magma-* EXPORT DATE: 2004-03-08 ************************************
4
5                     MODFORM: Modular Forms in MAGMA
6
7                              William A. Stein
8
10
11   $Header: /home/was/magma/packages/modform/code/RCS/p-adic.m,v 1.2 2001/05/30 18:56:25 was Exp$
12
13   $Log: p-adic.m,v$
14   Revision 1.2  2001/05/30 18:56:25  was
15   Created.
16
17   Revision 1.1  2001/05/30 04:10:36  was
18   Initial revision
19
20
21
22 ***************************************************************************/
23
24
25
26intrinsic Slopes(M::ModFrm : Proof := true) -> SeqEnum
27{The slopes of the Newton polygon of the characteristic polynomial f of
28the Hecke operator T_p acting on M, where M is defined over pAdicField(p).
29This is a list of the valuations of the p-adic roots of f.}
30   require Type(BaseRing(M)) eq FldPad :
31     "The base ring of argument 1 must be a p-adic field.";
32   p := Prime(BaseRing(M));
33   return ValuationsOfRoots(HeckePolynomial(M,p : Proof := Proof),p);
34end intrinsic;
35
36
37///////////////////////////////////////////////////////////////////
38// Newton Polygons                                               //
39// Ported from PARI by William Stein  Feb 12, 2000               //
40///////////////////////////////////////////////////////////////////
41intrinsic NP(f::RngUPolElt, p::RngIntElt) -> List
42{The slopes of the Newton polygon of f with at the prime p.
43The slopes are the valuations of the p-adic roots of f.}
44   n := Degree(f);
45   if n le 0 then
46      return [];
47   end if;
48
49   y := [* *];
50   vval := [* *];
51   for i in [0..n] do
52      Append(~vval,Type(Parent(Coefficient(f,0))) in [RngInt,FldRat] select
53                       Valuation(Coefficient(f,i),p)
54                   else
55   		       Valuation(Coefficient(f,i)));
56      Append(~y,0);
57   end for;
58
59   a := 1; ind := 2;
60   while a le n do
61      if vval[a] ne Infinity() then
62         break;
63      end if;
64      y[ind] := Infinity();
65      ind +:= 1;
66      a +:= 1;
67   end while;
68
69   b := a+1;
70   while b le n+1 do
71      while vval[b] eq Infinity() do
72         b +:= 1;
73      end while;
74      u1 := vval[a] - vval[b];
75      u2 := b - a;
76      c := b+1;
77      while c le n+1 do
78         if vval[c] eq Infinity() then
79            c +:= 1;
80            continue;
81         end if;
82         r1 := vval[a] - vval[c];
83         r2 := c - a;
84         if u1*r2 le u2*r1 then
85            u1 := r1;
86            u2 := r2;
87             b := c;
88         end if;
89         c +:= 1;
90      end while;
91
92      while ind le b do
93         if u1 eq 0 then
94            y[ind] := 0;
95         else
96            y[ind] := u1 / u2;
97         end if;
98         ind +:= 1;
99      end while;
100      a := b;
101      b := a+1;
102   end while;
103   Remove(~y,1);
104   z := [* *];
105   for i in [1..#y] do
106      Append(~z,y[#y-i+1]);
107   end for;
108   return z;
109end intrinsic;
110