flint_sys/
fmpz_mod.rs

1#![allow(non_camel_case_types)]
2
3//! See the [FLINT documentation](http://flintlib.org/doc/fmpz_mod.html).
4
5use crate::deps::*;
6use crate::flint::*;
7use crate::fmpz::{fmpz, fmpz_t};
8use crate::nmod_vec::nmod_t;
9
10#[repr(C)]
11#[derive(Debug, Copy, Clone)]
12pub struct fmpz_mod_ctx {
13    pub n: fmpz_t,
14    pub add_fxn: ::std::option::Option<
15        unsafe extern "C" fn(
16            arg1: *mut fmpz,
17            arg2: *mut fmpz,
18            arg3: *mut fmpz,
19            arg4: *const fmpz_mod_ctx,
20        ),
21    >,
22    pub sub_fxn: ::std::option::Option<
23        unsafe extern "C" fn(
24            arg1: *mut fmpz,
25            arg2: *mut fmpz,
26            arg3: *mut fmpz,
27            arg4: *const fmpz_mod_ctx,
28        ),
29    >,
30    pub mul_fxn: ::std::option::Option<
31        unsafe extern "C" fn(
32            arg1: *mut fmpz,
33            arg2: *mut fmpz,
34            arg3: *mut fmpz,
35            arg4: *const fmpz_mod_ctx,
36        ),
37    >,
38    pub mod_: nmod_t,
39    pub n_limbs: [mp_limb_t; 3usize],
40    pub ninv_limbs: [mp_limb_t; 3usize],
41}
42pub type fmpz_mod_ctx_struct = fmpz_mod_ctx;
43pub type fmpz_mod_ctx_t = [fmpz_mod_ctx_struct; 1usize];
44extern "C" {
45    pub fn fmpz_mod_ctx_init(ctx: *mut fmpz_mod_ctx_struct, n: *const fmpz);
46}
47extern "C" {
48    pub fn fmpz_mod_ctx_init_ui(ctx: *mut fmpz_mod_ctx_struct, n: mp_limb_t);
49}
50extern "C" {
51    pub fn fmpz_mod_ctx_clear(ctx: *mut fmpz_mod_ctx_struct);
52}
53extern "C" {
54    pub fn fmpz_mod_ctx_modulus(ctx: *const fmpz_mod_ctx_struct) -> *const fmpz;
55}
56extern "C" {
57    pub fn fmpz_mod_ctx_get_modulus_mpz_read_only(
58        m: *mut __mpz_struct,
59        ctx: *const fmpz_mod_ctx_struct,
60    );
61}
62extern "C" {
63    pub fn fmpz_mod_ctx_set_modulus(ctx: *mut fmpz_mod_ctx_struct, n: *const fmpz);
64}
65extern "C" {
66    pub fn fmpz_mod_ctx_set_modulus_ui(ctx: *mut fmpz_mod_ctx_struct, n: mp_limb_t);
67}
68extern "C" {
69    pub fn fmpz_mod_is_canonical(
70        a: *const fmpz,
71        ctx: *const fmpz_mod_ctx_struct,
72    ) -> ::std::os::raw::c_int;
73}
74extern "C" {
75    pub fn fmpz_mod_assert_canonical(a: *const fmpz, ctx: *const fmpz_mod_ctx_struct);
76}
77extern "C" {
78    pub fn fmpz_mod_is_one(
79        a: *const fmpz,
80        ctx: *const fmpz_mod_ctx_struct,
81    ) -> ::std::os::raw::c_int;
82}
83extern "C" {
84    pub fn fmpz_mod_equal_fmpz(
85        a: *const fmpz,
86        b: *const fmpz,
87        ctx: *const fmpz_mod_ctx_struct,
88    ) -> ::std::os::raw::c_int;
89}
90extern "C" {
91    pub fn fmpz_mod_equal_si(
92        a: *const fmpz,
93        b: mp_limb_signed_t,
94        ctx: *const fmpz_mod_ctx_struct,
95    ) -> ::std::os::raw::c_int;
96}
97extern "C" {
98    pub fn fmpz_mod_set_fmpz(a: *mut fmpz, b: *const fmpz, ctx: *const fmpz_mod_ctx_struct);
99}
100extern "C" {
101    pub fn fmpz_mod_set_ui(a: *mut fmpz, b: mp_limb_t, ctx: *const fmpz_mod_ctx_struct);
102}
103extern "C" {
104    pub fn fmpz_mod_set_si(a: *mut fmpz, b: mp_limb_signed_t, ctx: *const fmpz_mod_ctx_struct);
105}
106extern "C" {
107    pub fn _fmpz_mod_add1(
108        a: *mut fmpz,
109        b: *const fmpz,
110        c: *const fmpz,
111        ctx: *const fmpz_mod_ctx_struct,
112    );
113}
114extern "C" {
115    pub fn _fmpz_mod_add2s(
116        a: *mut fmpz,
117        b: *const fmpz,
118        c: *const fmpz,
119        ctx: *const fmpz_mod_ctx_struct,
120    );
121}
122extern "C" {
123    pub fn _fmpz_mod_add2(
124        a: *mut fmpz,
125        b: *const fmpz,
126        c: *const fmpz,
127        ctx: *const fmpz_mod_ctx_struct,
128    );
129}
130extern "C" {
131    pub fn _fmpz_mod_addN(
132        a: *mut fmpz,
133        b: *const fmpz,
134        c: *const fmpz,
135        ctx: *const fmpz_mod_ctx_struct,
136    );
137}
138extern "C" {
139    pub fn fmpz_mod_add(
140        a: *mut fmpz,
141        b: *const fmpz,
142        c: *const fmpz,
143        ctx: *const fmpz_mod_ctx_struct,
144    );
145}
146extern "C" {
147    pub fn fmpz_mod_add_fmpz(
148        a: *mut fmpz,
149        b: *const fmpz,
150        c: *const fmpz,
151        ctx: *const fmpz_mod_ctx_struct,
152    );
153}
154extern "C" {
155    pub fn fmpz_mod_add_ui(
156        a: *mut fmpz,
157        b: *const fmpz,
158        c: mp_limb_t,
159        ctx: *const fmpz_mod_ctx_struct,
160    );
161}
162extern "C" {
163    pub fn fmpz_mod_add_si(
164        a: *mut fmpz,
165        b: *const fmpz,
166        c: mp_limb_signed_t,
167        ctx: *const fmpz_mod_ctx_struct,
168    );
169}
170extern "C" {
171    pub fn _fmpz_mod_sub1(
172        a: *mut fmpz,
173        b: *const fmpz,
174        c: *const fmpz,
175        ctx: *const fmpz_mod_ctx_struct,
176    );
177}
178extern "C" {
179    pub fn _fmpz_mod_sub2s(
180        a: *mut fmpz,
181        b: *const fmpz,
182        c: *const fmpz,
183        ctx: *const fmpz_mod_ctx_struct,
184    );
185}
186extern "C" {
187    pub fn _fmpz_mod_sub2(
188        a: *mut fmpz,
189        b: *const fmpz,
190        c: *const fmpz,
191        ctx: *const fmpz_mod_ctx_struct,
192    );
193}
194extern "C" {
195    pub fn _fmpz_mod_subN(
196        a: *mut fmpz,
197        b: *const fmpz,
198        c: *const fmpz,
199        ctx: *const fmpz_mod_ctx_struct,
200    );
201}
202extern "C" {
203    pub fn fmpz_mod_sub(
204        a: *mut fmpz,
205        b: *const fmpz,
206        c: *const fmpz,
207        ctx: *const fmpz_mod_ctx_struct,
208    );
209}
210extern "C" {
211    pub fn fmpz_mod_sub_fmpz(
212        a: *mut fmpz,
213        b: *const fmpz,
214        c: *const fmpz,
215        ctx: *const fmpz_mod_ctx_struct,
216    );
217}
218extern "C" {
219    pub fn fmpz_mod_sub_ui(
220        a: *mut fmpz,
221        b: *const fmpz,
222        c: mp_limb_t,
223        ctx: *const fmpz_mod_ctx_struct,
224    );
225}
226extern "C" {
227    pub fn fmpz_mod_sub_si(
228        a: *mut fmpz,
229        b: *const fmpz,
230        c: mp_limb_signed_t,
231        ctx: *const fmpz_mod_ctx_struct,
232    );
233}
234extern "C" {
235    pub fn fmpz_mod_fmpz_sub(
236        a: *mut fmpz,
237        b: *const fmpz,
238        c: *const fmpz,
239        ctx: *const fmpz_mod_ctx_struct,
240    );
241}
242extern "C" {
243    pub fn fmpz_mod_ui_sub(
244        a: *mut fmpz,
245        b: mp_limb_t,
246        c: *const fmpz,
247        ctx: *const fmpz_mod_ctx_struct,
248    );
249}
250extern "C" {
251    pub fn fmpz_mod_si_sub(
252        a: *mut fmpz,
253        b: mp_limb_signed_t,
254        c: *const fmpz,
255        ctx: *const fmpz_mod_ctx_struct,
256    );
257}
258extern "C" {
259    pub fn fmpz_mod_neg(a: *mut fmpz, b: *const fmpz, ctx: *const fmpz_mod_ctx_struct);
260}
261extern "C" {
262    pub fn _fmpz_mod_mul1(
263        a: *mut fmpz,
264        b: *const fmpz,
265        c: *const fmpz,
266        ctx: *const fmpz_mod_ctx_struct,
267    );
268}
269extern "C" {
270    pub fn _fmpz_mod_mul2s(
271        a: *mut fmpz,
272        b: *const fmpz,
273        c: *const fmpz,
274        ctx: *const fmpz_mod_ctx_struct,
275    );
276}
277extern "C" {
278    pub fn _fmpz_mod_mul2(
279        a: *mut fmpz,
280        b: *const fmpz,
281        c: *const fmpz,
282        ctx: *const fmpz_mod_ctx_struct,
283    );
284}
285extern "C" {
286    pub fn _fmpz_mod_mulN(
287        a: *mut fmpz,
288        b: *const fmpz,
289        c: *const fmpz,
290        ctx: *const fmpz_mod_ctx_struct,
291    );
292}
293extern "C" {
294    pub fn fmpz_mod_mul(
295        a: *mut fmpz,
296        b: *const fmpz,
297        c: *const fmpz,
298        ctx: *const fmpz_mod_ctx_struct,
299    );
300}
301extern "C" {
302    pub fn fmpz_mod_addmul(
303        a: *mut fmpz,
304        b: *const fmpz,
305        c: *const fmpz,
306        d: *const fmpz,
307        ctx: *const fmpz_mod_ctx_struct,
308    );
309}
310extern "C" {
311    pub fn fmpz_mod_mul_fmpz(
312        a: *mut fmpz,
313        b: *const fmpz,
314        c: *const fmpz,
315        ctx: *const fmpz_mod_ctx_struct,
316    );
317}
318extern "C" {
319    pub fn fmpz_mod_mul_ui(
320        a: *mut fmpz,
321        b: *const fmpz,
322        c: mp_limb_t,
323        ctx: *const fmpz_mod_ctx_struct,
324    );
325}
326extern "C" {
327    pub fn fmpz_mod_mul_si(
328        a: *mut fmpz,
329        b: *const fmpz,
330        c: mp_limb_signed_t,
331        ctx: *const fmpz_mod_ctx_struct,
332    );
333}
334extern "C" {
335    pub fn fmpz_mod_is_invertible(
336        a: *const fmpz,
337        ctx: *const fmpz_mod_ctx_struct,
338    ) -> ::std::os::raw::c_int;
339}
340extern "C" {
341    pub fn fmpz_mod_inv(a: *mut fmpz, b: *const fmpz, ctx: *const fmpz_mod_ctx_struct);
342}
343extern "C" {
344    pub fn fmpz_mod_divides(
345        a: *const fmpz,
346        b: *const fmpz,
347        c: *const fmpz,
348        ctx: *const fmpz_mod_ctx_struct,
349    ) -> ::std::os::raw::c_int;
350}
351extern "C" {
352    pub fn fmpz_mod_pow_ui(
353        a: *mut fmpz,
354        b: *const fmpz,
355        pow: mp_limb_t,
356        ctx: *const fmpz_mod_ctx_struct,
357    );
358}
359extern "C" {
360    pub fn fmpz_mod_pow_fmpz(
361        a: *mut fmpz,
362        b: *const fmpz,
363        pow: *const fmpz,
364        ctx: *const fmpz_mod_ctx_struct,
365    ) -> ::std::os::raw::c_int;
366}
367extern "C" {
368    pub fn fmpz_mod_rand(a: *mut fmpz, state: *const flint_rand_s, ctx: *const fmpz_mod_ctx_struct);
369}
370extern "C" {
371    pub fn fmpz_mod_rand_not_zero(
372        a: *mut fmpz,
373        state: *const flint_rand_s,
374        ctx: *const fmpz_mod_ctx_struct,
375    );
376}
377#[repr(C)]
378#[derive(Debug, Copy, Clone)]
379pub struct fmpz_mod_discrete_log_pohlig_hellman_table_entry_struct {
380    pub gammapow: fmpz_t,
381    pub cm: mp_limb_t,
382}
383#[repr(C)]
384#[derive(Debug, Copy, Clone)]
385pub struct fmpz_mod_discrete_log_pohlig_hellman_entry_struct {
386    pub exp: mp_limb_signed_t,
387    pub prime: mp_limb_t,
388    pub gamma: fmpz_t,
389    pub gammainv: fmpz_t,
390    pub startingbeta: fmpz_t,
391    pub co: fmpz_t,
392    pub startinge: fmpz_t,
393    pub idem: fmpz_t,
394    pub cbound: mp_limb_t,
395    pub dbound: mp_limb_t,
396    pub table: *mut fmpz_mod_discrete_log_pohlig_hellman_table_entry_struct,
397}
398#[repr(C)]
399#[derive(Debug, Copy, Clone)]
400pub struct fmpz_mod_discrete_log_pohlig_hellman_struct {
401    pub fpctx: fmpz_mod_ctx_t,
402    pub pm1: fmpz_t,
403    pub alpha: fmpz_t,
404    pub alphainv: fmpz_t,
405    pub num_factors: mp_limb_signed_t,
406    pub entries: *mut fmpz_mod_discrete_log_pohlig_hellman_entry_struct,
407}
408pub type fmpz_mod_discrete_log_pohlig_hellman_t =
409    [fmpz_mod_discrete_log_pohlig_hellman_struct; 1usize];
410extern "C" {
411    pub fn fmpz_mod_discrete_log_pohlig_hellman_init(
412        L: *mut fmpz_mod_discrete_log_pohlig_hellman_struct,
413    );
414}
415extern "C" {
416    pub fn fmpz_mod_discrete_log_pohlig_hellman_clear(
417        L: *mut fmpz_mod_discrete_log_pohlig_hellman_struct,
418    );
419}
420extern "C" {
421    pub fn fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(
422        L: *const fmpz_mod_discrete_log_pohlig_hellman_struct,
423        p: *const fmpz,
424    ) -> f64;
425}
426extern "C" {
427    pub fn fmpz_mod_discrete_log_pohlig_hellman_run(
428        x: *mut fmpz,
429        L: *const fmpz_mod_discrete_log_pohlig_hellman_struct,
430        y: *const fmpz,
431    );
432}
433extern "C" {
434    pub fn fmpz_mod_discrete_log_pohlig_hellman_primitive_root(
435        L: *const fmpz_mod_discrete_log_pohlig_hellman_struct,
436    ) -> *const fmpz;
437}
438extern "C" {
439    pub fn fmpz_next_smooth_prime(a: *mut fmpz, b: *const fmpz) -> ::std::os::raw::c_int;
440}