Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:15:13

0001 /*
0002     Copyright (C) 2010 William Hart
0003     Copyright (C) 2010 Fredrik Johansson
0004 
0005     This file is part of FLINT.
0006 
0007     FLINT is free software: you can redistribute it and/or modify it under
0008     the terms of the GNU Lesser General Public License (LGPL) as published
0009     by the Free Software Foundation; either version 3 of the License, or
0010     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
0011 */
0012 
0013 #ifndef FMPZ_MAT_H
0014 #define FMPZ_MAT_H
0015 
0016 #ifdef FMPZ_MAT_INLINES_C
0017 #define FMPZ_MAT_INLINE
0018 #else
0019 #define FMPZ_MAT_INLINE static inline
0020 #endif
0021 
0022 #include "fmpz_types.h"
0023 #include "nmod_types.h"
0024 
0025 #ifdef __cplusplus
0026 extern "C" {
0027 #endif
0028 
0029 /* Element access  ********************************************************/
0030 
0031 FMPZ_MAT_INLINE
0032 fmpz * fmpz_mat_entry(const fmpz_mat_t mat, slong i, slong j)
0033 {
0034    return mat->entries + i * mat->stride + j;
0035 }
0036 
0037 FMPZ_MAT_INLINE
0038 fmpz * fmpz_mat_row(const fmpz_mat_t mat, slong i)
0039 {
0040    return mat->entries + i * mat->stride;
0041 }
0042 
0043 FMPZ_MAT_INLINE
0044 slong fmpz_mat_nrows(const fmpz_mat_t mat)
0045 {
0046    return mat->r;
0047 }
0048 
0049 FMPZ_MAT_INLINE
0050 slong fmpz_mat_ncols(const fmpz_mat_t mat)
0051 {
0052    return mat->c;
0053 }
0054 
0055 /* Memory management  ********************************************************/
0056 
0057 void fmpz_mat_init(fmpz_mat_t mat, slong rows, slong cols);
0058 void fmpz_mat_init_set(fmpz_mat_t mat, const fmpz_mat_t src);
0059 
0060 void fmpz_mat_swap(fmpz_mat_t mat1, fmpz_mat_t mat2);
0061 void fmpz_mat_swap_entrywise(fmpz_mat_t mat1, fmpz_mat_t mat2);
0062 void fmpz_mat_swap_cols(fmpz_mat_t mat, slong * perm, slong r, slong s);
0063 
0064 void fmpz_mat_set(fmpz_mat_t mat1, const fmpz_mat_t mat2);
0065 void fmpz_mat_clear(fmpz_mat_t mat);
0066 
0067 int fmpz_mat_equal(const fmpz_mat_t mat1, const fmpz_mat_t mat2);
0068 int fmpz_mat_is_zero(const fmpz_mat_t mat);
0069 int fmpz_mat_is_one(const fmpz_mat_t mat);
0070 
0071 int fmpz_mat_is_zero_row(const fmpz_mat_t mat, slong i);
0072 
0073 int fmpz_mat_equal_col(fmpz_mat_t M, slong m, slong n);
0074 int fmpz_mat_equal_row(fmpz_mat_t M, slong m, slong n);
0075 
0076 FMPZ_MAT_INLINE
0077 int fmpz_mat_is_empty(const fmpz_mat_t mat)
0078 {
0079     return (mat->r == 0) || (mat->c == 0);
0080 }
0081 
0082 FMPZ_MAT_INLINE
0083 int fmpz_mat_is_square(const fmpz_mat_t mat)
0084 {
0085     return (mat->r == mat->c);
0086 }
0087 
0088 void fmpz_mat_zero(fmpz_mat_t mat);
0089 void fmpz_mat_one(fmpz_mat_t mat);
0090 
0091 /* Windows and concatenation *************************************************/
0092 
0093 FMPZ_MAT_INLINE void
0094 fmpz_mat_window_init(fmpz_mat_t window, const fmpz_mat_t mat, slong r1,
0095                      slong c1, slong r2, slong c2)
0096 {
0097     FLINT_ASSERT(r1 >= 0 && r1 <= r2 && r2 <= mat->r);
0098     FLINT_ASSERT(c2 >= 0 && c1 <= c2 && c2 <= mat->c);
0099 
0100     window->entries = fmpz_mat_entry(mat, r1, c1);
0101     window->r = r2 - r1;
0102     window->c = c2 - c1;
0103     window->stride = mat->stride;
0104 }
0105 
0106 FMPZ_MAT_INLINE void
0107 fmpz_mat_window_clear(fmpz_mat_t FLINT_UNUSED(window))
0108 {
0109 }
0110 
0111 void _fmpz_mat_window_readonly_init_strip_initial_zero_rows(fmpz_mat_t A, const fmpz_mat_t B);
0112 #define _fmpz_mat_window_readonly_clear(A) /* Do nothing */
0113 
0114 void fmpz_mat_concat_horizontal(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2);
0115 void fmpz_mat_concat_vertical(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_mat_t mat2);
0116 
0117 /* Input and output  *********************************************************/
0118 
0119 #ifdef FLINT_HAVE_FILE
0120 int fmpz_mat_fprint(FILE * file, const fmpz_mat_t mat);
0121 int fmpz_mat_fprint_pretty(FILE * file, const fmpz_mat_t mat);
0122 
0123 int fmpz_mat_fread(FILE* file, fmpz_mat_t mat);
0124 #endif
0125 
0126 int fmpz_mat_print(const fmpz_mat_t mat);
0127 int fmpz_mat_print_pretty(const fmpz_mat_t mat);
0128 
0129 int fmpz_mat_read(fmpz_mat_t mat);
0130 
0131 /* Random matrix generation  *************************************************/
0132 
0133 void fmpz_mat_randbits(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits);
0134 void fmpz_mat_randtest(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits);
0135 void fmpz_mat_randtest_unsigned(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits);
0136 void fmpz_mat_randintrel(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits);
0137 void fmpz_mat_randsimdioph(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, flint_bitcnt_t bits2);
0138 void fmpz_mat_randntrulike(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q);
0139 void fmpz_mat_randntrulike2(fmpz_mat_t mat, flint_rand_t state, flint_bitcnt_t bits, ulong q);
0140 void fmpz_mat_randajtai(fmpz_mat_t mat, flint_rand_t state, double alpha);
0141 void fmpz_mat_randrank(fmpz_mat_t mat, flint_rand_t state, slong rank, flint_bitcnt_t bits);
0142 void fmpz_mat_randdet(fmpz_mat_t mat, flint_rand_t state, const fmpz_t det);
0143 void fmpz_mat_randops(fmpz_mat_t mat, flint_rand_t state, slong count);
0144 int fmpz_mat_randpermdiag(fmpz_mat_t mat, flint_rand_t state, const fmpz * diag, slong n);
0145 
0146 /* Norms */
0147 
0148 slong fmpz_mat_max_bits(const fmpz_mat_t mat);
0149 
0150 /* Transpose */
0151 
0152 void fmpz_mat_transpose(fmpz_mat_t B, const fmpz_mat_t A);
0153 
0154 /* Addition and subtraction */
0155 
0156 void fmpz_mat_add(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0157 void fmpz_mat_sub(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0158 void fmpz_mat_neg(fmpz_mat_t B, const fmpz_mat_t A);
0159 
0160 /* Scalar operations */
0161 void fmpz_mat_scalar_mul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c);
0162 void fmpz_mat_scalar_mul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c);
0163 void fmpz_mat_scalar_mul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c);
0164 
0165 void fmpz_mat_scalar_addmul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c);
0166 void fmpz_mat_scalar_addmul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c);
0167 void fmpz_mat_scalar_addmul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c);
0168 
0169 void fmpz_mat_scalar_submul_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c);
0170 void fmpz_mat_scalar_submul_si(fmpz_mat_t B, const fmpz_mat_t A, slong c);
0171 void fmpz_mat_scalar_submul_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c);
0172 
0173 void fmpz_mat_scalar_addmul_nmod_mat_fmpz(fmpz_mat_t B, const nmod_mat_t A, const fmpz_t c);
0174 void fmpz_mat_scalar_addmul_nmod_mat_ui(fmpz_mat_t B, const nmod_mat_t A, ulong c);
0175 
0176 void fmpz_mat_scalar_divexact_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t c);
0177 void fmpz_mat_scalar_divexact_si(fmpz_mat_t B, const fmpz_mat_t A, slong c);
0178 void fmpz_mat_scalar_divexact_ui(fmpz_mat_t B, const fmpz_mat_t A, ulong c);
0179 
0180 void fmpz_mat_scalar_mul_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp);
0181 void fmpz_mat_scalar_tdiv_q_2exp(fmpz_mat_t B, const fmpz_mat_t A, ulong exp);
0182 void fmpz_mat_scalar_smod(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t P);
0183 
0184 void fmpz_mat_scalar_mod_fmpz(fmpz_mat_t B, const fmpz_mat_t A, const fmpz_t m);
0185 
0186 /* Multiplication */
0187 
0188 void fmpz_mat_mul(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0189 void fmpz_mat_mul_classical(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0190 void fmpz_mat_mul_waksman(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0191 void fmpz_mat_mul_strassen(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0192 
0193 void _fmpz_mat_mul_fft(fmpz_mat_t C, const fmpz_mat_t A, slong abits, const fmpz_mat_t B, slong bbits, int sign);
0194 void fmpz_mat_mul_fft(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0195 
0196 void _fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B, int sign, flint_bitcnt_t Cbits);
0197 void fmpz_mat_mul_multi_mod(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0198 
0199 int _fmpz_mat_mul_blas(
0200         fmpz_mat_t C,
0201         const fmpz_mat_t A, flint_bitcnt_t Abits,
0202         const fmpz_mat_t B, flint_bitcnt_t Bbits,
0203         int sign, flint_bitcnt_t Cbits);
0204 int fmpz_mat_mul_blas(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0205 
0206 void _fmpz_mat_mul_small_1(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0207 void _fmpz_mat_mul_small_2a(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0208 void _fmpz_mat_mul_small_2b(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0209 
0210 void _fmpz_mat_mul_small_internal(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B, flint_bitcnt_t Cbits);
0211 void _fmpz_mat_mul_double_word_internal(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B, int sign, flint_bitcnt_t bits);
0212 
0213 void _fmpz_mat_mul_small(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0214 void _fmpz_mat_mul_double_word(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0215 
0216 void fmpz_mat_sqr_bodrato(fmpz_mat_t B, const fmpz_mat_t A);
0217 
0218 void fmpz_mat_sqr(fmpz_mat_t B, const fmpz_mat_t A);
0219 
0220 void fmpz_mat_pow(fmpz_mat_t B, const fmpz_mat_t A, ulong exp);
0221 
0222 void fmpz_mat_mul_fmpz_vec(fmpz * c, const fmpz_mat_t A, const fmpz * b, slong blen);
0223 void fmpz_mat_mul_fmpz_vec_ptr(fmpz * const * c, const fmpz_mat_t A, const fmpz * const * b, slong blen);
0224 
0225 void fmpz_mat_fmpz_vec_mul(fmpz * c, const fmpz * a, slong alen, const fmpz_mat_t B);
0226 void fmpz_mat_fmpz_vec_mul_ptr(fmpz * const * c, const fmpz * const * a, slong alen, const fmpz_mat_t B);
0227 
0228 /* Kronecker product */
0229 
0230 void fmpz_mat_kronecker_product(fmpz_mat_t C, const fmpz_mat_t A, const fmpz_mat_t B);
0231 
0232 /* Content */
0233 
0234 void fmpz_mat_content(fmpz_t ret, const fmpz_mat_t A);
0235 
0236 /* Permutations */
0237 
0238 void fmpz_mat_swap_rows(fmpz_mat_t mat, slong * perm, slong r, slong s);
0239 void fmpz_mat_invert_rows(fmpz_mat_t mat, slong * perm);
0240 void fmpz_mat_invert_cols(fmpz_mat_t mat, slong * perm);
0241 
0242 /* Gaussian elimination *****************************************************/
0243 
0244 slong fmpz_mat_find_pivot_any(const fmpz_mat_t mat, slong start_row, slong end_row, slong c);
0245 
0246 slong fmpz_mat_find_pivot_smallest(const fmpz_mat_t mat, slong start_row, slong end_row, slong c);
0247 
0248 slong fmpz_mat_fflu(fmpz_mat_t B, fmpz_t den, slong * perm, const fmpz_mat_t A, int rank_check);
0249 
0250 slong fmpz_mat_rank_small_inplace(fmpz_mat_t B);
0251 
0252 slong fmpz_mat_rref(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A);
0253 slong fmpz_mat_rref_fflu(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A);
0254 slong fmpz_mat_rref_mul(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A);
0255 
0256 int fmpz_mat_rref_upper_certify_lu_mod_p(fmpz_mat_t E, fmpz_t den, const fmpz_mat_t A, slong rank, const slong * P, const slong * pivs);
0257 
0258 int fmpz_mat_rank_certify_lu_mod_p(const fmpz_mat_t A, slong rank, const slong * P, const slong * pivs);
0259 
0260 int fmpz_mat_is_in_rref_with_rank(const fmpz_mat_t A, const fmpz_t den, slong rank);
0261 
0262 /* Modular Howell and strong echelon form ***********************************/
0263 
0264 slong fmpz_mat_howell_form_mod(fmpz_mat_t A, const fmpz_t mod);
0265 
0266 void fmpz_mat_strong_echelon_form_mod(fmpz_mat_t A, const fmpz_t mod);
0267 
0268 /* Trace ********************************************************************/
0269 
0270 void fmpz_mat_trace(fmpz_t trace, const fmpz_mat_t mat);
0271 
0272 /* Determinant **************************************************************/
0273 
0274 void fmpz_mat_det_bareiss(fmpz_t det, const fmpz_mat_t A);
0275 void fmpz_mat_det_cofactor(fmpz_t det, const fmpz_mat_t A);
0276 void fmpz_mat_det_modular(fmpz_t det, const fmpz_mat_t A, int proved);
0277 void fmpz_mat_det_modular_accelerated(fmpz_t det, const fmpz_mat_t A, int proved);
0278 void fmpz_mat_det_modular_given_divisor(fmpz_t det, const fmpz_mat_t A, const fmpz_t d, int proved);
0279 void fmpz_mat_det(fmpz_t det, const fmpz_mat_t A);
0280 
0281 void fmpz_mat_det_bound(fmpz_t bound, const fmpz_mat_t A);
0282 void fmpz_mat_det_bound_submatrix(fmpz_t bound, const fmpz_mat_t A);
0283 
0284 void fmpz_mat_det_divisor(fmpz_t d, const fmpz_mat_t A);
0285 
0286 int fmpz_mat_permanent(fmpz_t res, const fmpz_mat_t A);
0287 
0288 /* Transforms */
0289 
0290 void fmpz_mat_similarity(fmpz_mat_t A, slong r, fmpz_t d);
0291 
0292 /* Characteristic polynomial ************************************************/
0293 
0294 void fmpz_mat_charpoly_bound(fmpz_t bound, const fmpz_mat_t A);
0295 
0296 void _fmpz_mat_charpoly_berkowitz(fmpz * rop, const fmpz_mat_t op);
0297 void fmpz_mat_charpoly_berkowitz(fmpz_poly_t cp, const fmpz_mat_t mat);
0298 
0299 void _fmpz_mat_charpoly_modular(fmpz * rop, const fmpz_mat_t op);
0300 void fmpz_mat_charpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat);
0301 
0302 void _fmpz_mat_charpoly(fmpz * cp, const fmpz_mat_t mat);
0303 void fmpz_mat_charpoly(fmpz_poly_t cp, const fmpz_mat_t mat);
0304 
0305 /* Characteristic polynomial ************************************************/
0306 
0307 slong _fmpz_mat_minpoly_modular(fmpz * rop, const fmpz_mat_t op);
0308 void fmpz_mat_minpoly_modular(fmpz_poly_t cp, const fmpz_mat_t mat);
0309 
0310 FMPZ_MAT_INLINE
0311 slong _fmpz_mat_minpoly(fmpz * cp, const fmpz_mat_t mat)
0312 {
0313    return _fmpz_mat_minpoly_modular(cp, mat);
0314 }
0315 
0316 FMPZ_MAT_INLINE
0317 void fmpz_mat_minpoly(fmpz_poly_t cp, const fmpz_mat_t mat)
0318 {
0319    if (mat->r != mat->c)
0320    {
0321        flint_throw(FLINT_ERROR, "Exception (fmpz_mat_minpoly).  Non-square matrix.\n");
0322    }
0323 
0324    fmpz_mat_minpoly_modular(cp, mat);
0325 }
0326 
0327 /* Rank **********************************************************************/
0328 
0329 slong fmpz_mat_rank(const fmpz_mat_t A);
0330 
0331 /* Nonsingular solving *******************************************************/
0332 
0333 void fmpz_mat_solve_bound(fmpz_t N, fmpz_t D, const fmpz_mat_t A, const fmpz_mat_t B);
0334 
0335 int fmpz_mat_solve_cramer(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B);
0336 int fmpz_mat_solve_fflu_precomp(fmpz_mat_t X, const slong * perm, const fmpz_mat_t FFLU, const fmpz_mat_t B);
0337 int fmpz_mat_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B);
0338 int fmpz_mat_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B);
0339 
0340 ulong
0341 fmpz_mat_find_good_prime_and_invert(nmod_mat_t Ainv,
0342                            const fmpz_mat_t A, const fmpz_t det_bound);
0343 
0344 ulong * fmpz_mat_dixon_get_crt_primes(slong * num_primes, const fmpz_mat_t A, ulong p);
0345 
0346 void _fmpz_mat_solve_dixon(
0347         fmpz_mat_t X, fmpz_t mod,
0348         const fmpz_mat_t A, const fmpz_mat_t B, const nmod_mat_t Ainv,
0349         ulong p, const fmpz_t N, const fmpz_t D);
0350 
0351 void _fmpz_mat_solve_dixon_den(
0352         fmpz_mat_t X, fmpz_t den,
0353         const fmpz_mat_t A, const fmpz_mat_t B, const nmod_mat_t Ainv,
0354         ulong p, const fmpz_t N, const fmpz_t D);
0355 
0356 int fmpz_mat_solve_dixon(fmpz_mat_t X, fmpz_t mod, const fmpz_mat_t A, const fmpz_mat_t B);
0357 
0358 int fmpz_mat_solve_dixon_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B);
0359 int fmpz_mat_solve_multi_mod_den(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B);
0360 
0361 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);
0362 int fmpz_mat_can_solve_fflu(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B);
0363 int fmpz_mat_can_solve(fmpz_mat_t X, fmpz_t den, const fmpz_mat_t A, const fmpz_mat_t B);
0364 
0365 /* Nullspace *****************************************************************/
0366 
0367 slong fmpz_mat_nullspace(fmpz_mat_t res, const fmpz_mat_t mat);
0368 
0369 /* Inverse *******************************************************************/
0370 
0371 int fmpz_mat_inv(fmpz_mat_t B, fmpz_t den, const fmpz_mat_t A);
0372 
0373 /* Modular reduction and reconstruction **************************************/
0374 
0375 void fmpz_mat_set_nmod_mat(fmpz_mat_t A, const nmod_mat_t Amod);
0376 void fmpz_mat_set_nmod_mat_unsigned(fmpz_mat_t A, const nmod_mat_t Amod);
0377 void fmpz_mat_get_nmod_mat(nmod_mat_t Amod, const fmpz_mat_t A);
0378 
0379 void fmpz_mat_CRT_ui(fmpz_mat_t res, const fmpz_mat_t mat1, const fmpz_t m1, const nmod_mat_t mat2, int sign);
0380 
0381 /* fmpz_comb has poor basecase code; only use it when it's worth it.
0382    Fixme: improve fmpz_comb so that this isn't necessary. */
0383 #define FMPZ_MAT_MOD_PRIMES_COMB_CUTOFF 200
0384 #define FMPZ_MAT_CRT_PRIMES_COMB_CUTOFF 8
0385 
0386 /* Minimum (entries * primes) that warrant spawning a worker for multimodular
0387    reduction/CRT. */
0388 #define FMPZ_MAT_CRT_MIN_WORK_PER_THREAD 1024
0389 
0390 #ifdef FMPZ_H
0391 void fmpz_mat_multi_mod_ui_precomp(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat, const fmpz_comb_t comb);
0392 void fmpz_mat_multi_mod_2_ui_precomp(nmod_mat_t * residues_A, nmod_mat_t * residues_B, slong nres, const fmpz_mat_t A, const fmpz_mat_t B, const fmpz_comb_t comb);
0393 void fmpz_mat_multi_CRT_ui_precomp(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, const fmpz_comb_t comb, int sign);
0394 #endif
0395 
0396 void fmpz_mat_multi_mod_ui(nmod_mat_t * residues, slong nres, const fmpz_mat_t mat);
0397 void fmpz_mat_multi_CRT_ui(fmpz_mat_t mat, nmod_mat_t * const residues, slong nres, int sign);
0398 
0399 /* HNF and SNF **************************************************************/
0400 
0401 void fmpz_mat_hnf(fmpz_mat_t H, const fmpz_mat_t A);
0402 void fmpz_mat_hnf_transform(fmpz_mat_t H, fmpz_mat_t U, const fmpz_mat_t A);
0403 void fmpz_mat_hnf_classical(fmpz_mat_t H, const fmpz_mat_t A);
0404 void fmpz_mat_hnf_xgcd(fmpz_mat_t H, const fmpz_mat_t A);
0405 void fmpz_mat_hnf_minors(fmpz_mat_t H, const fmpz_mat_t A);
0406 void fmpz_mat_hnf_minors_transform(fmpz_mat_t H, fmpz_mat_t U, const fmpz_mat_t A);
0407 void fmpz_mat_hnf_modular(fmpz_mat_t H, const fmpz_mat_t A, const fmpz_t D);
0408 void fmpz_mat_hnf_modular_eldiv(fmpz_mat_t A, const fmpz_t D);
0409 void fmpz_mat_hnf_pernet_stein(fmpz_mat_t H, const fmpz_mat_t A, flint_rand_t state);
0410 
0411 int fmpz_mat_is_in_hnf(const fmpz_mat_t A);
0412 
0413 void fmpz_mat_snf(fmpz_mat_t S, const fmpz_mat_t A);
0414 void fmpz_mat_snf_diagonal(fmpz_mat_t S, const fmpz_mat_t A);
0415 void fmpz_mat_snf_kannan_bachem(fmpz_mat_t S, const fmpz_mat_t A);
0416 void fmpz_mat_snf_iliopoulos(fmpz_mat_t S, const fmpz_mat_t A, const fmpz_t mod);
0417 
0418 int fmpz_mat_is_in_snf(const fmpz_mat_t A);
0419 
0420 int fmpz_mat_is_diagonal(const fmpz_mat_t A);
0421 
0422 slong _fmpz_mat_snf_iter_bound(const fmpz_mat_t A);
0423 
0424 void fmpz_mat_snf_transform(fmpz_mat_t S, fmpz_mat_t U, fmpz_mat_t V, const fmpz_mat_t A);
0425 
0426 slong fmpz_mat_elementary_divisors(fmpz * ed, const fmpz_mat_t A);
0427 
0428 /* Special matrices **********************************************************/
0429 
0430 int fmpz_mat_is_hadamard(const fmpz_mat_t A);
0431 
0432 int fmpz_mat_hadamard(fmpz_mat_t A);
0433 
0434 /* Gram matrix **************************************************************/
0435 
0436 void fmpz_mat_gram(fmpz_mat_t B, const fmpz_mat_t A);
0437 
0438 int fmpz_mat_is_spd(const fmpz_mat_t A);
0439 
0440 /* Conversions **************************************************************/
0441 
0442 #if defined(D_MAT_H)
0443 int fmpz_mat_get_d_mat(d_mat_t B, const fmpz_mat_t A);
0444 int fmpz_mat_get_d_mat_transpose(d_mat_t B, const fmpz_mat_t A);
0445 #endif
0446 
0447 /* Cholesky Decomposition ****************************************************/
0448 
0449 #if defined(D_MAT_H)
0450 void fmpz_mat_chol_d(d_mat_t R, const fmpz_mat_t A);
0451 #endif
0452 
0453 /* LLL ***********************************************************************/
0454 
0455 int fmpz_mat_is_reduced(const fmpz_mat_t A, double delta, double eta);
0456 
0457 int fmpz_mat_is_reduced_gram(const fmpz_mat_t A, double delta, double eta);
0458 
0459 int fmpz_mat_is_reduced_with_removal(const fmpz_mat_t A,
0460                         double delta, double eta, const fmpz_t gs_B, int newd);
0461 
0462 int fmpz_mat_is_reduced_gram_with_removal(const fmpz_mat_t A,
0463                         double delta, double eta, const fmpz_t gs_B, int newd);
0464 
0465 /* Classical LLL *************************************************************/
0466 
0467 void fmpz_mat_lll_original(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta);
0468 
0469 /* Modified LLL **************************************************************/
0470 
0471 void fmpz_mat_lll_storjohann(fmpz_mat_t A, const fmpq_t delta, const fmpq_t eta);
0472 
0473 /* Column partitioning *******************************************************/
0474 
0475 int fmpz_mat_col_partition(slong * part, fmpz_mat_t M, int short_circuit);
0476 
0477 /* Van Hoeij helper function *************************************************/
0478 
0479 int fmpz_mat_next_col_van_hoeij(fmpz_mat_t M, fmpz_t P, fmpz_mat_t col, slong exp, slong U_exp);
0480 
0481 #ifdef __cplusplus
0482 }
0483 #endif
0484 
0485 #endif