-
Notifications
You must be signed in to change notification settings - Fork 0
/
field2n.h
59 lines (46 loc) · 1.09 KB
/
field2n.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*** field2n.h ***/
#define WORDSIZE (sizeof(int)*8)
#define NUMBITS 113
#define TYPE2
/*#undef TYPE2 */
#ifdef TYPE2
#define field_prime ((NUMBITS<<1)+1)
#else
#define field_prime (NUMBITS+1)
#endif
#define NUMWORD (NUMBITS/WORDSIZE)
#define UPRSHIFT (NUMBITS%WORDSIZE)
#define MAXLONG (NUMWORD+1)
#define MAXBITS (MAXLONG*WORDSIZE)
#define MAXSHIFT (WORDSIZE-1)
#define MSB (1L<<MAXSHIFT)
#define UPRBIT (1L<<(UPRSHIFT-1))
#define UPRMASK (~(-1L<<UPRSHIFT))
#define SUMLOOP(i) for(i=0; i<MAXLONG; i++)
#define LONGWORD (field_prime/WORDSIZE)
#define LONGSHIFT ((field_prime-1)%WORDSIZE)
#define LONGBIT (1L<<(LONGSHIFT-1))
#define LONGMASK (~(-1L<<LONGSHIFT))
typedef short int INDEX;
typedef unsigned long ELEMENT;
typedef struct {
ELEMENT e[MAXLONG];
} FIELD2N;
typedef struct {
ELEMENT e[LONGWORD+1];
} CUSTFIELD;
/* prototypes */
void rot_left();
void rot_right();
void null();
void copy();
void null_cust();
void copy_cust ();
void genlambda();
void genlambda2();
void opt_mul();
void opt_inv();
INDEX log_2();
void one();
void cus_times_u_to_n();
void init_opt_math();