8 |
object big_log_op(); |
object big_log_op(); |
9 |
object normalize_big(object); |
object normalize_big(object); |
10 |
|
|
11 |
object |
static object |
12 |
log_op(int (*op) (/* ??? */), void (*mp_op) (/* ??? */)) |
log_op(int (*op) (/* ??? */), void (*mp_op) (/* ??? */)) |
13 |
{ |
{ |
14 |
object x; |
object x; |
45 |
} |
} |
46 |
|
|
47 |
|
|
48 |
void |
static void |
49 |
mp_and_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_and_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
50 |
{ |
{ |
51 |
mpz_and(u,i,j); |
mpz_and(u,i,j); |
52 |
/* (i & j); */ |
/* (i & j); */ |
53 |
} |
} |
54 |
|
|
55 |
void |
static void |
56 |
mp_eqv_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_eqv_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
57 |
{ |
{ |
58 |
mpz_xor(u,i,j); |
mpz_xor(u,i,j); |
61 |
|
|
62 |
} |
} |
63 |
|
|
64 |
void |
static void |
65 |
mp_nand_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_nand_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
66 |
{ |
{ |
67 |
mpz_and(u,i,j); |
mpz_and(u,i,j); |
69 |
/* (~(i & j)); */ |
/* (~(i & j)); */ |
70 |
} |
} |
71 |
|
|
72 |
void |
static void |
73 |
mp_nor_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_nor_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
74 |
{ |
{ |
75 |
/* mpz_ior(u,u,j); */ |
/* mpz_ior(u,u,j); */ |
79 |
/* (~(i | j)); */ |
/* (~(i | j)); */ |
80 |
} |
} |
81 |
|
|
82 |
void |
static void |
83 |
mp_andc1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_andc1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
84 |
{ |
{ |
85 |
mpz_com(i,i); |
mpz_com(i,i); |
87 |
/* ((~i) & j); */ |
/* ((~i) & j); */ |
88 |
} |
} |
89 |
|
|
90 |
void |
static void |
91 |
mp_andc2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_andc2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
92 |
{ |
{ |
93 |
mpz_com(j,j); |
mpz_com(j,j); |
95 |
/* (i & (~j));*/ |
/* (i & (~j));*/ |
96 |
} |
} |
97 |
|
|
98 |
void |
static void |
99 |
mp_orc1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_orc1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
100 |
{ |
{ |
101 |
mpz_com(i,i); |
mpz_com(i,i); |
103 |
/* ((~i) | j); */ |
/* ((~i) | j); */ |
104 |
} |
} |
105 |
|
|
106 |
void |
static void |
107 |
mp_orc2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_orc2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
108 |
{ |
{ |
109 |
mpz_com(j,j); |
mpz_com(j,j); |
111 |
/* (i | (~j)); */ |
/* (i | (~j)); */ |
112 |
} |
} |
113 |
|
|
114 |
void |
static void |
115 |
mp_b_clr_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_b_clr_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
116 |
{ |
{ |
117 |
mpz_set_si(u,0); |
mpz_set_si(u,0); |
118 |
/* (0); */ |
/* (0); */ |
119 |
} |
} |
120 |
|
|
121 |
void |
static void |
122 |
mp_b_set_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_b_set_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
123 |
{ |
{ |
124 |
mpz_set_si(u,-1); |
mpz_set_si(u,-1); |
125 |
/* (-1); */ |
/* (-1); */ |
126 |
} |
} |
127 |
|
|
128 |
void |
static void |
129 |
mp_b_1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_b_1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
130 |
{ |
{ |
131 |
mpz_set(u,i); |
mpz_set(u,i); |
132 |
/* (i); */ |
/* (i); */ |
133 |
} |
} |
134 |
|
|
135 |
void |
static void |
136 |
mp_b_2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_b_2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
137 |
{ |
{ |
138 |
mpz_set(u,j); |
mpz_set(u,j); |
139 |
/* (j); */ |
/* (j); */ |
140 |
} |
} |
141 |
|
|
142 |
void |
static void |
143 |
mp_b_c1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_b_c1_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
144 |
{ |
{ |
145 |
mpz_com(u,i); |
mpz_com(u,i); |
146 |
/* (~i); */ |
/* (~i); */ |
147 |
} |
} |
148 |
|
|
149 |
void |
static void |
150 |
mp_b_c2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_b_c2_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
151 |
{ |
{ |
152 |
mpz_com(u,j); |
mpz_com(u,j); |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
int |
static int |
160 |
big_bitp(object x, int p) |
big_bitp(object x, int p) |
161 |
{ |
{ |
162 |
return mpz_tstbit(MP(x),p); |
return mpz_tstbit(MP(x),p); |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
void |
static void |
170 |
mp_ior_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_ior_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
171 |
{ |
{ |
172 |
mpz_ior(u,i,j); |
mpz_ior(u,i,j); |
173 |
/* (i | j); */ |
/* (i | j); */ |
174 |
} |
} |
175 |
|
|
176 |
void |
static void |
177 |
mp_xor_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
mp_xor_op(__mpz_struct *u, __mpz_struct *i, __mpz_struct *j) |
178 |
{ |
{ |
179 |
mpz_xor(u,i,j); |
mpz_xor(u,i,j); |
180 |
/* (i ^ j); */ |
/* (i ^ j); */ |
181 |
} |
} |
182 |
|
|
183 |
int |
static int |
184 |
mpz_bitcount(__mpz_struct *x) |
mpz_bitcount(__mpz_struct *x) |
185 |
{ |
{ |
186 |
if (mpz_sgn(x) >= 0) { |
if (mpz_sgn(x) >= 0) { |
193 |
} |
} |
194 |
|
|
195 |
|
|
196 |
int |
static int |
197 |
mpz_bitlength(__mpz_struct *x) |
mpz_bitlength(__mpz_struct *x) |
198 |
{ |
{ |
199 |
if (mpz_sgn(x) >= 0) { |
if (mpz_sgn(x) >= 0) { |