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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#![allow(non_camel_case_types)]

//! *See the [FLINT documentation](http://flintlib.org/doc/fq_nmod.html).

use crate::deps::*;
use crate::flint::*;
use crate::fmpz::fmpz;
use crate::nmod_mat::nmod_mat_struct;
use crate::nmod_poly::{nmod_poly_struct, nmod_poly_t};
use crate::nmod_vec::nmod_t;
use libc::{c_char, c_int, FILE};

pub type fq_nmod_t = nmod_poly_t;
pub type fq_nmod_struct = nmod_poly_struct;

#[repr(C)]
#[derive(Debug, Copy, Clone, Hash)]
pub struct fq_nmod_ctx_struct {
    pub p: fmpz,
    pub mod_: nmod_t,
    pub sparse_modulus: c_int,
    pub is_conway: c_int,
    pub a: *mut mp_limb_t,
    pub j: *mut mp_limb_signed_t,
    pub len: mp_limb_signed_t,
    pub modulus: nmod_poly_t,
    pub inv: nmod_poly_t,
    pub var: *mut c_char,
}

pub type fq_nmod_ctx_t = [fq_nmod_ctx_struct; 1usize];

extern "C" {
    pub fn fq_nmod_ctx_init(
        ctx: *mut fq_nmod_ctx_struct,
        p: *mut fmpz,
        d: mp_limb_signed_t,
        var: *const c_char,
    );
    pub fn _fq_nmod_ctx_init_conway(
        ctx: *mut fq_nmod_ctx_struct,
        p: *mut fmpz,
        d: mp_limb_signed_t,
        var: *const c_char,
    ) -> c_int;
    pub fn fq_nmod_ctx_init_conway(
        ctx: *mut fq_nmod_ctx_struct,
        p: *mut fmpz,
        d: mp_limb_signed_t,
        var: *const c_char,
    );
    pub fn fq_nmod_ctx_init_modulus(
        ctx: *mut fq_nmod_ctx_struct,
        modulus: *mut nmod_poly_struct,
        var: *const c_char,
    );
    pub fn fq_nmod_ctx_randtest(ctx: *mut fq_nmod_ctx_struct, state: *mut flint_rand_s);
    pub fn fq_nmod_ctx_randtest_reducible(ctx: *mut fq_nmod_ctx_struct, state: *mut flint_rand_s);
    pub fn fq_nmod_ctx_clear(ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_ctx_modulus(ctx: *mut fq_nmod_ctx_struct) -> *const nmod_poly_struct;
    pub fn fq_nmod_ctx_degree(ctx: *mut fq_nmod_ctx_struct) -> mp_limb_signed_t;
    pub fn fq_nmod_ctx_order(f: *mut fmpz, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_ctx_fprint(file: *mut FILE, ctx: *mut fq_nmod_ctx_struct) -> c_int;
    pub fn fq_nmod_ctx_print(ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_init(rop: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_init2(rop: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_clear(rop: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn _fq_nmod_sparse_reduce(
        R: *mut mp_limb_t,
        lenR: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn _fq_nmod_dense_reduce(
        R: *mut mp_limb_t,
        lenR: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn _fq_nmod_reduce(R: *mut mp_limb_t, lenR: mp_limb_signed_t, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_reduce(rop: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_add(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        op2: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_sub(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        op2: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_sub_one(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_neg(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_mul(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        op2: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_mul_fmpz(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        x: *mut fmpz,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_mul_si(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        x: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_mul_ui(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        x: mp_limb_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_sqr(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_inv(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn _fq_nmod_pow(
        rop: *mut mp_limb_t,
        op: *const mp_limb_t,
        len: mp_limb_signed_t,
        e: *mut fmpz,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_pow(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        e: *mut fmpz,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_pow_ui(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        e: mp_limb_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_sqrt(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> c_int;
    pub fn fq_nmod_pth_root(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_is_square(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct) -> c_int;
    pub fn fq_nmod_randtest(
        rop: *mut nmod_poly_struct,
        state: *mut flint_rand_s,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_randtest_dense(
        rop: *mut nmod_poly_struct,
        state: *mut flint_rand_s,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_randtest_not_zero(
        rop: *mut nmod_poly_struct,
        state: *mut flint_rand_s,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_rand(
        rop: *mut nmod_poly_struct,
        state: *mut flint_rand_s,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_rand_not_zero(
        rop: *mut nmod_poly_struct,
        state: *mut flint_rand_s,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_equal(
        op1: *mut nmod_poly_struct,
        op2: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> c_int;
    pub fn fq_nmod_is_zero(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct) -> c_int;
    pub fn fq_nmod_is_one(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct) -> c_int;
    pub fn fq_nmod_cmp(
        a: *mut nmod_poly_struct,
        b: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> c_int;
    pub fn fq_nmod_set(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_set_fmpz(rop: *mut nmod_poly_struct, x: *mut fmpz, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_set_si(
        rop: *mut nmod_poly_struct,
        x: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_set_ui(rop: *mut nmod_poly_struct, x: mp_limb_t, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_swap(
        op1: *mut nmod_poly_struct,
        op2: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_zero(rop: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_one(rop: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_gen(rop: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_get_nmod_poly(
        a: *mut nmod_poly_struct,
        b: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_set_nmod_poly(
        a: *mut nmod_poly_struct,
        b: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_fprint(
        file: *mut FILE,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> c_int;
    pub fn fq_nmod_print(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_fprint_pretty(
        file: *mut FILE,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> c_int;
    pub fn fq_nmod_print_pretty(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_get_str(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct) -> *mut c_char;
    pub fn fq_nmod_get_str_pretty(
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> *mut c_char;
    pub fn _fq_nmod_trace(
        rop: *mut fmpz,
        op: *const mp_limb_t,
        len: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_trace(rop: *mut fmpz, op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn _fq_nmod_frobenius(
        rop: *mut mp_limb_t,
        op: *const mp_limb_t,
        len: mp_limb_signed_t,
        e: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_frobenius(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        e: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn _fq_nmod_norm(
        rop: *mut fmpz,
        op: *const mp_limb_t,
        len: mp_limb_signed_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_norm(rop: *mut fmpz, op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_bit_pack(
        f: *mut fmpz,
        op: *mut nmod_poly_struct,
        bit_size: mp_limb_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_bit_unpack(
        rop: *mut nmod_poly_struct,
        f: *mut fmpz,
        bit_size: mp_limb_t,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn __fq_nmod_ctx_prime(p: *mut fmpz, ctx: *mut fq_nmod_ctx_struct);
    pub fn fq_nmod_gcdinv(
        rop: *mut nmod_poly_struct,
        inv: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_is_invertible(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct) -> c_int;
    pub fn fq_nmod_is_invertible_f(
        rop: *mut nmod_poly_struct,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> c_int;
    pub fn fq_nmod_div(
        rop: *mut nmod_poly_struct,
        op1: *mut nmod_poly_struct,
        op2: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_multiplicative_order(
        ord: *mut fmpz,
        op: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    ) -> c_int;
    pub fn fq_nmod_get_nmod_mat(
        col: *mut nmod_mat_struct,
        a: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_set_nmod_mat(
        a: *mut nmod_poly_struct,
        col: *mut nmod_mat_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_is_primitive(op: *mut nmod_poly_struct, ctx: *mut fq_nmod_ctx_struct) -> c_int;
}