1use flint_sys::deps::*;
2use flint_sys::fmpz::*;
3
4use libc::c_int;
5
6#[repr(C)]
7#[derive(Debug, Copy, Clone)]
8pub struct qfb {
9 pub a: fmpz_t,
10 pub b: fmpz_t,
11 pub c: fmpz_t,
12}
13
14pub type qfb_t = [qfb; 1usize];
15
16#[repr(C)]
17#[derive(Debug, Copy, Clone)]
18pub struct qfb_hash_t {
19 pub q: qfb_t,
20 pub q2: qfb_t,
21 pub iter: mp_limb_signed_t,
22}
23
24extern "C" {
25 pub fn qfb_hash_init(depth: mp_limb_signed_t) -> *const qfb_hash_t;
26 pub fn qfb_hash_clear(qhash: *mut qfb_hash_t, depth: mp_limb_signed_t);
27 pub fn qfb_hash_insert(
28 qhash: *mut qfb_hash_t,
29 q: *const qfb,
30 q2: *const qfb,
31 iter: mp_limb_signed_t,
32 depth: mp_limb_signed_t,
33 );
34 pub fn qfb_hash_find(
35 qhash: *mut qfb_hash_t,
36 q: *const qfb,
37 depth: mp_limb_signed_t,
38 ) -> mp_limb_signed_t;
39 pub fn qfb_reduce(r: *mut qfb, f: *const qfb, D: *const fmpz);
40 pub fn qfb_is_reduced(r: *const qfb) -> c_int;
41 pub fn qfb_reduced_forms(forms: *mut *mut qfb, d: mp_limb_signed_t) -> mp_limb_signed_t;
42 pub fn qfb_reduced_forms_large(forms: *mut *mut qfb, d: mp_limb_signed_t) -> mp_limb_signed_t;
43 pub fn qfb_nucomp(r: *mut qfb, f: *const qfb, g: *const qfb, D: *const fmpz, L: *const fmpz);
44 pub fn qfb_nudupl(r: *mut qfb, f: *const qfb, D: *const fmpz, L: *const fmpz);
45 pub fn qfb_pow_ui(r: *mut qfb, f: *const qfb, D: *const fmpz, exp: mp_limb_t);
46 pub fn qfb_pow(r: *mut qfb, f: *const qfb, D: *const fmpz, exp: *const fmpz);
47 pub fn qfb_pow_with_root(
48 r: *mut qfb,
49 f: *const qfb,
50 D: *const fmpz,
51 e: *const fmpz,
52 L: *const fmpz,
53 );
54 pub fn qfb_prime_form(r: *mut qfb, D: *const fmpz, p: *const fmpz);
55 pub fn qfb_exponent_element(
56 exponent: *mut fmpz,
57 f: *const qfb,
58 n: *const fmpz,
59 B1: mp_limb_t,
60 B2_sqrt: mp_limb_t,
61 ) -> c_int;
62 pub fn qfb_exponent(
63 exponent: *mut fmpz,
64 n: *const fmpz,
65 B1: mp_limb_t,
66 B2_sqrt: mp_limb_t,
67 c: mp_limb_signed_t,
68 ) -> c_int;
69 pub fn qfb_exponent_grh(
70 exponent: *mut fmpz,
71 n: *const fmpz,
72 B1: mp_limb_t,
73 B2_sqrt: mp_limb_t,
74 ) -> c_int;
75}
76
77#[inline]
78pub unsafe fn qfb_init(r: *mut qfb) {
79 fmpz_init(&mut (*r).a[0]);
80 fmpz_init(&mut (*r).b[0]);
81 fmpz_init(&mut (*r).c[0]);
82}
83
84#[inline]
85pub unsafe fn qfb_clear(r: *mut qfb) {
86 fmpz_clear(&mut (*r).a[0]);
87 fmpz_clear(&mut (*r).b[0]);
88 fmpz_clear(&mut (*r).c[0]);
89}
90
91#[inline]
92pub unsafe fn qfb_equal(f: *const qfb, g: *const qfb) -> c_int {
93 let b = fmpz_equal(&(*f).a[0], &(*g).a[0]) != 0
94 && fmpz_equal(&(*f).b[0], &(*g).b[0]) != 0
95 && fmpz_equal(&(*f).c[0], &(*g).c[0]) != 0;
96 b as i32
97}
98
99#[inline]
100pub unsafe fn qfb_set(f: *mut qfb, g: *const qfb) {
101 fmpz_set(&mut (*f).a[0], &(*g).a[0]);
102 fmpz_set(&mut (*f).b[0], &(*g).b[0]);
103 fmpz_set(&mut (*f).c[0], &(*g).c[0]);
104}
105
106