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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#![allow(non_camel_case_types)]

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


use crate::deps::*;
use crate::flint::*;
use crate::fmpz_poly::fmpz_poly_struct;
use crate::nmod_poly::nmod_poly_struct;
use crate::nmod_mat::nmod_mat_struct;
use crate::fq::{fq_struct, fq_ctx_struct};
use crate::fq_nmod::fq_nmod_ctx_struct;
use libc::{c_int, FILE};


#[repr(C)]
#[derive(Debug, Copy, Clone, Hash)]
pub struct fq_mat_struct {
    pub entries: *mut fq_struct,
    pub r: mp_limb_signed_t,
    pub c: mp_limb_signed_t,
    pub rows: *mut *mut fq_struct,
}

pub type fq_mat_t = [fq_mat_struct; 1usize];

extern "C" {
    pub fn FQ_MAT_MUL_KS_CUTOFF(
        r: mp_limb_signed_t,
        c: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_init(
        mat: *mut fq_mat_struct,
        rows: mp_limb_signed_t,
        cols: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_init_set(
        mat: *mut fq_mat_struct,
        src: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_swap(mat1: *mut fq_mat_struct, mat2: *mut fq_mat_struct, ctx: *mut fq_ctx_struct);
    pub fn fq_mat_set(mat1: *mut fq_mat_struct, mat2: *mut fq_mat_struct, ctx: *mut fq_ctx_struct);
    pub fn fq_mat_clear(mat: *mut fq_mat_struct, ctx: *mut fq_ctx_struct);
    pub fn fq_mat_equal(
        mat1: *mut fq_mat_struct,
        mat2: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_is_zero(
        mat: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_is_empty(
        mat: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_is_square(
        mat: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_entry(
        mat: *mut fq_mat_struct,
        i: mp_limb_signed_t,
        j: mp_limb_signed_t,
    ) -> *mut fq_struct;
    pub fn fq_mat_entry_set(
        mat: *mut fq_mat_struct,
        i: mp_limb_signed_t,
        j: mp_limb_signed_t,
        x: *mut fmpz_poly_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_nrows(mat: *mut fq_mat_struct, ctx: *mut fq_ctx_struct) -> mp_limb_signed_t;
    pub fn fq_mat_ncols(mat: *mut fq_mat_struct, ctx: *mut fq_ctx_struct) -> mp_limb_signed_t;
    pub fn fq_mat_swap_rows(
        mat: *mut fq_mat_struct,
        perm: *mut mp_limb_signed_t,
        r: mp_limb_signed_t,
        s: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_invert_rows(
        mat: *mut fq_mat_struct,
        perm: *mut mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_swap_cols(
        mat: *mut fq_mat_struct,
        perm: *mut mp_limb_signed_t,
        r: mp_limb_signed_t,
        s: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_invert_cols(
        mat: *mut fq_mat_struct,
        perm: *mut mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_zero(A: *mut fq_mat_struct, ctx: *mut fq_ctx_struct);
    pub fn fq_mat_window_init(
        window: *mut fq_mat_struct,
        mat: *mut fq_mat_struct,
        r1: mp_limb_signed_t,
        c1: mp_limb_signed_t,
        r2: mp_limb_signed_t,
        c2: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_window_clear(window: *mut fq_mat_struct, ctx: *mut fq_ctx_struct);
    pub fn fq_mat_concat_horizontal(
        res: *mut fq_mat_struct,
        mat1: *mut fq_mat_struct,
        mat2: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_concat_vertical(
        res: *mut fq_mat_struct,
        mat1: *mut fq_mat_struct,
        mat2: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_fprint(
        file: *mut FILE,
        mat: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_fprint_pretty(
        file: *mut FILE,
        mat: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_print(mat: *mut fq_mat_struct, ctx: *mut fq_ctx_struct) -> c_int;
    pub fn fq_mat_print_pretty(
        mat: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_randtest(
        mat: *mut fq_mat_struct,
        state: *mut flint_rand_s,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_randrank(
        mat: *mut fq_mat_struct,
        state: *mut flint_rand_s,
        rank: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_randpermdiag(
        mat: *mut fq_mat_struct,
        state: *mut flint_rand_s,
        diag: *mut fq_struct,
        n: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_randops(
        mat: *mut fq_mat_struct,
        count: mp_limb_signed_t,
        state: *mut flint_rand_s,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_randtril(
        mat: *mut fq_mat_struct,
        state: *mut flint_rand_s,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_randtriu(
        mat: *mut fq_mat_struct,
        state: *mut flint_rand_s,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_add(
        C: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_sub(
        C: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_neg(B: *mut fq_mat_struct, A: *mut fq_mat_struct, ctx: *mut fq_ctx_struct);
    pub fn fq_mat_submul(
        D: *mut fq_mat_struct,
        C: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_mul(
        C: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_mul_classical(
        C: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_mul_KS(
        C: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_lu(
        P: *mut mp_limb_signed_t,
        A: *mut fq_mat_struct,
        rank_check: c_int,
        ctx: *mut fq_ctx_struct,
    ) -> mp_limb_signed_t;
    pub fn fq_mat_lu_recursive(
        P: *mut mp_limb_signed_t,
        A: *mut fq_mat_struct,
        rank_check: c_int,
        ctx: *mut fq_ctx_struct,
    ) -> mp_limb_signed_t;
    pub fn fq_mat_lu_classical(
        P: *mut mp_limb_signed_t,
        A: *mut fq_mat_struct,
        rank_check: c_int,
        ctx: *mut fq_ctx_struct,
    ) -> mp_limb_signed_t;
    pub fn fq_mat_inv(
        B: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_rref(A: *mut fq_mat_struct, ctx: *mut fq_ctx_struct) -> mp_limb_signed_t;
    pub fn fq_mat_reduce_row(
        A: *mut fq_mat_struct,
        P: *mut mp_limb_signed_t,
        L: *mut mp_limb_signed_t,
        m: mp_limb_signed_t,
        ctx: *mut fq_ctx_struct,
    ) -> mp_limb_signed_t;
    pub fn fq_mat_nullspace(
        X: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> mp_limb_signed_t;
    pub fn fq_mat_rank(A: *mut fq_mat_struct, ctx: *mut fq_ctx_struct) -> mp_limb_signed_t;
    pub fn fq_mat_solve_tril(
        X: *mut fq_mat_struct,
        L: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_solve_tril_classical(
        X: *mut fq_mat_struct,
        L: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_solve_tril_recursive(
        X: *mut fq_mat_struct,
        L: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_solve_triu(
        X: *mut fq_mat_struct,
        U: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_solve_triu_classical(
        X: *mut fq_mat_struct,
        U: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_solve_triu_recursive(
        X: *mut fq_mat_struct,
        U: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        unit: c_int,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_mat_solve(
        X: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        C: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_can_solve(
        X: *mut fq_mat_struct,
        A: *mut fq_mat_struct,
        B: *mut fq_mat_struct,
        ctx: *mut fq_ctx_struct,
    ) -> c_int;
    pub fn fq_mat_similarity(
        A: *mut fq_mat_struct,
        r: mp_limb_signed_t,
        d: *mut fmpz_poly_struct,
        ctx: *mut fq_ctx_struct,
    );
    pub fn fq_nmod_embed_gens(
        gen_sub: *mut nmod_poly_struct,
        gen_sup: *mut nmod_poly_struct,
        minpoly: *mut nmod_poly_struct,
        sub_ctx: *mut fq_nmod_ctx_struct,
        sup_ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn _fq_nmod_embed_gens_naive(
        gen_sub: *mut nmod_poly_struct,
        gen_sup: *mut nmod_poly_struct,
        minpoly: *mut nmod_poly_struct,
        sub_ctx: *mut fq_nmod_ctx_struct,
        sup_ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn _fq_nmod_embed_gens_allombert(
        gen_sub: *mut nmod_poly_struct,
        gen_sup: *mut nmod_poly_struct,
        minpoly: *mut nmod_poly_struct,
        sub_ctx: *mut fq_nmod_ctx_struct,
        sup_ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_embed_matrices(
        embed: *mut nmod_mat_struct,
        project: *mut nmod_mat_struct,
        gen_sub: *mut nmod_poly_struct,
        sub_ctx: *mut fq_nmod_ctx_struct,
        gen_sup: *mut nmod_poly_struct,
        sup_ctx: *mut fq_nmod_ctx_struct,
        gen_minpoly: *mut nmod_poly_struct,
    );
    pub fn fq_nmod_embed_trace_matrix(
        res: *mut nmod_mat_struct,
        basis: *mut nmod_mat_struct,
        sub_ctx: *mut fq_nmod_ctx_struct,
        sup_ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_embed_composition_matrix_sub(
        matrix: *mut nmod_mat_struct,
        gen: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
        trunc: mp_limb_signed_t,
    );
    pub fn fq_nmod_embed_mul_matrix(
        matrix: *mut nmod_mat_struct,
        gen: *mut nmod_poly_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_embed_mono_to_dual_matrix(
        res: *mut nmod_mat_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
    pub fn fq_nmod_embed_dual_to_mono_matrix(
        res: *mut nmod_mat_struct,
        ctx: *mut fq_nmod_ctx_struct,
    );
}