Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <time.h>
4
#include "smalljac.h"
5
6
/*
7
Copyright 2007 Andrew V. Sutherland
8
9
This file is part of smalljac.
10
11
smalljac is free software: you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 2 of the License, or
14
(at your option) any later version.
15
16
smalljac is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with smalljac. If not, see <http://www.gnu.org/licenses/>.
23
*/
24
25
// simple command-line program to compute the L-polynomial of a J(C/F_p)
26
27
int main (int argc, char *argv[])
28
{
29
unsigned long p;
30
long a[3];
31
int sts, a1_only;
32
33
if ( argc < 3 ) { puts ("lpoly curve q [a1-only-flag]"); puts (" \"lpoly [1,2,3,4,5] 65537\""); puts(" \"lpoly x^5+3x^3-2x+1 10000019\""); return 0; }
34
35
p = atoll(argv[2]);
36
a1_only = ( argc > 3 ? atoi(argv[3]) : 0 );
37
38
sts = smalljac_Lpoly (a, argv[1], p, a1_only);
39
if ( sts <= 0 ) {
40
switch (sts) {
41
case 0: printf ("Specified curve has bad reduction at %lu\n", p); break;
42
case SMALLJAC_PARSE_ERROR: printf ("Unable to parse curve string: %s\n", argv[3]); break;
43
case SMALLJAC_UNSUPPORTED_CURVE: puts ("Specified curve not supported - should be degree 3, 5, or 7\n"); break;
44
case SMALLJAC_SINGULAR_CURVE: puts ("Specified curve is singular over Q\n"); break;
45
case SMALLJAC_INVALID_PP: puts ("q must be a prime power"); break;
46
case SMALLJAC_WRONG_GENUS: printf ("Specified curve has the wrong genus, compiled for genus %d\n", SMALLJAC_GENUS); break;
47
default: printf ("smalljac_Lpoly returned error %d\n", sts);
48
}
49
return 0;
50
}
51
if ( a1_only ) {
52
printf ("a1 coefficient of L_p(T) is %ld\n", a[0]);
53
} else {
54
switch ( sts ) {
55
case 1: printf ("L_q(T) = qT^2 + %ldT + 1\n", a[0]); break;
56
case 2: printf ("L_q(T) = q^2T^4 + %ldqT^3 + %ldT^2 + %ldT + 1\n", a[0], a[1], a[0]); break;
57
case 3: printf ("L_q(T) = q^3T^6 + %ldq^2T^5 + %ldqT^4 + %ldT^3 + %ldT^2 + %ldT + 1\n", a[0], a[1], a[2], a[1], a[0]); break;
58
default: printf ("Lpoly returned unexpected value %d\n", sts);
59
}
60
}
61
}
62
63