flint_sys/
padic.rs

1#![allow(non_snake_case)]
2#![allow(non_camel_case_types)]
3#![allow(non_upper_case_globals)]
4
5//! *See the [FLINT documentation](http://flintlib.org/doc/padic.html).
6
7use crate::deps::*;
8use crate::flint::*;
9use crate::fmpq::fmpq;
10use crate::fmpz::{fmpz, fmpz_t};
11use libc::{c_char, c_int, c_uint, FILE};
12
13#[repr(C)]
14#[derive(Debug, Copy, Clone)]
15pub struct padic_struct {
16    pub u: fmpz,
17    pub v: mp_limb_signed_t,
18    pub N: mp_limb_signed_t,
19}
20
21pub type padic_t = [padic_struct; 1usize];
22
23#[repr(C)]
24#[derive(Debug, Copy, Clone)]
25pub struct padic_ctx_struct {
26    pub p: fmpz_t,
27    pub pinv: f64,
28    pub pow: *mut fmpz,
29    pub min: mp_limb_signed_t,
30    pub max: mp_limb_signed_t,
31    pub mode: padic_print_mode,
32}
33
34pub type padic_ctx_t = [padic_ctx_struct; 1usize];
35
36#[repr(C)]
37#[derive(Debug, Copy, Clone)]
38pub struct padic_inv_struct {
39    pub n: mp_limb_signed_t,
40    pub pow: *mut fmpz,
41}
42
43pub type padic_inv_t = [padic_inv_struct; 1usize];
44
45pub const padic_print_mode_PADIC_TERSE: padic_print_mode = 0;
46pub const padic_print_mode_PADIC_SERIES: padic_print_mode = 1;
47pub const padic_print_mode_PADIC_VAL_UNIT: padic_print_mode = 2;
48
49pub type padic_print_mode = c_uint;
50
51extern "C" {
52    pub fn padic_ctx_init(
53        ctx: *mut padic_ctx_struct,
54        p: *const fmpz,
55        min: mp_limb_signed_t,
56        max: mp_limb_signed_t,
57        mode: padic_print_mode,
58    );
59    pub fn padic_unit(x: *const padic_struct) -> *mut fmpz;
60    pub fn padic_get_val(x: *const padic_struct) -> mp_limb_signed_t;
61    pub fn padic_get_prec(x: *const padic_struct) -> mp_limb_signed_t;
62    pub fn padic_ctx_clear(ctx: *mut padic_ctx_struct);
63    pub fn _padic_ctx_pow_ui(rop: *mut fmpz, e: mp_limb_t, ctx: *const padic_ctx_struct) -> c_int;
64    pub fn padic_ctx_pow_ui(rop: *mut fmpz, e: mp_limb_t, ctx: *const padic_ctx_struct);
65    pub fn padic_init(rop: *mut padic_struct);
66    pub fn padic_init2(rop: *mut padic_struct, N: mp_limb_signed_t);
67    pub fn padic_clear(rop: *mut padic_struct);
68    pub fn _padic_canonicalise(rop: *mut padic_struct, ctx: *const padic_ctx_struct);
69    pub fn _padic_reduce(rop: *mut padic_struct, ctx: *const padic_ctx_struct);
70    pub fn padic_reduce(rop: *mut padic_struct, ctx: *const padic_ctx_struct);
71    pub fn padic_randtest(
72        rop: *mut padic_struct,
73        state: *const flint_rand_s,
74        ctx: *const padic_ctx_struct,
75    );
76    pub fn padic_randtest_not_zero(
77        rop: *mut padic_struct,
78        state: *const flint_rand_s,
79        ctx: *const padic_ctx_struct,
80    );
81    pub fn padic_randtest_int(
82        rop: *mut padic_struct,
83        state: *const flint_rand_s,
84        ctx: *const padic_ctx_struct,
85    );
86    pub fn padic_set(rop: *mut padic_struct, op: *const padic_struct, ctx: *const padic_ctx_struct);
87    pub fn padic_set_si(rop: *mut padic_struct, op: mp_limb_signed_t, ctx: *const padic_ctx_struct);
88    pub fn padic_set_ui(rop: *mut padic_struct, op: mp_limb_t, ctx: *const padic_ctx_struct);
89    pub fn padic_set_fmpz(rop: *mut padic_struct, op: *const fmpz, ctx: *const padic_ctx_struct);
90    pub fn padic_set_fmpq(rop: *mut padic_struct, op: *const fmpq, ctx: *const padic_ctx_struct);
91    pub fn padic_set_mpz(
92        rop: *mut padic_struct,
93        op: *const __mpz_struct,
94        ctx: *const padic_ctx_struct,
95    );
96    pub fn padic_set_mpq(
97        rop: *mut padic_struct,
98        op: *const __mpq_struct,
99        ctx: *const padic_ctx_struct,
100    );
101    pub fn padic_get_fmpz(rop: *mut fmpz, op: *const padic_struct, ctx: *const padic_ctx_struct);
102    pub fn padic_get_fmpq(rop: *mut fmpq, op: *const padic_struct, ctx: *const padic_ctx_struct);
103    pub fn padic_get_mpz(
104        rop: *mut __mpz_struct,
105        op: *const padic_struct,
106        ctx: *const padic_ctx_struct,
107    );
108    pub fn padic_get_mpq(
109        rop: *mut __mpq_struct,
110        op: *const padic_struct,
111        ctx: *const padic_ctx_struct,
112    );
113    pub fn padic_swap(op1: *mut padic_struct, op2: *const padic_struct);
114    pub fn padic_zero(rop: *mut padic_struct);
115    pub fn padic_one(rop: *mut padic_struct);
116    pub fn padic_is_zero(op: *const padic_struct) -> c_int;
117    pub fn padic_is_one(op: *const padic_struct) -> c_int;
118    pub fn padic_equal(op1: *const padic_struct, op2: *const padic_struct) -> c_int;
119    pub fn _padic_lifts_exps(
120        n: *mut mp_limb_signed_t,
121        N: mp_limb_signed_t,
122    ) -> *const mp_limb_signed_t;
123    pub fn _padic_lifts_pows(
124        pow: *mut fmpz,
125        a: *const mp_limb_signed_t,
126        n: mp_limb_signed_t,
127        p: *const fmpz,
128    );
129    pub fn padic_add(
130        rop: *mut padic_struct,
131        op1: *const padic_struct,
132        op2: *const padic_struct,
133        ctx: *const padic_ctx_struct,
134    );
135    pub fn padic_sub(
136        rop: *mut padic_struct,
137        op1: *const padic_struct,
138        op2: *const padic_struct,
139        ctx: *const padic_ctx_struct,
140    );
141    pub fn padic_neg(rop: *mut padic_struct, op: *const padic_struct, ctx: *const padic_ctx_struct);
142    pub fn padic_mul(
143        rop: *mut padic_struct,
144        op1: *const padic_struct,
145        op2: *const padic_struct,
146        ctx: *const padic_ctx_struct,
147    );
148    pub fn padic_shift(
149        rop: *mut padic_struct,
150        op: *const padic_struct,
151        v: mp_limb_signed_t,
152        ctx: *const padic_ctx_struct,
153    );
154    pub fn padic_div(
155        rop: *mut padic_struct,
156        op1: *const padic_struct,
157        op2: *const padic_struct,
158        ctx: *const padic_ctx_struct,
159    );
160    pub fn _padic_inv_precompute(S: *mut padic_inv_struct, p: *const fmpz, N: mp_limb_signed_t);
161    pub fn _padic_inv_clear(S: *mut padic_inv_struct);
162    pub fn _padic_inv_precomp(rop: *mut fmpz, op: *const fmpz, S: *const padic_inv_struct);
163    pub fn _padic_inv(rop: *mut fmpz, op: *const fmpz, p: *const fmpz, N: mp_limb_signed_t);
164    pub fn padic_inv(rop: *mut padic_struct, op: *const padic_struct, ctx: *const padic_ctx_struct);
165    pub fn padic_sqrt(
166        rop: *mut padic_struct,
167        op: *const padic_struct,
168        ctx: *const padic_ctx_struct,
169    ) -> c_int;
170    pub fn padic_pow_si(
171        rop: *mut padic_struct,
172        op: *const padic_struct,
173        e: mp_limb_signed_t,
174        ctx: *const padic_ctx_struct,
175    );
176    pub fn _padic_exp_bound(
177        v: mp_limb_signed_t,
178        N: mp_limb_signed_t,
179        p: *const fmpz,
180    ) -> mp_limb_signed_t;
181    pub fn _padic_exp(
182        rop: *mut fmpz,
183        u: *const fmpz,
184        v: mp_limb_signed_t,
185        p: *const fmpz,
186        N: mp_limb_signed_t,
187    );
188    pub fn _padic_exp_rectangular(
189        rop: *mut fmpz,
190        u: *const fmpz,
191        v: mp_limb_signed_t,
192        p: *const fmpz,
193        N: mp_limb_signed_t,
194    );
195    pub fn _padic_exp_balanced(
196        rop: *mut fmpz,
197        u: *const fmpz,
198        v: mp_limb_signed_t,
199        p: *const fmpz,
200        N: mp_limb_signed_t,
201    );
202    pub fn padic_exp(
203        rop: *mut padic_struct,
204        op: *const padic_struct,
205        ctx: *const padic_ctx_struct,
206    ) -> c_int;
207    pub fn padic_exp_rectangular(
208        rop: *mut padic_struct,
209        op: *const padic_struct,
210        ctx: *const padic_ctx_struct,
211    ) -> c_int;
212    pub fn padic_exp_balanced(
213        rop: *mut padic_struct,
214        op: *const padic_struct,
215        ctx: *const padic_ctx_struct,
216    ) -> c_int;
217    pub fn _padic_log_bound(
218        v: mp_limb_signed_t,
219        N: mp_limb_signed_t,
220        p: *const fmpz,
221    ) -> mp_limb_signed_t;
222    pub fn _padic_log(
223        z: *mut fmpz,
224        y: *const fmpz,
225        v: mp_limb_signed_t,
226        p: *const fmpz,
227        N: mp_limb_signed_t,
228    );
229    pub fn _padic_log_rectangular(
230        z: *mut fmpz,
231        y: *const fmpz,
232        v: mp_limb_signed_t,
233        p: *const fmpz,
234        N: mp_limb_signed_t,
235    );
236    pub fn _padic_log_satoh(
237        z: *mut fmpz,
238        y: *const fmpz,
239        v: mp_limb_signed_t,
240        p: *const fmpz,
241        N: mp_limb_signed_t,
242    );
243    pub fn _padic_log_balanced(
244        z: *mut fmpz,
245        y: *const fmpz,
246        v: mp_limb_signed_t,
247        p: *const fmpz,
248        N: mp_limb_signed_t,
249    );
250    pub fn padic_log(
251        rop: *mut padic_struct,
252        op: *const padic_struct,
253        ctx: *const padic_ctx_struct,
254    ) -> c_int;
255    pub fn padic_log_rectangular(
256        rop: *mut padic_struct,
257        op: *const padic_struct,
258        ctx: *const padic_ctx_struct,
259    ) -> c_int;
260    pub fn padic_log_satoh(
261        rop: *mut padic_struct,
262        op: *const padic_struct,
263        ctx: *const padic_ctx_struct,
264    ) -> c_int;
265    pub fn padic_log_balanced(
266        rop: *mut padic_struct,
267        op: *const padic_struct,
268        ctx: *const padic_ctx_struct,
269    ) -> c_int;
270    pub fn _padic_teichmuller(rop: *mut fmpz, op: *const fmpz, p: *const fmpz, N: mp_limb_signed_t);
271    pub fn padic_teichmuller(
272        rop: *mut padic_struct,
273        op: *const padic_struct,
274        ctx: *const padic_ctx_struct,
275    );
276    pub fn padic_val_fac_ui_2(N: mp_limb_t) -> mp_limb_t;
277    pub fn padic_val_fac_ui(N: mp_limb_t, p: *const fmpz) -> mp_limb_t;
278    pub fn padic_val_fac(rop: *mut fmpz, op: *const fmpz, p: *const fmpz);
279    pub fn _padic_get_str(
280        str_: *const c_char,
281        op: *const padic_struct,
282        p: *const fmpz,
283        mode: padic_print_mode,
284    ) -> *const c_char;
285    pub fn padic_get_str(
286        str_: *const c_char,
287        op: *const padic_struct,
288        ctx: *const padic_ctx_struct,
289    ) -> *const c_char;
290    pub fn _padic_fprint(
291        file: *mut FILE,
292        u: *const fmpz,
293        v: mp_limb_signed_t,
294        ctx: *const padic_ctx_struct,
295    ) -> c_int;
296    pub fn padic_fprint(
297        file: *mut FILE,
298        op: *const padic_struct,
299        ctx: *const padic_ctx_struct,
300    ) -> c_int;
301    pub fn _padic_print(u: *mut fmpz, v: mp_limb_signed_t, ctx: *const padic_ctx_struct) -> c_int;
302    pub fn padic_print(op: *mut padic_struct, ctx: *const padic_ctx_struct) -> c_int;
303    pub fn padic_debug(op: *mut padic_struct);
304}