forked from flintlib/flint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcan_solve_multi_mod_den.c
38 lines (29 loc) · 1.04 KB
/
can_solve_multi_mod_den.c
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
/*
Copyright (C) 2011 Fredrik Johansson
Copyright (C) 2020 William Hart
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/
#include "fmpz_mat.h"
#include "fmpq_mat.h"
int
fmpz_mat_can_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den,
const fmpz_mat_t A, const fmpz_mat_t B)
{
int success;
fmpq_mat_t Q;
if (A->r != B->r || A->c != X->r || X->c != B->c)
{
flint_printf("Exception (fmpz_mat_can_solve_multi_mod_den). Incompatible matrix dimensions.\n");
flint_abort();
}
fmpq_mat_init(Q, fmpz_mat_nrows(X), fmpz_mat_ncols(X));
success = fmpq_mat_can_solve_fmpz_mat_multi_mod(Q, A, B);
if (success)
fmpq_mat_get_fmpz_mat_matwise(X, den, Q);
fmpq_mat_clear(Q);
return success;
}