Annotation of OpenXM_contrib2/asir2000/engine/gfs.c, Revision 1.10
1.1 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a ligfsted,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a ligfsted right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not ligfsted to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as acadegfsc, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as pergfstted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
26: * e-mail at risa-adgfsn@sec.flab.fujitsu.co.jp of the detailed specification
27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.10 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/engine/gfs.c,v 1.9 2001/10/09 01:36:12 noro Exp $
1.1 noro 49: */
50: #include "ca.h"
51:
52: /* q = p^n */
53:
1.2 noro 54: P current_gfs_ext;
55: int current_gfs_p;
1.1 noro 56: int current_gfs_q;
57: int current_gfs_q1;
58: int *current_gfs_plus1;
59: int *current_gfs_ntoi;
60: int *current_gfs_iton;
61:
1.6 noro 62: struct prim_root_info {
63: int p;
64: int extdeg;
65: int defpoly;
66: int prim_root;
67: };
68:
69: struct prim_root_info prim_root_info_tab[] = {
70: {2,1,0,0}, {2,2,7,2}, {2,3,11,2}, {2,4,19,2}, {2,5,37,2}, {2,6,67,2},
71: {2,7,131,2}, {2,8,283,3}, {2,9,515,7}, {2,10,1033,2}, {2,11,2053,2},
72: {2,12,4105,3}, {2,13,8219,2}, {2,14,16417,7}, {2,15,32771,2}, {3,1,0,2},
73: {3,2,10,4}, {3,3,34,3}, {3,4,86,3}, {3,5,250,3}, {3,6,734,3}, {3,7,2198,5},
74: {3,8,6572,38}, {3,9,19747,3}, {3,10,59068,34}, {5,1,0,2}, {5,2,27,6},
75: {5,3,131,9}, {5,4,627,6}, {5,5,3146,10}, {5,6,15632,5}, {7,1,0,3},
76: {7,2,50,9}, {7,3,345,22}, {7,4,2409,12}, {7,5,16817,9}, {11,1,0,2},
77: {11,2,122,15}, {11,3,1346,11}, {11,4,14654,11}, {13,1,0,2}, {13,2,171,15},
78: {13,3,2199,15}, {13,4,28563,17}, {17,1,0,3}, {17,2,292,19}, {17,3,4933,17},
79: {19,1,0,2}, {19,2,362,22}, {19,3,6861,29}, {23,1,0,5}, {23,2,530,25},
80: {23,3,12193,23}, {29,1,0,2}, {29,2,843,30}, {29,3,24422,30}, {31,1,0,3},
81: {31,2,962,35}, {31,3,29794,34}, {37,1,0,2}, {37,2,1371,41}, {37,3,50655,75},
82: {41,1,0,6}, {41,2,1684,43}, {43,1,0,3}, {43,2,1850,45}, {47,1,0,5},
83: {47,2,2210,49}, {53,1,0,2}, {53,2,2811,54}, {59,1,0,2}, {59,2,3482,62},
84: {61,1,0,2}, {61,2,3723,63}, {67,1,0,2}, {67,2,4490,74}, {71,1,0,7},
85: {71,2,5042,79}, {73,1,0,5}, {73,2,5334,76}, {79,1,0,3}, {79,2,6242,85},
86: {83,1,0,2}, {83,2,6890,93}, {89,1,0,3}, {89,2,7924,91}, {97,1,0,5},
87: {97,2,9414,101}, {101,1,0,2}, {101,2,10203,102},
88: {103,1,0,5}, {103,2,10610,105}, {107,1,0,2}, {107,2,11450,109},
89: {109,1,0,6}, {109,2,11883,111}, {113,1,0,3}, {113,2,12772,117},
90: {127,1,0,3}, {127,2,16130,135}, {131,1,0,2}, {131,2,17162,134},
91: {137,1,0,3}, {137,2,18772,145}, {139,1,0,2}, {139,2,19322,143},
92: {149,1,0,2}, {149,2,22203,152}, {151,1,0,6}, {151,2,22802,160},
93: {157,1,0,5}, {157,2,24651,159}, {163,1,0,2}, {163,2,26570,170},
94: {167,1,0,5}, {167,2,27890,169}, {173,1,0,2}, {173,2,29931,174},
95: {179,1,0,2}, {179,2,32042,182}, {181,1,0,2}, {181,2,32763,185},
96: {191,1,0,19}, {191,2,36482,201}, {193,1,0,5}, {193,2,37254,198},
97: {197,1,0,2}, {197,2,38811,200}, {199,1,0,3}, {199,2,39602,212},
98: {211,1,0,2}, {211,2,44522,215}, {223,1,0,3}, {223,2,49730,225},
99: {227,1,0,2}, {227,2,51530,229}, {229,1,0,6}, {229,2,52443,231},
100: {233,1,0,3}, {233,2,54292,241}, {239,1,0,7}, {239,2,57122,247},
101: {241,1,0,7}, {241,2,58088,248}, {251,1,0,6}, {251,2,63002,256},
102: {257,1,0,3}, {263,1,0,5}, {269,1,0,2}, {271,1,0,6}, {277,1,0,5}, {281,1,0,3},
103: {283,1,0,3}, {293,1,0,2}, {307,1,0,5}, {311,1,0,17}, {313,1,0,10},
104: {317,1,0,2}, {331,1,0,3}, {337,1,0,10}, {347,1,0,2}, {349,1,0,2},
105: {353,1,0,3}, {359,1,0,7}, {367,1,0,6}, {373,1,0,2}, {379,1,0,2},
106: {383,1,0,5}, {389,1,0,2}, {397,1,0,5}, {401,1,0,3}, {409,1,0,21},
107: {419,1,0,2}, {421,1,0,2}, {431,1,0,7}, {433,1,0,5}, {439,1,0,15},
108: {443,1,0,2}, {449,1,0,3}, {457,1,0,13}, {461,1,0,2}, {463,1,0,3},
109: {467,1,0,2}, {479,1,0,13}, {487,1,0,3}, {491,1,0,2}, {499,1,0,7},
110: {503,1,0,5}, {509,1,0,2}, {521,1,0,3}, {523,1,0,2}, {541,1,0,2},
111: {547,1,0,2}, {557,1,0,2}, {563,1,0,2}, {569,1,0,3}, {571,1,0,3},
112: {577,1,0,5}, {587,1,0,2}, {593,1,0,3}, {599,1,0,7}, {601,1,0,7},
113: {607,1,0,3}, {613,1,0,2}, {617,1,0,3}, {619,1,0,2}, {631,1,0,3},
114: {641,1,0,3}, {643,1,0,11}, {647,1,0,5}, {653,1,0,2}, {659,1,0,2},
115: {661,1,0,2}, {673,1,0,5}, {677,1,0,2}, {683,1,0,5}, {691,1,0,3},
116: {701,1,0,2}, {709,1,0,2}, {719,1,0,11}, {727,1,0,5}, {733,1,0,6},
117: {739,1,0,3}, {743,1,0,5}, {751,1,0,3}, {757,1,0,2}, {761,1,0,6},
118: {769,1,0,11}, {773,1,0,2}, {787,1,0,2}, {797,1,0,2}, {809,1,0,3},
119: {811,1,0,3}, {821,1,0,2}, {823,1,0,3}, {827,1,0,2}, {829,1,0,2},
120: {839,1,0,11}, {853,1,0,2}, {857,1,0,3}, {859,1,0,2}, {863,1,0,5},
121: {877,1,0,2}, {881,1,0,3}, {883,1,0,2}, {887,1,0,5}, {907,1,0,2},
122: {911,1,0,17}, {919,1,0,7}, {929,1,0,3}, {937,1,0,5}, {941,1,0,2},
123: {947,1,0,2}, {953,1,0,3}, {967,1,0,5}, {971,1,0,6}, {977,1,0,3},
124: {983,1,0,5}, {991,1,0,6}, {997,1,0,7}, {1009,1,0,11}, {1013,1,0,3},
125: {1019,1,0,2}, {1021,1,0,10}, {1031,1,0,14}, {1033,1,0,5}, {1039,1,0,3},
126: {1049,1,0,3}, {1051,1,0,7}, {1061,1,0,2}, {1063,1,0,3}, {1069,1,0,6},
127: {1087,1,0,3}, {1091,1,0,2}, {1093,1,0,5}, {1097,1,0,3}, {1103,1,0,5},
128: {1109,1,0,2}, {1117,1,0,2}, {1123,1,0,2}, {1129,1,0,11}, {1151,1,0,17},
129: {1153,1,0,5}, {1163,1,0,5}, {1171,1,0,2}, {1181,1,0,7}, {1187,1,0,2},
130: {1193,1,0,3}, {1201,1,0,11}, {1213,1,0,2}, {1217,1,0,3}, {1223,1,0,5},
131: {1229,1,0,2}, {1231,1,0,3}, {1237,1,0,2}, {1249,1,0,7}, {1259,1,0,2},
132: {1277,1,0,2}, {1279,1,0,3}, {1283,1,0,2}, {1289,1,0,6}, {1291,1,0,2},
133: {1297,1,0,10}, {1301,1,0,2}, {1303,1,0,6}, {1307,1,0,2}, {1319,1,0,13},
134: {1321,1,0,13}, {1327,1,0,3}, {1361,1,0,3}, {1367,1,0,5}, {1373,1,0,2},
135: {1381,1,0,2}, {1399,1,0,13}, {1409,1,0,3}, {1423,1,0,3}, {1427,1,0,2},
136: {1429,1,0,6}, {1433,1,0,3}, {1439,1,0,7}, {1447,1,0,3}, {1451,1,0,2},
137: {1453,1,0,2}, {1459,1,0,3}, {1471,1,0,6}, {1481,1,0,3}, {1483,1,0,2},
138: {1487,1,0,5}, {1489,1,0,14}, {1493,1,0,2}, {1499,1,0,2}, {1511,1,0,11},
139: {1523,1,0,2}, {1531,1,0,2}, {1543,1,0,5}, {1549,1,0,2}, {1553,1,0,3},
140: {1559,1,0,19}, {1567,1,0,3}, {1571,1,0,2}, {1579,1,0,3}, {1583,1,0,5},
141: {1597,1,0,11}, {1601,1,0,3}, {1607,1,0,5}, {1609,1,0,7}, {1613,1,0,3},
142: {1619,1,0,2}, {1621,1,0,2}, {1627,1,0,3}, {1637,1,0,2}, {1657,1,0,11},
143: {1663,1,0,3}, {1667,1,0,2}, {1669,1,0,2}, {1693,1,0,2}, {1697,1,0,3},
144: {1699,1,0,3}, {1709,1,0,3}, {1721,1,0,3}, {1723,1,0,3}, {1733,1,0,2},
145: {1741,1,0,2}, {1747,1,0,2}, {1753,1,0,7}, {1759,1,0,6}, {1777,1,0,5},
146: {1783,1,0,10}, {1787,1,0,2}, {1789,1,0,6}, {1801,1,0,11}, {1811,1,0,6},
147: {1823,1,0,5}, {1831,1,0,3}, {1847,1,0,5}, {1861,1,0,2}, {1867,1,0,2},
148: {1871,1,0,14}, {1873,1,0,10}, {1877,1,0,2}, {1879,1,0,6}, {1889,1,0,3},
149: {1901,1,0,2}, {1907,1,0,2}, {1913,1,0,3}, {1931,1,0,2}, {1933,1,0,5},
150: {1949,1,0,2}, {1951,1,0,3}, {1973,1,0,2}, {1979,1,0,2}, {1987,1,0,2},
151: {1993,1,0,5}, {1997,1,0,2}, {1999,1,0,3}, {2003,1,0,5}, {2011,1,0,3},
152: {2017,1,0,5}, {2027,1,0,2}, {2029,1,0,2}, {2039,1,0,7}, {2053,1,0,2},
153: {2063,1,0,5}, {2069,1,0,2}, {2081,1,0,3}, {2083,1,0,2}, {2087,1,0,5},
154: {2089,1,0,7}, {2099,1,0,2}, {2111,1,0,7}, {2113,1,0,5}, {2129,1,0,3},
155: {2131,1,0,2}, {2137,1,0,10}, {2141,1,0,2}, {2143,1,0,3}, {2153,1,0,3},
156: {2161,1,0,23}, {2179,1,0,7}, {2203,1,0,5}, {2207,1,0,5}, {2213,1,0,2},
157: {2221,1,0,2}, {2237,1,0,2}, {2239,1,0,3}, {2243,1,0,2}, {2251,1,0,7},
158: {2267,1,0,2}, {2269,1,0,2}, {2273,1,0,3}, {2281,1,0,7}, {2287,1,0,19},
159: {2293,1,0,2}, {2297,1,0,5}, {2309,1,0,2}, {2311,1,0,3}, {2333,1,0,2},
160: {2339,1,0,2}, {2341,1,0,7}, {2347,1,0,3}, {2351,1,0,13}, {2357,1,0,2},
161: {2371,1,0,2}, {2377,1,0,5}, {2381,1,0,3}, {2383,1,0,5}, {2389,1,0,2},
162: {2393,1,0,3}, {2399,1,0,11}, {2411,1,0,6}, {2417,1,0,3}, {2423,1,0,5},
163: {2437,1,0,2}, {2441,1,0,6}, {2447,1,0,5}, {2459,1,0,2}, {2467,1,0,2},
164: {2473,1,0,5}, {2477,1,0,2}, {2503,1,0,3}, {2521,1,0,17}, {2531,1,0,2},
165: {2539,1,0,2}, {2543,1,0,5}, {2549,1,0,2}, {2551,1,0,6}, {2557,1,0,2},
166: {2579,1,0,2}, {2591,1,0,7}, {2593,1,0,7}, {2609,1,0,3}, {2617,1,0,5},
167: {2621,1,0,2}, {2633,1,0,3}, {2647,1,0,3}, {2657,1,0,3}, {2659,1,0,2},
168: {2663,1,0,5}, {2671,1,0,7}, {2677,1,0,2}, {2683,1,0,2}, {2687,1,0,5},
169: {2689,1,0,19}, {2693,1,0,2}, {2699,1,0,2}, {2707,1,0,2}, {2711,1,0,7},
170: {2713,1,0,5}, {2719,1,0,3}, {2729,1,0,3}, {2731,1,0,3}, {2741,1,0,2},
171: {2749,1,0,6}, {2753,1,0,3}, {2767,1,0,3}, {2777,1,0,3}, {2789,1,0,2},
172: {2791,1,0,6}, {2797,1,0,2}, {2801,1,0,3}, {2803,1,0,2}, {2819,1,0,2},
173: {2833,1,0,5}, {2837,1,0,2}, {2843,1,0,2}, {2851,1,0,2}, {2857,1,0,11},
174: {2861,1,0,2}, {2879,1,0,7}, {2887,1,0,5}, {2897,1,0,3}, {2903,1,0,5},
175: {2909,1,0,2}, {2917,1,0,5}, {2927,1,0,5}, {2939,1,0,2}, {2953,1,0,13},
176: {2957,1,0,2}, {2963,1,0,2}, {2969,1,0,3}, {2971,1,0,10}, {2999,1,0,17},
177: {3001,1,0,14}, {3011,1,0,2}, {3019,1,0,2}, {3023,1,0,5}, {3037,1,0,2},
178: {3041,1,0,3}, {3049,1,0,11}, {3061,1,0,6}, {3067,1,0,2}, {3079,1,0,6},
179: {3083,1,0,2}, {3089,1,0,3}, {3109,1,0,6}, {3119,1,0,7}, {3121,1,0,7},
180: {3137,1,0,3}, {3163,1,0,3}, {3167,1,0,5}, {3169,1,0,7}, {3181,1,0,7},
181: {3187,1,0,2}, {3191,1,0,11}, {3203,1,0,2}, {3209,1,0,3}, {3217,1,0,5},
182: {3221,1,0,10}, {3229,1,0,6}, {3251,1,0,6}, {3253,1,0,2}, {3257,1,0,3},
183: {3259,1,0,3}, {3271,1,0,3}, {3299,1,0,2}, {3301,1,0,6}, {3307,1,0,2},
184: {3313,1,0,10}, {3319,1,0,6}, {3323,1,0,2}, {3329,1,0,3}, {3331,1,0,3},
185: {3343,1,0,5}, {3347,1,0,2}, {3359,1,0,11}, {3361,1,0,22}, {3371,1,0,2},
186: {3373,1,0,5}, {3389,1,0,3}, {3391,1,0,3}, {3407,1,0,5}, {3413,1,0,2},
187: {3433,1,0,5}, {3449,1,0,3}, {3457,1,0,7}, {3461,1,0,2}, {3463,1,0,3},
188: {3467,1,0,2}, {3469,1,0,2}, {3491,1,0,2}, {3499,1,0,2}, {3511,1,0,7},
189: {3517,1,0,2}, {3527,1,0,5}, {3529,1,0,17}, {3533,1,0,2}, {3539,1,0,2},
190: {3541,1,0,7}, {3547,1,0,2}, {3557,1,0,2}, {3559,1,0,3}, {3571,1,0,2},
191: {3581,1,0,2}, {3583,1,0,3}, {3593,1,0,3}, {3607,1,0,5}, {3613,1,0,2},
192: {3617,1,0,3}, {3623,1,0,5}, {3631,1,0,15}, {3637,1,0,2}, {3643,1,0,2},
193: {3659,1,0,2}, {3671,1,0,13}, {3673,1,0,5}, {3677,1,0,2}, {3691,1,0,2},
194: {3697,1,0,5}, {3701,1,0,2}, {3709,1,0,2}, {3719,1,0,7}, {3727,1,0,3},
195: {3733,1,0,2}, {3739,1,0,7}, {3761,1,0,3}, {3767,1,0,5}, {3769,1,0,7},
196: {3779,1,0,2}, {3793,1,0,5}, {3797,1,0,2}, {3803,1,0,2}, {3821,1,0,3},
197: {3823,1,0,3}, {3833,1,0,3}, {3847,1,0,5}, {3851,1,0,2}, {3853,1,0,2},
198: {3863,1,0,5}, {3877,1,0,2}, {3881,1,0,13}, {3889,1,0,11}, {3907,1,0,2},
199: {3911,1,0,13}, {3917,1,0,2}, {3919,1,0,3}, {3923,1,0,2}, {3929,1,0,3},
200: {3931,1,0,2}, {3943,1,0,3}, {3947,1,0,2}, {3967,1,0,6}, {3989,1,0,2},
201: {4001,1,0,3}, {4003,1,0,2}, {4007,1,0,5}, {4013,1,0,2}, {4019,1,0,2},
202: {4021,1,0,2}, {4027,1,0,3}, {4049,1,0,3}, {4051,1,0,10}, {4057,1,0,5},
203: {4073,1,0,3}, {4079,1,0,11}, {4091,1,0,2}, {4093,1,0,2}, {4099,1,0,2},
204: {4111,1,0,12}, {4127,1,0,5}, {4129,1,0,13}, {4133,1,0,2}, {4139,1,0,2},
205: {4153,1,0,5}, {4157,1,0,2}, {4159,1,0,3}, {4177,1,0,5}, {4201,1,0,11},
206: {4211,1,0,6}, {4217,1,0,3}, {4219,1,0,2}, {4229,1,0,2}, {4231,1,0,3},
207: {4241,1,0,3}, {4243,1,0,2}, {4253,1,0,2}, {4259,1,0,2}, {4261,1,0,2},
208: {4271,1,0,7}, {4273,1,0,5}, {4283,1,0,2}, {4289,1,0,3}, {4297,1,0,5},
209: {4327,1,0,3}, {4337,1,0,3}, {4339,1,0,10}, {4349,1,0,2}, {4357,1,0,2},
210: {4363,1,0,2}, {4373,1,0,2}, {4391,1,0,14}, {4397,1,0,2}, {4409,1,0,3},
211: {4421,1,0,3}, {4423,1,0,3}, {4441,1,0,21}, {4447,1,0,3}, {4451,1,0,2},
212: {4457,1,0,3}, {4463,1,0,5}, {4481,1,0,3}, {4483,1,0,2}, {4493,1,0,2},
213: {4507,1,0,2}, {4513,1,0,7}, {4517,1,0,2}, {4519,1,0,3}, {4523,1,0,5},
214: {4547,1,0,2}, {4549,1,0,6}, {4561,1,0,11}, {4567,1,0,3}, {4583,1,0,5},
215: {4591,1,0,11}, {4597,1,0,5}, {4603,1,0,2}, {4621,1,0,2}, {4637,1,0,2},
216: {4639,1,0,3}, {4643,1,0,5}, {4649,1,0,3}, {4651,1,0,3}, {4657,1,0,15},
217: {4663,1,0,3}, {4673,1,0,3}, {4679,1,0,11}, {4691,1,0,2}, {4703,1,0,5},
218: {4721,1,0,6}, {4723,1,0,2}, {4729,1,0,17}, {4733,1,0,5}, {4751,1,0,19},
219: {4759,1,0,3}, {4783,1,0,6}, {4787,1,0,2}, {4789,1,0,2}, {4793,1,0,3},
220: {4799,1,0,7}, {4801,1,0,7}, {4813,1,0,2}, {4817,1,0,3}, {4831,1,0,3},
221: {4861,1,0,11}, {4871,1,0,11}, {4877,1,0,2}, {4889,1,0,3}, {4903,1,0,3},
222: {4909,1,0,6}, {4919,1,0,13}, {4931,1,0,6}, {4933,1,0,2}, {4937,1,0,3},
223: {4943,1,0,7}, {4951,1,0,6}, {4957,1,0,2}, {4967,1,0,5}, {4969,1,0,11},
224: {4973,1,0,2}, {4987,1,0,2}, {4993,1,0,5}, {4999,1,0,3}, {5003,1,0,2},
225: {5009,1,0,3}, {5011,1,0,2}, {5021,1,0,3}, {5023,1,0,3}, {5039,1,0,11},
226: {5051,1,0,2}, {5059,1,0,2}, {5077,1,0,2}, {5081,1,0,3}, {5087,1,0,5},
227: {5099,1,0,2}, {5101,1,0,6}, {5107,1,0,2}, {5113,1,0,19}, {5119,1,0,3},
228: {5147,1,0,2}, {5153,1,0,5}, {5167,1,0,6}, {5171,1,0,2}, {5179,1,0,2},
229: {5189,1,0,2}, {5197,1,0,7}, {5209,1,0,17}, {5227,1,0,2}, {5231,1,0,7},
230: {5233,1,0,10}, {5237,1,0,3}, {5261,1,0,2}, {5273,1,0,3}, {5279,1,0,7},
231: {5281,1,0,7}, {5297,1,0,3}, {5303,1,0,5}, {5309,1,0,2}, {5323,1,0,5},
232: {5333,1,0,2}, {5347,1,0,3}, {5351,1,0,11}, {5381,1,0,3}, {5387,1,0,2},
233: {5393,1,0,3}, {5399,1,0,7}, {5407,1,0,3}, {5413,1,0,5}, {5417,1,0,3},
234: {5419,1,0,3}, {5431,1,0,3}, {5437,1,0,5}, {5441,1,0,3}, {5443,1,0,2},
235: {5449,1,0,7}, {5471,1,0,7}, {5477,1,0,2}, {5479,1,0,3}, {5483,1,0,2},
236: {5501,1,0,2}, {5503,1,0,3}, {5507,1,0,2}, {5519,1,0,13}, {5521,1,0,11},
237: {5527,1,0,5}, {5531,1,0,10}, {5557,1,0,2}, {5563,1,0,2}, {5569,1,0,13},
238: {5573,1,0,2}, {5581,1,0,6}, {5591,1,0,11}, {5623,1,0,5}, {5639,1,0,7},
239: {5641,1,0,14}, {5647,1,0,3}, {5651,1,0,2}, {5653,1,0,5}, {5657,1,0,3},
240: {5659,1,0,2}, {5669,1,0,3}, {5683,1,0,2}, {5689,1,0,11}, {5693,1,0,2},
241: {5701,1,0,2}, {5711,1,0,19}, {5717,1,0,2}, {5737,1,0,5}, {5741,1,0,2},
242: {5743,1,0,10}, {5749,1,0,2}, {5779,1,0,2}, {5783,1,0,7}, {5791,1,0,6},
243: {5801,1,0,3}, {5807,1,0,5}, {5813,1,0,2}, {5821,1,0,6}, {5827,1,0,2},
244: {5839,1,0,6}, {5843,1,0,2}, {5849,1,0,3}, {5851,1,0,2}, {5857,1,0,7},
245: {5861,1,0,3}, {5867,1,0,5}, {5869,1,0,2}, {5879,1,0,11}, {5881,1,0,31},
246: {5897,1,0,3}, {5903,1,0,5}, {5923,1,0,2}, {5927,1,0,5}, {5939,1,0,2},
247: {5953,1,0,7}, {5981,1,0,3}, {5987,1,0,2}, {6007,1,0,3}, {6011,1,0,2},
248: {6029,1,0,2}, {6037,1,0,5}, {6043,1,0,5}, {6047,1,0,5}, {6053,1,0,2},
249: {6067,1,0,2}, {6073,1,0,10}, {6079,1,0,17}, {6089,1,0,3}, {6091,1,0,7},
250: {6101,1,0,2}, {6113,1,0,3}, {6121,1,0,7}, {6131,1,0,2}, {6133,1,0,5},
251: {6143,1,0,5}, {6151,1,0,3}, {6163,1,0,3}, {6173,1,0,2}, {6197,1,0,2},
252: {6199,1,0,3}, {6203,1,0,2}, {6211,1,0,2}, {6217,1,0,5}, {6221,1,0,3},
253: {6229,1,0,2}, {6247,1,0,5}, {6257,1,0,3}, {6263,1,0,5}, {6269,1,0,2},
254: {6271,1,0,11}, {6277,1,0,2}, {6287,1,0,7}, {6299,1,0,2}, {6301,1,0,10},
255: {6311,1,0,7}, {6317,1,0,2}, {6323,1,0,2}, {6329,1,0,3}, {6337,1,0,10},
256: {6343,1,0,3}, {6353,1,0,3}, {6359,1,0,13}, {6361,1,0,19}, {6367,1,0,3},
257: {6373,1,0,2}, {6379,1,0,2}, {6389,1,0,2}, {6397,1,0,2}, {6421,1,0,6},
258: {6427,1,0,3}, {6449,1,0,3}, {6451,1,0,3}, {6469,1,0,2}, {6473,1,0,3},
259: {6481,1,0,7}, {6491,1,0,2}, {6521,1,0,6}, {6529,1,0,7}, {6547,1,0,2},
260: {6551,1,0,17}, {6553,1,0,10}, {6563,1,0,5}, {6569,1,0,3}, {6571,1,0,3},
261: {6577,1,0,5}, {6581,1,0,14}, {6599,1,0,13}, {6607,1,0,3}, {6619,1,0,2},
262: {6637,1,0,2}, {6653,1,0,2}, {6659,1,0,2}, {6661,1,0,6}, {6673,1,0,5},
263: {6679,1,0,7}, {6689,1,0,3}, {6691,1,0,2}, {6701,1,0,2}, {6703,1,0,5},
264: {6709,1,0,2}, {6719,1,0,11}, {6733,1,0,2}, {6737,1,0,3}, {6761,1,0,3},
265: {6763,1,0,2}, {6779,1,0,2}, {6781,1,0,2}, {6791,1,0,7}, {6793,1,0,10},
266: {6803,1,0,2}, {6823,1,0,3}, {6827,1,0,2}, {6829,1,0,2}, {6833,1,0,3},
267: {6841,1,0,22}, {6857,1,0,3}, {6863,1,0,5}, {6869,1,0,2}, {6871,1,0,3},
268: {6883,1,0,2}, {6899,1,0,2}, {6907,1,0,2}, {6911,1,0,7}, {6917,1,0,2},
269: {6947,1,0,2}, {6949,1,0,2}, {6959,1,0,7}, {6961,1,0,13}, {6967,1,0,5},
270: {6971,1,0,2}, {6977,1,0,3}, {6983,1,0,5}, {6991,1,0,6}, {6997,1,0,5},
271: {7001,1,0,3}, {7013,1,0,2}, {7019,1,0,2}, {7027,1,0,2}, {7039,1,0,3},
272: {7043,1,0,2}, {7057,1,0,5}, {7069,1,0,2}, {7079,1,0,7}, {7103,1,0,5},
273: {7109,1,0,2}, {7121,1,0,3}, {7127,1,0,5}, {7129,1,0,7}, {7151,1,0,7},
274: {7159,1,0,3}, {7177,1,0,10}, {7187,1,0,2}, {7193,1,0,3}, {7207,1,0,3},
275: {7211,1,0,2}, {7213,1,0,5}, {7219,1,0,2}, {7229,1,0,2}, {7237,1,0,2},
276: {7243,1,0,2}, {7247,1,0,5}, {7253,1,0,2}, {7283,1,0,2}, {7297,1,0,5},
277: {7307,1,0,2}, {7309,1,0,6}, {7321,1,0,7}, {7331,1,0,2}, {7333,1,0,6},
278: {7349,1,0,2}, {7351,1,0,6}, {7369,1,0,7}, {7393,1,0,5}, {7411,1,0,2},
279: {7417,1,0,5}, {7433,1,0,3}, {7451,1,0,2}, {7457,1,0,3}, {7459,1,0,2},
280: {7477,1,0,2}, {7481,1,0,6}, {7487,1,0,5}, {7489,1,0,7}, {7499,1,0,2},
281: {7507,1,0,2}, {7517,1,0,2}, {7523,1,0,2}, {7529,1,0,3}, {7537,1,0,7},
282: {7541,1,0,2}, {7547,1,0,2}, {7549,1,0,2}, {7559,1,0,13}, {7561,1,0,13},
283: {7573,1,0,2}, {7577,1,0,3}, {7583,1,0,5}, {7589,1,0,2}, {7591,1,0,6},
284: {7603,1,0,2}, {7607,1,0,5}, {7621,1,0,2}, {7639,1,0,7}, {7643,1,0,2},
285: {7649,1,0,3}, {7669,1,0,2}, {7673,1,0,3}, {7681,1,0,17}, {7687,1,0,6},
286: {7691,1,0,2}, {7699,1,0,3}, {7703,1,0,5}, {7717,1,0,2}, {7723,1,0,3},
287: {7727,1,0,5}, {7741,1,0,7}, {7753,1,0,10}, {7757,1,0,2}, {7759,1,0,3},
288: {7789,1,0,2}, {7793,1,0,3}, {7817,1,0,3}, {7823,1,0,5}, {7829,1,0,2},
289: {7841,1,0,12}, {7853,1,0,2}, {7867,1,0,3}, {7873,1,0,5}, {7877,1,0,2},
290: {7879,1,0,3}, {7883,1,0,2}, {7901,1,0,2}, {7907,1,0,2}, {7919,1,0,7},
291: {7927,1,0,3}, {7933,1,0,2}, {7937,1,0,3}, {7949,1,0,2}, {7951,1,0,6},
292: {7963,1,0,5}, {7993,1,0,5}, {8009,1,0,3}, {8011,1,0,14}, {8017,1,0,5},
293: {8039,1,0,11}, {8053,1,0,2}, {8059,1,0,3}, {8069,1,0,2}, {8081,1,0,3},
294: {8087,1,0,5}, {8089,1,0,17}, {8093,1,0,2}, {8101,1,0,6}, {8111,1,0,11},
295: {8117,1,0,2}, {8123,1,0,2}, {8147,1,0,2}, {8161,1,0,7}, {8167,1,0,3},
296: {8171,1,0,2}, {8179,1,0,2}, {8191,1,0,17}, {8209,1,0,7}, {8219,1,0,2},
297: {8221,1,0,2}, {8231,1,0,11}, {8233,1,0,10}, {8237,1,0,2}, {8243,1,0,2},
298: {8263,1,0,3}, {8269,1,0,2}, {8273,1,0,3}, {8287,1,0,3}, {8291,1,0,2},
299: {8293,1,0,2}, {8297,1,0,3}, {8311,1,0,3}, {8317,1,0,6}, {8329,1,0,7},
300: {8353,1,0,5}, {8363,1,0,2}, {8369,1,0,3}, {8377,1,0,5}, {8387,1,0,2},
301: {8389,1,0,6}, {8419,1,0,3}, {8423,1,0,5}, {8429,1,0,2}, {8431,1,0,3},
302: {8443,1,0,2}, {8447,1,0,5}, {8461,1,0,6}, {8467,1,0,2}, {8501,1,0,7},
303: {8513,1,0,5}, {8521,1,0,13}, {8527,1,0,5}, {8537,1,0,3}, {8539,1,0,2},
304: {8543,1,0,5}, {8563,1,0,2}, {8573,1,0,2}, {8581,1,0,6}, {8597,1,0,2},
305: {8599,1,0,3}, {8609,1,0,3}, {8623,1,0,3}, {8627,1,0,2}, {8629,1,0,6},
306: {8641,1,0,17}, {8647,1,0,3}, {8663,1,0,5}, {8669,1,0,2}, {8677,1,0,2},
307: {8681,1,0,15}, {8689,1,0,13}, {8693,1,0,2}, {8699,1,0,2}, {8707,1,0,5},
308: {8713,1,0,5}, {8719,1,0,3}, {8731,1,0,2}, {8737,1,0,5}, {8741,1,0,2},
309: {8747,1,0,2}, {8753,1,0,3}, {8761,1,0,23}, {8779,1,0,11}, {8783,1,0,5},
310: {8803,1,0,2}, {8807,1,0,5}, {8819,1,0,2}, {8821,1,0,2}, {8831,1,0,7},
311: {8837,1,0,2}, {8839,1,0,3}, {8849,1,0,3}, {8861,1,0,2}, {8863,1,0,3},
312: {8867,1,0,2}, {8887,1,0,3}, {8893,1,0,5}, {8923,1,0,2}, {8929,1,0,11},
313: {8933,1,0,2}, {8941,1,0,6}, {8951,1,0,13}, {8963,1,0,2}, {8969,1,0,3},
314: {8971,1,0,2}, {8999,1,0,7}, {9001,1,0,7}, {9007,1,0,3}, {9011,1,0,2},
315: {9013,1,0,5}, {9029,1,0,2}, {9041,1,0,3}, {9043,1,0,3}, {9049,1,0,7},
316: {9059,1,0,2}, {9067,1,0,3}, {9091,1,0,3}, {9103,1,0,6}, {9109,1,0,10},
317: {9127,1,0,3}, {9133,1,0,6}, {9137,1,0,3}, {9151,1,0,3}, {9157,1,0,6},
318: {9161,1,0,3}, {9173,1,0,2}, {9181,1,0,2}, {9187,1,0,3}, {9199,1,0,3},
319: {9203,1,0,2}, {9209,1,0,3}, {9221,1,0,2}, {9227,1,0,2}, {9239,1,0,19},
320: {9241,1,0,13}, {9257,1,0,3}, {9277,1,0,5}, {9281,1,0,3}, {9283,1,0,2},
321: {9293,1,0,2}, {9311,1,0,7}, {9319,1,0,3}, {9323,1,0,2}, {9337,1,0,5},
322: {9341,1,0,2}, {9343,1,0,5}, {9349,1,0,2}, {9371,1,0,2}, {9377,1,0,3},
323: {9391,1,0,3}, {9397,1,0,2}, {9403,1,0,3}, {9413,1,0,3}, {9419,1,0,2},
324: {9421,1,0,2}, {9431,1,0,7}, {9433,1,0,5}, {9437,1,0,2}, {9439,1,0,22},
325: {9461,1,0,3}, {9463,1,0,3}, {9467,1,0,2}, {9473,1,0,3}, {9479,1,0,7},
326: {9491,1,0,2}, {9497,1,0,3}, {9511,1,0,3}, {9521,1,0,3}, {9533,1,0,2},
327: {9539,1,0,2}, {9547,1,0,2}, {9551,1,0,11}, {9587,1,0,2}, {9601,1,0,13},
328: {9613,1,0,2}, {9619,1,0,2}, {9623,1,0,5}, {9629,1,0,2}, {9631,1,0,3},
329: {9643,1,0,2}, {9649,1,0,7}, {9661,1,0,2}, {9677,1,0,2}, {9679,1,0,3},
330: {9689,1,0,3}, {9697,1,0,10}, {9719,1,0,17}, {9721,1,0,7}, {9733,1,0,2},
331: {9739,1,0,3}, {9743,1,0,5}, {9749,1,0,2}, {9767,1,0,5}, {9769,1,0,13},
332: {9781,1,0,6}, {9787,1,0,3}, {9791,1,0,11}, {9803,1,0,2}, {9811,1,0,3},
333: {9817,1,0,5}, {9829,1,0,10}, {9833,1,0,3}, {9839,1,0,7}, {9851,1,0,2},
334: {9857,1,0,5}, {9859,1,0,2}, {9871,1,0,3}, {9883,1,0,2}, {9887,1,0,5},
335: {9901,1,0,2}, {9907,1,0,2}, {9923,1,0,2}, {9929,1,0,3}, {9931,1,0,10},
336: {9941,1,0,2}, {9949,1,0,2}, {9967,1,0,3}, {9973,1,0,11}, {10007,1,0,5},
337: {10009,1,0,11}, {10037,1,0,2}, {10039,1,0,3}, {10061,1,0,3}, {10067,1,0,2},
338: {10069,1,0,2}, {10079,1,0,11}, {10091,1,0,2}, {10093,1,0,2}, {10099,1,0,2},
339: {10103,1,0,5}, {10111,1,0,12}, {10133,1,0,2}, {10139,1,0,2}, {10141,1,0,2},
340: {10151,1,0,7}, {10159,1,0,3}, {10163,1,0,2}, {10169,1,0,3}, {10177,1,0,7},
341: {10181,1,0,2}, {10193,1,0,3}, {10211,1,0,6}, {10223,1,0,5}, {10243,1,0,7},
342: {10247,1,0,5}, {10253,1,0,2}, {10259,1,0,2}, {10267,1,0,2}, {10271,1,0,7},
343: {10273,1,0,10}, {10289,1,0,3}, {10301,1,0,2}, {10303,1,0,3}, {10313,1,0,3},
344: {10321,1,0,7}, {10331,1,0,2}, {10333,1,0,5}, {10337,1,0,3}, {10343,1,0,5},
345: {10357,1,0,2}, {10369,1,0,13}, {10391,1,0,19}, {10399,1,0,6}, {10427,1,0,2},
346: {10429,1,0,7}, {10433,1,0,3}, {10453,1,0,5}, {10457,1,0,3}, {10459,1,0,2},
347: {10463,1,0,5}, {10477,1,0,2}, {10487,1,0,5}, {10499,1,0,2}, {10501,1,0,2},
348: {10513,1,0,7}, {10529,1,0,3}, {10531,1,0,3}, {10559,1,0,23}, {10567,1,0,6},
349: {10589,1,0,2}, {10597,1,0,5}, {10601,1,0,3}, {10607,1,0,5}, {10613,1,0,2},
350: {10627,1,0,5}, {10631,1,0,11}, {10639,1,0,6}, {10651,1,0,7}, {10657,1,0,7},
351: {10663,1,0,3}, {10667,1,0,2}, {10687,1,0,5}, {10691,1,0,2}, {10709,1,0,2},
352: {10711,1,0,3}, {10723,1,0,2}, {10729,1,0,7}, {10733,1,0,2}, {10739,1,0,6},
353: {10753,1,0,11}, {10771,1,0,3}, {10781,1,0,10}, {10789,1,0,2}, {10799,1,0,19},
354: {10831,1,0,7}, {10837,1,0,2}, {10847,1,0,5}, {10853,1,0,2}, {10859,1,0,2},
355: {10861,1,0,2}, {10867,1,0,2}, {10883,1,0,2}, {10889,1,0,3}, {10891,1,0,2},
356: {10903,1,0,3}, {10909,1,0,2}, {10937,1,0,3}, {10939,1,0,3}, {10949,1,0,2},
357: {10957,1,0,5}, {10973,1,0,2}, {10979,1,0,2}, {10987,1,0,2}, {10993,1,0,7},
358: {11003,1,0,2}, {11027,1,0,2}, {11047,1,0,3}, {11057,1,0,3}, {11059,1,0,10},
359: {11069,1,0,2}, {11071,1,0,3}, {11083,1,0,2}, {11087,1,0,5}, {11093,1,0,2},
360: {11113,1,0,13}, {11117,1,0,3}, {11119,1,0,3}, {11131,1,0,2}, {11149,1,0,10},
361: {11159,1,0,7}, {11161,1,0,7}, {11171,1,0,2}, {11173,1,0,5}, {11177,1,0,3},
362: {11197,1,0,2}, {11213,1,0,2}, {11239,1,0,3}, {11243,1,0,5}, {11251,1,0,13},
363: {11257,1,0,10}, {11261,1,0,2}, {11273,1,0,3}, {11279,1,0,7}, {11287,1,0,3},
364: {11299,1,0,3}, {11311,1,0,3}, {11317,1,0,2}, {11321,1,0,3}, {11329,1,0,7},
365: {11351,1,0,7}, {11353,1,0,7}, {11369,1,0,3}, {11383,1,0,5}, {11393,1,0,3},
366: {11399,1,0,11}, {11411,1,0,7}, {11423,1,0,5}, {11437,1,0,2}, {11443,1,0,2},
367: {11447,1,0,5}, {11467,1,0,5}, {11471,1,0,11}, {11483,1,0,2}, {11489,1,0,3},
368: {11491,1,0,3}, {11497,1,0,7}, {11503,1,0,3}, {11519,1,0,7}, {11527,1,0,5},
369: {11549,1,0,2}, {11551,1,0,7}, {11579,1,0,2}, {11587,1,0,2}, {11593,1,0,5},
370: {11597,1,0,3}, {11617,1,0,10}, {11621,1,0,2}, {11633,1,0,3}, {11657,1,0,3},
371: {11677,1,0,2}, {11681,1,0,3}, {11689,1,0,7}, {11699,1,0,2}, {11701,1,0,6},
372: {11717,1,0,2}, {11719,1,0,6}, {11731,1,0,3}, {11743,1,0,3}, {11777,1,0,3},
373: {11779,1,0,2}, {11783,1,0,5}, {11789,1,0,2}, {11801,1,0,3}, {11807,1,0,5},
374: {11813,1,0,2}, {11821,1,0,2}, {11827,1,0,2}, {11831,1,0,7}, {11833,1,0,5},
375: {11839,1,0,3}, {11863,1,0,3}, {11867,1,0,2}, {11887,1,0,3}, {11897,1,0,3},
376: {11903,1,0,5}, {11909,1,0,2}, {11923,1,0,5}, {11927,1,0,5}, {11933,1,0,2},
377: {11939,1,0,2}, {11941,1,0,10}, {11953,1,0,5}, {11959,1,0,3}, {11969,1,0,3},
378: {11971,1,0,10}, {11981,1,0,2}, {11987,1,0,2}, {12007,1,0,13}, {12011,1,0,2},
379: {12037,1,0,5}, {12041,1,0,3}, {12043,1,0,2}, {12049,1,0,13}, {12071,1,0,11},
380: {12073,1,0,7}, {12097,1,0,5}, {12101,1,0,3}, {12107,1,0,2}, {12109,1,0,6},
381: {12113,1,0,3}, {12119,1,0,7}, {12143,1,0,10}, {12149,1,0,2}, {12157,1,0,2},
382: {12161,1,0,3}, {12163,1,0,5}, {12197,1,0,2}, {12203,1,0,2}, {12211,1,0,2},
383: {12227,1,0,2}, {12239,1,0,13}, {12241,1,0,7}, {12251,1,0,2}, {12253,1,0,2},
384: {12263,1,0,5}, {12269,1,0,2}, {12277,1,0,2}, {12281,1,0,3}, {12289,1,0,11},
385: {12301,1,0,2}, {12323,1,0,2}, {12329,1,0,3}, {12343,1,0,7}, {12347,1,0,2},
386: {12373,1,0,2}, {12377,1,0,6}, {12379,1,0,2}, {12391,1,0,26}, {12401,1,0,3},
387: {12409,1,0,7}, {12413,1,0,2}, {12421,1,0,7}, {12433,1,0,13}, {12437,1,0,2},
388: {12451,1,0,3}, {12457,1,0,10}, {12473,1,0,3}, {12479,1,0,23}, {12487,1,0,3},
389: {12491,1,0,2}, {12497,1,0,3}, {12503,1,0,5}, {12511,1,0,3}, {12517,1,0,6},
390: {12527,1,0,5}, {12539,1,0,2}, {12541,1,0,14}, {12547,1,0,2}, {12553,1,0,5},
391: {12569,1,0,3}, {12577,1,0,10}, {12583,1,0,5}, {12589,1,0,2}, {12601,1,0,11},
392: {12611,1,0,2}, {12613,1,0,2}, {12619,1,0,2}, {12637,1,0,2}, {12641,1,0,3},
393: {12647,1,0,5}, {12653,1,0,2}, {12659,1,0,2}, {12671,1,0,14}, {12689,1,0,3},
394: {12697,1,0,7}, {12703,1,0,3}, {12713,1,0,3}, {12721,1,0,13}, {12739,1,0,2},
395: {12743,1,0,5}, {12757,1,0,2}, {12763,1,0,2}, {12781,1,0,2}, {12791,1,0,7},
396: {12799,1,0,13}, {12809,1,0,3}, {12821,1,0,2}, {12823,1,0,3}, {12829,1,0,2},
397: {12841,1,0,21}, {12853,1,0,5}, {12889,1,0,13}, {12893,1,0,3}, {12899,1,0,2},
398: {12907,1,0,2}, {12911,1,0,23}, {12917,1,0,2}, {12919,1,0,6}, {12923,1,0,2},
399: {12941,1,0,2}, {12953,1,0,3}, {12959,1,0,7}, {12967,1,0,3}, {12973,1,0,14},
400: {12979,1,0,2}, {12983,1,0,5}, {13001,1,0,3}, {13003,1,0,5}, {13007,1,0,5},
401: {13009,1,0,7}, {13033,1,0,5}, {13037,1,0,2}, {13043,1,0,2}, {13049,1,0,3},
402: {13063,1,0,5}, {13093,1,0,6}, {13099,1,0,3}, {13103,1,0,5}, {13109,1,0,2},
403: {13121,1,0,7}, {13127,1,0,5}, {13147,1,0,2}, {13151,1,0,13}, {13159,1,0,3},
404: {13163,1,0,2}, {13171,1,0,11}, {13177,1,0,5}, {13183,1,0,3}, {13187,1,0,2},
405: {13217,1,0,3}, {13219,1,0,3}, {13229,1,0,2}, {13241,1,0,3}, {13249,1,0,7},
406: {13259,1,0,6}, {13267,1,0,3}, {13291,1,0,2}, {13297,1,0,5}, {13309,1,0,6},
407: {13313,1,0,3}, {13327,1,0,3}, {13331,1,0,2}, {13337,1,0,3}, {13339,1,0,2},
408: {13367,1,0,5}, {13381,1,0,10}, {13397,1,0,2}, {13399,1,0,3}, {13411,1,0,2},
409: {13417,1,0,5}, {13421,1,0,10}, {13441,1,0,11}, {13451,1,0,2}, {13457,1,0,3},
410: {13463,1,0,5}, {13469,1,0,2}, {13477,1,0,2}, {13487,1,0,5}, {13499,1,0,6},
411: {13513,1,0,5}, {13523,1,0,2}, {13537,1,0,7}, {13553,1,0,3}, {13567,1,0,3},
412: {13577,1,0,3}, {13591,1,0,3}, {13597,1,0,5}, {13613,1,0,2}, {13619,1,0,2},
413: {13627,1,0,2}, {13633,1,0,5}, {13649,1,0,3}, {13669,1,0,6}, {13679,1,0,7},
414: {13681,1,0,22}, {13687,1,0,3}, {13691,1,0,2}, {13693,1,0,6}, {13697,1,0,3},
415: {13709,1,0,2}, {13711,1,0,6}, {13721,1,0,3}, {13723,1,0,2}, {13729,1,0,23},
416: {13751,1,0,11}, {13757,1,0,2}, {13759,1,0,6}, {13763,1,0,2}, {13781,1,0,7},
417: {13789,1,0,7}, {13799,1,0,7}, {13807,1,0,5}, {13829,1,0,2}, {13831,1,0,6},
418: {13841,1,0,6}, {13859,1,0,2}, {13873,1,0,5}, {13877,1,0,2}, {13879,1,0,6},
419: {13883,1,0,2}, {13901,1,0,2}, {13903,1,0,3}, {13907,1,0,2}, {13913,1,0,3},
420: {13921,1,0,7}, {13931,1,0,2}, {13933,1,0,2}, {13963,1,0,3}, {13967,1,0,5},
421: {13997,1,0,2}, {13999,1,0,3}, {14009,1,0,3}, {14011,1,0,2}, {14029,1,0,6},
422: {14033,1,0,3}, {14051,1,0,2}, {14057,1,0,3}, {14071,1,0,7}, {14081,1,0,3},
423: {14083,1,0,3}, {14087,1,0,5}, {14107,1,0,2}, {14143,1,0,3}, {14149,1,0,6},
424: {14153,1,0,3}, {14159,1,0,13}, {14173,1,0,2}, {14177,1,0,3}, {14197,1,0,11},
425: {14207,1,0,5}, {14221,1,0,2}, {14243,1,0,2}, {14249,1,0,3}, {14251,1,0,3},
426: {14281,1,0,19}, {14293,1,0,6}, {14303,1,0,5}, {14321,1,0,3}, {14323,1,0,5},
427: {14327,1,0,5}, {14341,1,0,2}, {14347,1,0,3}, {14369,1,0,3}, {14387,1,0,2},
428: {14389,1,0,2}, {14401,1,0,11}, {14407,1,0,19}, {14411,1,0,2}, {14419,1,0,2},
429: {14423,1,0,5}, {14431,1,0,3}, {14437,1,0,5}, {14447,1,0,5}, {14449,1,0,22},
430: {14461,1,0,2}, {14479,1,0,3}, {14489,1,0,3}, {14503,1,0,3}, {14519,1,0,13},
431: {14533,1,0,2}, {14537,1,0,3}, {14543,1,0,5}, {14549,1,0,2}, {14551,1,0,3},
432: {14557,1,0,2}, {14561,1,0,6}, {14563,1,0,3}, {14591,1,0,11}, {14593,1,0,5},
433: {14621,1,0,2}, {14627,1,0,2}, {14629,1,0,2}, {14633,1,0,3}, {14639,1,0,11},
434: {14653,1,0,2}, {14657,1,0,3}, {14669,1,0,2}, {14683,1,0,3}, {14699,1,0,2},
435: {14713,1,0,5}, {14717,1,0,2}, {14723,1,0,2}, {14731,1,0,10}, {14737,1,0,10},
436: {14741,1,0,2}, {14747,1,0,2}, {14753,1,0,3}, {14759,1,0,17}, {14767,1,0,3},
437: {14771,1,0,2}, {14779,1,0,3}, {14783,1,0,5}, {14797,1,0,2}, {14813,1,0,2},
438: {14821,1,0,2}, {14827,1,0,2}, {14831,1,0,11}, {14843,1,0,2}, {14851,1,0,2},
439: {14867,1,0,2}, {14869,1,0,2}, {14879,1,0,7}, {14887,1,0,3}, {14891,1,0,2},
440: {14897,1,0,3}, {14923,1,0,2}, {14929,1,0,7}, {14939,1,0,2}, {14947,1,0,2},
441: {14951,1,0,19}, {14957,1,0,2}, {14969,1,0,3}, {14983,1,0,3}, {15013,1,0,2},
442: {15017,1,0,3}, {15031,1,0,3}, {15053,1,0,2}, {15061,1,0,2}, {15073,1,0,5},
443: {15077,1,0,2}, {15083,1,0,2}, {15091,1,0,2}, {15101,1,0,2}, {15107,1,0,2},
444: {15121,1,0,11}, {15131,1,0,2}, {15137,1,0,3}, {15139,1,0,2}, {15149,1,0,2},
445: {15161,1,0,3}, {15173,1,0,2}, {15187,1,0,2}, {15193,1,0,5}, {15199,1,0,6},
446: {15217,1,0,10}, {15227,1,0,2}, {15233,1,0,3}, {15241,1,0,11}, {15259,1,0,2},
447: {15263,1,0,5}, {15269,1,0,2}, {15271,1,0,11}, {15277,1,0,6}, {15287,1,0,5},
448: {15289,1,0,11}, {15299,1,0,2}, {15307,1,0,3}, {15313,1,0,5}, {15319,1,0,3},
449: {15329,1,0,3}, {15331,1,0,2}, {15349,1,0,2}, {15359,1,0,11}, {15361,1,0,7},
450: {15373,1,0,2}, {15377,1,0,3}, {15383,1,0,5}, {15391,1,0,12}, {15401,1,0,6},
451: {15413,1,0,2}, {15427,1,0,2}, {15439,1,0,3}, {15443,1,0,2}, {15451,1,0,3},
452: {15461,1,0,2}, {15467,1,0,5}, {15473,1,0,3}, {15493,1,0,5}, {15497,1,0,3},
453: {15511,1,0,3}, {15527,1,0,5}, {15541,1,0,6}, {15551,1,0,7}, {15559,1,0,3},
454: {15569,1,0,3}, {15581,1,0,2}, {15583,1,0,5}, {15601,1,0,23}, {15607,1,0,3},
455: {15619,1,0,7}, {15629,1,0,2}, {15641,1,0,3}, {15643,1,0,5}, {15647,1,0,5},
456: {15649,1,0,11}, {15661,1,0,2}, {15667,1,0,2}, {15671,1,0,13}, {15679,1,0,11},
457: {15683,1,0,2}, {15727,1,0,3}, {15731,1,0,2}, {15733,1,0,6}, {15737,1,0,3},
458: {15739,1,0,2}, {15749,1,0,2}, {15761,1,0,3}, {15767,1,0,5}, {15773,1,0,2},
459: {15787,1,0,2}, {15791,1,0,29}, {15797,1,0,2}, {15803,1,0,2}, {15809,1,0,3},
460: {15817,1,0,5}, {15823,1,0,3}, {15859,1,0,2}, {15877,1,0,5}, {15881,1,0,3},
461: {15887,1,0,5}, {15889,1,0,21}, {15901,1,0,10}, {15907,1,0,2}, {15913,1,0,5},
462: {15919,1,0,6}, {15923,1,0,2}, {15937,1,0,7}, {15959,1,0,11}, {15971,1,0,2},
463: {15973,1,0,7}, {15991,1,0,12}, {16001,1,0,3}, {16007,1,0,5}, {16033,1,0,5},
464: {16057,1,0,7}, {16061,1,0,12}, {16063,1,0,5}, {16067,1,0,2}, {16069,1,0,2},
465: {16073,1,0,3}, {16087,1,0,5}, {16091,1,0,6}, {16097,1,0,3}, {16103,1,0,5},
466: {16111,1,0,7}, {16127,1,0,5}, {16139,1,0,2}, {16141,1,0,6}, {16183,1,0,3},
467: {16187,1,0,2}, {16189,1,0,2}, {16193,1,0,5}, {16217,1,0,3}, {16223,1,0,5},
468: {16229,1,0,2}, {16231,1,0,3}, {16249,1,0,17}, {16253,1,0,2}, {16267,1,0,3},
469: {16273,1,0,7}, {16301,1,0,2}, {16319,1,0,7}, {16333,1,0,2}, {16339,1,0,2},
470: {16349,1,0,2}, {16361,1,0,3}, {16363,1,0,2}, {16369,1,0,7}, {16381,1,0,2},
471: };
472:
1.9 noro 473: void dec_um(int p,int a,UM u)
1.2 noro 474: {
475: int i;
476:
477: for ( i = 0; a; i++, a /= p )
478: COEF(u)[i] = a%p;
479: DEG(u) = i-1;
480: }
1.1 noro 481:
482: /*
1.2 noro 483: * an element of GF(p^n) f(x)=a(n-1)*x^(n-1)+...+a(0)
484: * is encodeded to f(p).
1.1 noro 485: * current_gfs_iton[i] = r^i mod p (i=0,...,p-2)
486: * current_gfs_iton[p-1] = 0
487: */
488:
1.9 noro 489: void setmod_sf(int p,int n)
1.1 noro 490: {
1.2 noro 491: int r,i,q1,q,t,t1;
492: UM dp;
1.1 noro 493:
1.2 noro 494: for ( i = 0, q = 1; i < n; i++ )
495: q *= p;
496: dp = UMALLOC(n);
1.6 noro 497: r = search_defpoly_and_primitive_root(p,n,dp);
498: if ( !r ) {
499: generate_defpoly_um(p,n,dp);
500: r = generate_primitive_root_enc(p,n,dp);
1.9 noro 501: if ( !r )
502: error("setmod_sf : primitive root not found");
1.6 noro 503: }
1.2 noro 504: current_gfs_p = p;
505: current_gfs_q = q;
506: current_gfs_q1 = q1 = q-1;
1.1 noro 507: if ( n > 1 )
1.2 noro 508: umtop(CO->v,dp,¤t_gfs_ext);
509: else
510: current_gfs_ext = 0;
511: current_gfs_iton = (int *)MALLOC(q1*sizeof(int));
512: current_gfs_iton[0] = 1;
513: for ( i = 1; i < q1; i++ )
514: current_gfs_iton[i] = mulremum_enc(p,n,dp,current_gfs_iton[i-1],r);
515:
516: current_gfs_ntoi = (int *)MALLOC(q*sizeof(int));
517: current_gfs_ntoi[0] = -1;
518: for ( i = 0; i < q1; i++ )
519: current_gfs_ntoi[current_gfs_iton[i]] = i;
520:
521: current_gfs_plus1 = (int *)MALLOC(q*sizeof(int));
522: for ( i = 0; i < q1; i++ ) {
523: t = current_gfs_iton[i];
524: /* add 1 to the constant part */
525: t1 = (t/p)*p+((t+1)%p);
526: current_gfs_plus1[i] = current_gfs_ntoi[t1];
1.1 noro 527: }
528: }
529:
1.9 noro 530: int search_defpoly_and_primitive_root(int p,int n,UM dp)
1.6 noro 531: {
532: int l,min,max,mid,p1,i,ind,t;
533:
534: l = sizeof(prim_root_info_tab)/sizeof(struct prim_root_info);
535: min = 0; max = l-1;
536: ind = -1;
537: while ( max - min > 1 ) {
538: mid = (max+min)/2;
539: p1 = prim_root_info_tab[mid].p;
540: if ( p1 == p ) {
541: ind = mid; break;
542: } else if ( p1 > p )
543: max = mid;
544: else
545: min = mid;
546: }
547: if ( ind < 0 ) {
548: if ( prim_root_info_tab[min].p == p )
549: ind = min;
550: else if ( prim_root_info_tab[max].p == p )
551: ind = max;
552: else
553: return 0; /* XXX */
554: }
555: /* now prim_root_info_tab[ind].p = p */
556: t = ind - (prim_root_info_tab[ind].extdeg-1);
557: /* now prim_root_info_tab[t].extdeg = 1 */
558: for ( i = t; prim_root_info_tab[i].p == p; i++ )
559: if ( prim_root_info_tab[i].extdeg == n )
560: break;
561: if ( prim_root_info_tab[i].p != p )
562: return 0;
563: dec_um(p,prim_root_info_tab[i].defpoly,dp);
564: return prim_root_info_tab[i].prim_root;
565: }
566:
1.9 noro 567: void generate_defpoly_um(int p,int n,UM dp)
1.1 noro 568: {
1.9 noro 569: int i,j,a,q;
1.2 noro 570: UM wf,wdf,wgcd;
1.1 noro 571:
1.2 noro 572: wf = W_UMALLOC(n);
573: wdf = W_UMALLOC(n);
574: wgcd = W_UMALLOC(n);
575: COEF(dp)[n] = 1;
576: DEG(dp) = n;
577: for ( i = 0, q = 1; i < n; i++ )
578: q *= p;
579: for ( i = 0; i < q; i++ ) {
580: for ( j = 0, a = i; a; j++, a /= p )
581: COEF(dp)[j] = a%p;
582: for ( ; j < n; j++ )
583: COEF(dp)[j] = 0;
584: cpyum(dp,wf);
585: diffum(p,dp,wdf);
586: gcdum(p,wf,wdf,wgcd);
587: if ( DEG(wgcd) >= 1 )
588: continue;
589: mini(p,dp,wf);
590: if ( DEG(wf) <= 0 )
591: return;
592: }
593: }
594:
1.9 noro 595: int generate_primitive_root_enc(int p,int n,UM dp)
1.2 noro 596: {
597: int i,r,rj,j,q;
598:
1.5 noro 599: if ( p == 2 && n == 1 )
600: return 1;
601:
1.2 noro 602: for ( i = 0, q = 1; i < n; i++ )
603: q *= p;
604: for ( r = n==1?2:p; r < q; r++ ) {
1.1 noro 605: rj = r;
1.2 noro 606: for ( j = 1; j < q-1 && rj != 1; j++ )
607: rj = mulremum_enc(p,n,dp,rj,r);
608: if ( j == q-1 )
1.1 noro 609: return r;
610: }
1.9 noro 611: /* not found */
612: return 0;
1.2 noro 613: }
614:
615: /* [a(p)]*[b(p)] in GF(p^n) -> [a(x)*b(x) mod dp(x)]_{x->p} */
616:
1.9 noro 617: int mulremum_enc(int p,int n,UM dp,int a,int b)
1.2 noro 618: {
619: int i,dr,r;
620: UM wa,wb,wc,wq;
621:
622: if ( n == 1 )
623: return (a*b)%p;
624: if ( !a || !b )
625: return 0;
626:
627: wa = W_UMALLOC(n);
628: dec_um(p,a,wa);
629:
630: wb = W_UMALLOC(n);
631: dec_um(p,b,wb);
632:
633: wc = W_UMALLOC(2*n);
634: wq = W_UMALLOC(2*n);
635: mulum(p,wa,wb,wc);
636: dr = divum(p,wc,dp,wq);
637: for ( i = dr, r = 0; i >= 0; i-- )
638: r = r*p+COEF(wc)[i];
639: return r;
1.5 noro 640: }
641:
1.10 ! noro 642: /* sigma : alpha -> alpha^q */
! 643:
1.9 noro 644: void gfs_galois_action(GFS a,Q e,GFS *c)
1.5 noro 645: {
1.10 ! noro 646: Q q;
1.5 noro 647: int i,k;
648: GFS t,s;
649:
650: t = a;
651: k = QTOS(e);
1.10 ! noro 652: STOQ(current_gfs_q,q);
1.5 noro 653: for ( i = 0; i < k; i++ ) {
1.10 ! noro 654: pwrgfs(t,q,&s); t = s;
1.5 noro 655: }
656: *c = t;
657: }
658:
1.8 noro 659: /* GF(pn)={0,1,a,a^2,...} -> GF(pm)={0,1,b,b^2,...}; a->b^k */
660:
1.9 noro 661: void gfs_embed(GFS z,int k,int pm,GFS *c)
1.8 noro 662: {
663: int t;
664:
665: if ( !z )
666: *c = 0;
667: else {
668: t = dmar(k,CONT(z),0,pm-1);
669: MKGFS(t,*c);
670: }
671: }
1.9 noro 672:
673: void qtogfs(Q a,GFS *c)
1.5 noro 674: {
675: int s;
676:
677: s = QTOS(a)%current_gfs_q;
678: if ( s < 0 )
679: s += current_gfs_q;
680: if ( !s )
681: *c = 0;
682: else
683: MKGFS(current_gfs_ntoi[s],*c);
1.1 noro 684: }
685:
1.9 noro 686: void mqtogfs(MQ a,GFS *c)
1.1 noro 687: {
688: if ( !a )
689: *c = 0;
690: else {
691: MKGFS(current_gfs_ntoi[CONT(a)],*c);
692: }
693: }
694:
1.9 noro 695: void gfstomq(GFS a,MQ *c)
1.1 noro 696: {
697: if ( !a )
698: *c = 0;
699: else {
700: UTOMQ(current_gfs_iton[CONT(a)],*c);
701: }
702: }
703:
1.9 noro 704: void ntogfs(Obj a,GFS *b)
1.1 noro 705: {
706: P t;
707:
708: if ( !current_gfs_q1 )
709: error("addgfs : current_gfs_q is not set");
710: if ( !a || (OID(a)==O_N && NID(a) == N_GFS) )
711: *b = (GFS)a;
712: else if ( OID(a) == O_N && NID(a) == N_M )
1.9 noro 713: mqtogfs((MQ)a,b);
1.1 noro 714: else if ( OID(a) == O_N && NID(a) == N_Q ) {
1.9 noro 715: ptomp(current_gfs_p,(P)a,&t); mqtogfs((MQ)t,b);
1.1 noro 716: } else
717: error("ntogfs : invalid argument");
718: }
719:
1.9 noro 720: void addgfs(GFS a,GFS b,GFS *c)
1.1 noro 721: {
722: int ai,bi,ci;
723: GFS z;
724:
1.9 noro 725: ntogfs((Obj)a,&z); a = z;
726: ntogfs((Obj)b,&z); b = z;
1.1 noro 727: if ( !a )
728: *c = b;
729: else if ( !b )
730: *c = a;
731: else {
732: ai = CONT(a); bi = CONT(b);
733: if ( ai > bi ) {
734: /* tab[ai]+tab[bi] = tab[bi](tab[ai-bi]+1) */
735: ci = current_gfs_plus1[ai-bi];
736: if ( ci < 0 )
737: *c = 0;
738: else {
739: ci += bi;
740: if ( ci >= current_gfs_q1 )
741: ci -= current_gfs_q1;
742: MKGFS(ci,*c);
743: }
744: } else {
745: /* tab[ai]+tab[bi] = tab[ai](tab[bi-ai]+1) */
746: ci = current_gfs_plus1[bi-ai];
747: if ( ci < 0 )
748: *c = 0;
749: else {
750: ci += ai;
751: if ( ci >= current_gfs_q1 )
752: ci -= current_gfs_q1;
753: MKGFS(ci,*c);
754: }
755: }
756: }
757: }
758:
1.9 noro 759: void subgfs(GFS a,GFS b,GFS *c)
1.1 noro 760: {
761: GFS t,z;
762:
1.9 noro 763: ntogfs((Obj)a,&z); a = z;
764: ntogfs((Obj)b,&z); b = z;
1.1 noro 765: if ( !b )
766: *c = a;
767: else {
768: chsgngfs(b,&t);
769: addgfs(a,t,c);
770: }
771: }
772:
1.9 noro 773: void mulgfs(GFS a,GFS b,GFS *c)
1.1 noro 774: {
775: int ai;
776: GFS z;
777:
1.9 noro 778: ntogfs((Obj)a,&z); a = z;
779: ntogfs((Obj)b,&z); b = z;
1.1 noro 780: if ( !a || !b )
781: *c = 0;
782: else {
783: ai = CONT(a) + CONT(b);
784: if ( ai >= current_gfs_q1 )
785: ai -= current_gfs_q1;
786: MKGFS(ai,*c);
787: }
788: }
789:
1.9 noro 790: void divgfs(GFS a,GFS b,GFS *c)
1.1 noro 791: {
792: int ai;
793: GFS z;
794:
1.9 noro 795: ntogfs((Obj)a,&z); a = z;
796: ntogfs((Obj)b,&z); b = z;
1.1 noro 797: if ( !b )
798: error("divgfs : division by 0");
799: else if ( !a )
800: *c = 0;
801: else {
802: ai = CONT(a) - CONT(b);
803: if ( ai < 0 )
804: ai += current_gfs_q1;
805: MKGFS(ai,*c);
806: }
807: }
808:
1.9 noro 809: void chsgngfs(GFS a,GFS *c)
1.1 noro 810: {
811: int ai;
812: GFS z;
813:
1.9 noro 814: ntogfs((Obj)a,&z); a = z;
1.1 noro 815: if ( !a )
816: *c = 0;
817: else if ( current_gfs_q1&1 )
818: *c = a;
819: else {
820: /* r^((q-1)/2) = -1 */
821: ai = CONT(a)+(current_gfs_q1>>1);
822: if ( ai >= current_gfs_q1 )
823: ai -= current_gfs_q1;
824: MKGFS(ai,*c);
825: }
826: }
827:
1.9 noro 828: void pwrgfs(GFS a,Q b,GFS *c)
1.1 noro 829: {
830: N an,tn,rn;
831: GFS t,s,z;
832:
1.9 noro 833: ntogfs((Obj)a,&z); a = z;
1.1 noro 834: if ( !b )
835: MKGFS(0,*c);
836: else if ( !a )
837: *c = 0;
838: else {
839: STON(CONT(a),an); muln(an,NM(b),&tn);
840: STON(current_gfs_q1,an); remn(tn,an,&rn);
841: if ( !rn )
842: MKGFS(0,*c);
843: else if ( SGN(b) > 0 )
844: MKGFS(BD(rn)[0],*c);
845: else {
846: MKGFS(0,t);
847: MKGFS(BD(rn)[0],s);
848: divgfs(t,s,c);
849: }
850: }
851: }
852:
1.9 noro 853: int cmpgfs(GFS a,GFS b)
1.1 noro 854: {
855: GFS z;
856:
1.9 noro 857: ntogfs((Obj)a,&z); a = z;
1.1 noro 858: if ( !a )
859: return !b ? 0 : -1;
860: else
861: if ( !b )
862: return 1;
863: else {
864: if ( CONT(a) > CONT(b) )
865: return 1;
866: else if ( CONT(a) < CONT(b) )
867: return -1;
868: else
869: return 0;
870: }
1.3 noro 871: }
872:
1.9 noro 873: void randomgfs(GFS *r)
1.3 noro 874: {
875: unsigned int t;
876:
877: if ( !current_gfs_q1 )
878: error("addgfs : current_gfs_q is not set");
879: t = mt_genrand()%current_gfs_q;
880: if ( !t )
881: *r = 0;
882: else {
1.9 noro 883: if ( t == (unsigned int)current_gfs_q1 )
1.3 noro 884: t = 0;
885: MKGFS(t,*r);
886: }
1.1 noro 887: }
1.6 noro 888:
889: /* arithmetic operations for 'immediate values of GFS */
890:
1.9 noro 891: int _addsf(int a,int b)
1.6 noro 892: {
893: if ( !a )
894: return b;
895: else if ( !b )
896: return a;
897:
898: a = IFTOF(a); b = IFTOF(b);
899: if ( a > b ) {
900: /* tab[a]+tab[b] = tab[b](tab[a-b]+1) */
901: a = current_gfs_plus1[a-b];
902: if ( a < 0 )
903: return 0;
904: else {
905: a += b;
906: if ( a >= current_gfs_q1 )
907: a -= current_gfs_q1;
908: return FTOIF(a);
909: }
910: } else {
911: /* tab[a]+tab[b] = tab[a](tab[b-a]+1) */
912: b = current_gfs_plus1[b-a];
913: if ( b < 0 )
914: return 0;
915: else {
916: b += a;
917: if ( b >= current_gfs_q1 )
918: b -= current_gfs_q1;
919: return FTOIF(b);
920: }
921: }
922: }
923:
1.9 noro 924: int _chsgnsf(int a)
1.6 noro 925: {
926: if ( !a )
927: return 0;
928: else if ( current_gfs_q1&1 )
929: return a;
930: else {
931: /* r^((q-1)/2) = -1 */
932: a = IFTOF(a);
933: a += (current_gfs_q1>>1);
934: if ( a >= current_gfs_q1 )
935: a -= current_gfs_q1;
936: return FTOIF(a);
937: }
938: }
939:
1.9 noro 940: int _subsf(int a,int b)
1.6 noro 941: {
942: if ( !a )
943: return _chsgnsf(b);
944: else if ( !b )
945: return a;
946: else
947: return _addsf(a,_chsgnsf(b));
948: }
949:
1.9 noro 950: int _mulsf(int a,int b)
1.6 noro 951: {
952: if ( !a || !b )
953: return 0;
954: else {
955: a = IFTOF(a) + IFTOF(b);
956: if ( a >= current_gfs_q1 )
957: a -= current_gfs_q1;
958: return FTOIF(a);
959: }
960: }
961:
1.9 noro 962: int _invsf(int a)
1.6 noro 963: {
1.9 noro 964: if ( !a ) {
1.6 noro 965: error("_invsf : division by 0");
1.9 noro 966: /* NOTREACHED */
967: return -1;
968: } else {
1.6 noro 969: a = current_gfs_q1 - IFTOF(a);
970: return FTOIF(a);
971: }
972: }
973:
1.9 noro 974: int _divsf(int a,int b)
1.6 noro 975: {
1.9 noro 976: if ( !b ) {
1.6 noro 977: error("_divsf : division by 0");
1.9 noro 978: /* NOTREACHED */
979: return -1;
980: } else if ( !a )
1.6 noro 981: return 0;
982: else {
983: a = IFTOF(a) - IFTOF(b);
984: if ( a < 0 )
985: a += current_gfs_q1;
986: return FTOIF(a);
987: }
988: }
989:
1.9 noro 990: int _pwrsf(int a,int b)
1.6 noro 991: {
992: GFS at,ct;
993: Q bt;
994: int c;
995:
996: if ( !b )
997: return _onesf();
998: else if ( !a )
999: return 0;
1000: else {
1001: a = IFTOF(a);
1002: MKGFS(a,at);
1003: STOQ(b,bt);
1004: pwrgfs(at,bt,&ct);
1005: c = CONT(ct);
1006: return FTOIF(c);
1007: }
1008: }
1009:
1010: int _onesf()
1011: {
1012: return FTOIF(0);
1013: }
1014:
1.9 noro 1015: int _itosf(int n)
1.6 noro 1016: {
1017: int i;
1018:
1019: n %= current_gfs_p;
1020: if ( !n )
1021: return 0;
1022: i = current_gfs_ntoi[n];
1023: i = FTOIF(i);
1024: if ( n < 0 )
1025: i = _chsgnsf(i);
1026: return i;
1027: }
1028:
1.9 noro 1029: int _isonesf(int a)
1.6 noro 1030: {
1031: return a == FTOIF(0);
1032: }
1033:
1034: int _randomsf()
1035: {
1036: int t;
1037:
1038: t = (int) (mt_genrand() % current_gfs_q1);
1039: if ( !t )
1040: return 0;
1041: else
1042: return FTOIF(t);
1043: }
1044:
1045: int field_order_sf()
1046: {
1047: return current_gfs_q;
1048: }
1049:
1050: int characteristic_sf()
1051: {
1052: return current_gfs_p;
1053: }
1054:
1.7 noro 1055: int extdeg_sf()
1056: {
1057: return UDEG(current_gfs_ext);
1058: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>