flint_sys/
fmpz_lll.rs

1#![allow(non_camel_case_types)]
2#![allow(non_upper_case_globals)]
3// TODO: sort out d_mat_t and mpf_mat_t, then fmpz_gram_union etc.
4
5//! See the [FLINT documentation](http://flintlib.org/doc/fmpz_lll.html).
6
7use crate::deps::*;
8use crate::flint::*;
9use crate::fmpz::fmpz;
10use crate::fmpz_mat::fmpz_mat_struct;
11use libc::{c_int, c_uint};
12
13pub const rep_type_GRAM: rep_type = 0;
14pub const rep_type_Z_BASIS: rep_type = 1;
15pub type rep_type = c_uint;
16pub const gram_type_APPROX: gram_type = 0;
17pub const gram_type_EXACT: gram_type = 1;
18pub type gram_type = c_uint;
19
20#[repr(C)]
21#[derive(Debug, Copy, Clone)]
22pub struct fmpz_lll_struct {
23    pub delta: f64,
24    pub eta: f64,
25    pub rt: rep_type,
26    pub gt: gram_type,
27}
28
29pub type fmpz_lll_t = [fmpz_lll_struct; 1usize];
30
31/*
32#[repr(C)]
33#[derive(Copy, Clone)]
34pub union fmpz_gram_union {
35    pub appSP: d_mat_t,
36    pub appSP2: mpf_mat_t,
37    pub exactSP: fmpz_mat_t,
38}
39
40pub type fmpz_gram_t = [fmpz_gram_union; 1usize];
41*/
42
43extern "C" {
44    pub fn fmpz_lll_context_init_default(fl: *mut fmpz_lll_struct);
45    pub fn fmpz_lll_context_init(
46        fl: *mut fmpz_lll_struct,
47        delta: f64,
48        eta: f64,
49        rt: rep_type,
50        gt: gram_type,
51    );
52    pub fn fmpz_lll_randtest(fl: *mut fmpz_lll_struct, state: *const flint_rand_s);
53    pub fn fmpz_lll_heuristic_dot(
54        vec1: *const f64,
55        vec2: *const f64,
56        len2: mp_limb_signed_t,
57        B: *const fmpz_mat_struct,
58        k: mp_limb_signed_t,
59        j: mp_limb_signed_t,
60        exp_adj: mp_limb_signed_t,
61    ) -> f64;
62    /*
63    pub fn fmpz_lll_check_babai(
64        kappa: c_int,
65        B: *mut fmpz_mat_struct,
66        U: *mut fmpz_mat_struct,
67        mu: *mut d_mat_struct,
68        r: *mut d_mat_struct,
69        s: *mut f64,
70        appB: *mut d_mat_struct,
71        expo: *mut c_int,
72        A: *mut fmpz_gram_union,
73        a: c_int,
74        zeros: c_int,
75        kappamax: c_int,
76        n: c_int,
77        fl: *const fmpz_lll_struct,
78    ) -> c_int;
79    pub fn fmpz_lll_check_babai_heuristic_d(
80        kappa: c_int,
81        B: *mut fmpz_mat_struct,
82        U: *mut fmpz_mat_struct,
83        mu: *mut d_mat_struct,
84        r: *mut d_mat_struct,
85        s: *mut f64,
86        appB: *mut d_mat_struct,
87        expo: *mut c_int,
88        A: *mut fmpz_gram_union,
89        a: c_int,
90        zeros: c_int,
91        kappamax: c_int,
92        n: c_int,
93        fl: *const fmpz_lll_struct,
94    ) -> c_int;
95    */
96    pub fn fmpz_lll_shift(B: *const fmpz_mat_struct) -> c_int;
97    pub fn fmpz_lll_d(
98        B: *mut fmpz_mat_struct,
99        U: *mut fmpz_mat_struct,
100        fl: *const fmpz_lll_struct,
101    ) -> c_int;
102    pub fn fmpz_lll_d_heuristic(
103        B: *mut fmpz_mat_struct,
104        U: *mut fmpz_mat_struct,
105        fl: *const fmpz_lll_struct,
106    ) -> c_int;
107    /*
108    pub fn fmpz_lll_check_babai_heuristic(
109        kappa: c_int,
110        B: *mut fmpz_mat_struct,
111        U: *mut fmpz_mat_struct,
112        mu: *mut mpf_mat_struct,
113        r: *mut mpf_mat_struct,
114        s: *mut mpf,
115        appB: *mut mpf_mat_struct,
116        A: *mut fmpz_gram_union,
117        a: c_int,
118        zeros: c_int,
119        kappamax: c_int,
120        n: c_int,
121        tmp: *mut __mpf_struct,
122        rtmp: *mut __mpf_struct,
123        prec: mp_limb_t,
124        fl: *const fmpz_lll_struct,
125    ) -> c_int;
126    */
127    pub fn fmpz_lll_mpf2(
128        B: *mut fmpz_mat_struct,
129        U: *mut fmpz_mat_struct,
130        prec: mp_limb_t,
131        fl: *const fmpz_lll_struct,
132    ) -> c_int;
133    pub fn fmpz_lll_mpf(
134        B: *mut fmpz_mat_struct,
135        U: *mut fmpz_mat_struct,
136        fl: *const fmpz_lll_struct,
137    ) -> c_int;
138    pub fn fmpz_lll_wrapper(
139        B: *mut fmpz_mat_struct,
140        U: *mut fmpz_mat_struct,
141        fl: *const fmpz_lll_struct,
142    ) -> c_int;
143    /*
144    pub fn fmpz_lll_advance_check_babai(
145        cur_kappa: c_int,
146        kappa: c_int,
147        B: *mut fmpz_mat_struct,
148        U: *mut fmpz_mat_struct,
149        mu: *mut d_mat_struct,
150        r: *mut d_mat_struct,
151        s: *mut f64,
152        appB: *mut d_mat_struct,
153        expo: *mut c_int,
154        A: *mut fmpz_gram_union,
155        a: c_int,
156        zeros: c_int,
157        kappamax: c_int,
158        n: c_int,
159        fl: *const fmpz_lll_struct,
160    ) -> c_int;
161    pub fn fmpz_lll_advance_check_babai_heuristic_d(
162        cur_kappa: c_int,
163        kappa: c_int,
164        B: *mut fmpz_mat_struct,
165        U: *mut fmpz_mat_struct,
166        mu: *mut d_mat_struct,
167        r: *mut d_mat_struct,
168        s: *mut f64,
169        appB: *mut d_mat_struct,
170        expo: *mut c_int,
171        A: *mut fmpz_gram_union,
172        a: c_int,
173        zeros: c_int,
174        kappamax: c_int,
175        n: c_int,
176        fl: *const fmpz_lll_struct,
177    ) -> c_int;
178    */
179    pub fn fmpz_lll_d_with_removal(
180        B: *mut fmpz_mat_struct,
181        U: *mut fmpz_mat_struct,
182        gs_B: *const fmpz,
183        fl: *const fmpz_lll_struct,
184    ) -> c_int;
185    pub fn fmpz_lll_d_heuristic_with_removal(
186        B: *mut fmpz_mat_struct,
187        U: *mut fmpz_mat_struct,
188        gs_B: *const fmpz,
189        fl: *const fmpz_lll_struct,
190    ) -> c_int;
191    pub fn fmpz_lll_mpf2_with_removal(
192        B: *mut fmpz_mat_struct,
193        U: *mut fmpz_mat_struct,
194        prec: mp_limb_t,
195        gs_B: *const fmpz,
196        fl: *const fmpz_lll_struct,
197    ) -> c_int;
198    pub fn fmpz_lll_mpf_with_removal(
199        B: *mut fmpz_mat_struct,
200        U: *mut fmpz_mat_struct,
201        gs_B: *const fmpz,
202        fl: *const fmpz_lll_struct,
203    ) -> c_int;
204    pub fn fmpz_lll_wrapper_with_removal(
205        B: *mut fmpz_mat_struct,
206        U: *mut fmpz_mat_struct,
207        gs_B: *const fmpz,
208        fl: *const fmpz_lll_struct,
209    ) -> c_int;
210    pub fn fmpz_lll_d_with_removal_knapsack(
211        B: *mut fmpz_mat_struct,
212        U: *mut fmpz_mat_struct,
213        gs_B: *const fmpz,
214        fl: *const fmpz_lll_struct,
215    ) -> c_int;
216    pub fn fmpz_lll_wrapper_with_removal_knapsack(
217        B: *mut fmpz_mat_struct,
218        U: *mut fmpz_mat_struct,
219        gs_B: *const fmpz,
220        fl: *const fmpz_lll_struct,
221    ) -> c_int;
222    pub fn fmpz_lll_with_removal_ulll(
223        FM: *mut fmpz_mat_struct,
224        UM: *mut fmpz_mat_struct,
225        new_size: mp_limb_signed_t,
226        gs_B: *const fmpz,
227        fl: *const fmpz_lll_struct,
228    ) -> c_int;
229    pub fn fmpz_lll_is_reduced_d(B: *const fmpz_mat_struct, fl: *const fmpz_lll_struct) -> c_int;
230    pub fn fmpz_lll_is_reduced_mpfr(
231        B: *const fmpz_mat_struct,
232        fl: *const fmpz_lll_struct,
233        prec: mp_limb_t,
234    ) -> c_int;
235    pub fn fmpz_lll_is_reduced(
236        B: *const fmpz_mat_struct,
237        fl: *const fmpz_lll_struct,
238        prec: mp_limb_t,
239    ) -> c_int;
240    pub fn fmpz_lll_is_reduced_d_with_removal(
241        B: *const fmpz_mat_struct,
242        fl: *const fmpz_lll_struct,
243        gs_B: *const fmpz,
244        newd: c_int,
245    ) -> c_int;
246    pub fn fmpz_lll_is_reduced_mpfr_with_removal(
247        B: *const fmpz_mat_struct,
248        fl: *const fmpz_lll_struct,
249        gs_B: *const fmpz,
250        newd: c_int,
251        prec: mp_limb_t,
252    ) -> c_int;
253    pub fn fmpz_lll_is_reduced_with_removal(
254        B: *const fmpz_mat_struct,
255        fl: *const fmpz_lll_struct,
256        gs_B: *const fmpz,
257        newd: c_int,
258        prec: mp_limb_t,
259    ) -> c_int;
260    pub fn fmpz_lll(B: *mut fmpz_mat_struct, U: *mut fmpz_mat_struct, fl: *const fmpz_lll_struct);
261    pub fn fmpz_lll_with_removal(
262        B: *mut fmpz_mat_struct,
263        U: *mut fmpz_mat_struct,
264        gs_B: *const fmpz,
265        fl: *const fmpz_lll_struct,
266    ) -> c_int;
267    pub fn fmpz_lll_storjohann_ulll(
268        FM: *mut fmpz_mat_struct,
269        new_size: mp_limb_signed_t,
270        fl: *const fmpz_lll_struct,
271    );
272}