69 fmpq_mat_get_fmpz_mat_rowwise(m1, NULL, A.
value());
70 size_t rk = fmpz_mat_rank(m1);
80 fmpq_mat_det(det, A.
value());
81 fmpq_get_mpq(&result_det, det);
86 std::vector<size_t>& profile)
89 long nrows = fmpq_mat_nrows(B);
90 long ncols = fmpq_mat_ncols(B);
93 while (thisrow < nrows and thiscol < ncols)
95 if (not fmpq_is_zero(fmpq_mat_entry(B, thisrow, thiscol)))
97 profile.push_back(thiscol);
228 std::vector<size_t> profile;
234 if (profile[profile.size() - 1] >= ncols)
242 for (
long r = 0; r < profile.size(); r++)
244 fmpq_set(fmpq_mat_entry(X.
value(), profile[r], c),
245 fmpq_mat_entry(AB.
value(), r, ncols + c));
259 int isfullrank = fmpq_mat_solve_dixon(X.
value(), A.
value(), B.
value());
260 if (isfullrank == 0)
return false;
274 fmpz_mat_t matZZ, invZZ;
277 fmpz_mat_init(matZZ, nrows, nrows);
278 fmpz_mat_init(invZZ, nrows, nrows);
280 fmpq_mat_get_fmpz_mat_matwise(matZZ, D, A.
value());
281 int result = fmpz_mat_inv(invZZ, den, matZZ);
284 fmpq_mat_set_fmpz_mat_div_fmpz(inv.
value(), invZZ, den);
285 fmpq_mat_scalar_mul_fmpz(inv.
value(), inv.
value(), D);
290 fmpz_mat_clear(matZZ);
291 fmpz_mat_clear(invZZ);
304 fmpq_mat_get_fmpz_mat_rowwise(matZZ, NULL, A.
value());
305 long nullity = fmpz_mat_nullspace(kerZZ, matZZ);
308 for (
long c = 0; c < nullity; c++)
314 kerQQ.
toDMat(result_nullspace);
315 fmpz_mat_clear(matZZ);
316 fmpz_mat_clear(kerZZ);
size_t numColumns() const
const std::vector< size_t > & permutation()
bool inverse(Mat &result_inv)
void determinant(ElementType &result_det)
void matrixPLU(std::vector< size_t > &P, Mat &L, Mat &U)
void columnRankProfile(std::vector< size_t > &profile)
size_t kernel(Mat &result_nullspace)
static void findColumnRankProfileFromLU(const fmpq_mat_t B, std::vector< size_t > &profile)
bool solve(const Mat &B1, Mat &X1)
bool solveInvertible(const Mat &B1, Mat &X1)
RingType::ElementType ElementType
void set_from_fmpz(long r, long c, fmpz_t val)
fmpq_mat_struct * value()
void toDMat(DMatQQ &result)
RAII wrapper around FLINT's fmpq_mat_t for translating dense QQ-coefficient matrices between the engi...
static void setUpperLower(const Mat &LU, Mat &lower, Mat &upper)
Translation bridge that lets GMP-backed DMat<ARingQQ> borrow FLINT matrix arithmetic.
VALGRIND_MAKE_MEM_DEFINED & result(result)
static void concatenateMatrices(const Mat &A, const Mat &B, Mat &C)