File indexing completed on 2026-11-07 10:15:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef PADIC_MAT_H
0013 #define PADIC_MAT_H
0014
0015 #ifdef PADIC_MAT_INLINES_C
0016 #define PADIC_MAT_INLINE
0017 #else
0018 #define PADIC_MAT_INLINE static inline
0019 #endif
0020
0021 #include "fmpq_types.h"
0022 #include "padic_types.h"
0023
0024 #ifdef __cplusplus
0025 extern "C" {
0026 #endif
0027
0028
0029
0030 PADIC_MAT_INLINE
0031 fmpz_mat_struct * padic_mat(const padic_mat_t A)
0032 {
0033 return (fmpz_mat_struct *)(&(A->mat));
0034 }
0035
0036 PADIC_MAT_INLINE
0037 fmpz * padic_mat_entry(const padic_mat_t A, slong i, slong j)
0038 {
0039 return A->mat.entries + i * A->mat.stride + j;
0040 }
0041
0042 #define padic_mat_val(A) ((A)->val)
0043 #define padic_mat_prec(A) ((A)->N)
0044
0045 PADIC_MAT_INLINE
0046 slong padic_mat_get_val(const padic_mat_t A)
0047 {
0048 return A->val;
0049 }
0050
0051 PADIC_MAT_INLINE
0052 slong padic_mat_get_prec(const padic_mat_t A)
0053 {
0054 return A->N;
0055 }
0056
0057 PADIC_MAT_INLINE
0058 slong padic_mat_nrows(const padic_mat_t A)
0059 {
0060 return (A->mat).r;
0061 }
0062
0063 PADIC_MAT_INLINE
0064 slong padic_mat_ncols(const padic_mat_t A)
0065 {
0066 return (A->mat).c;
0067 }
0068
0069
0070
0071 void padic_mat_init(padic_mat_t A, slong r, slong c);
0072
0073 void padic_mat_init2(padic_mat_t A, slong r, slong c, slong prec);
0074
0075 void padic_mat_clear(padic_mat_t A);
0076
0077 void _padic_mat_canonicalise(padic_mat_t A, const padic_ctx_t ctx);
0078
0079 void _padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx);
0080
0081 void padic_mat_reduce(padic_mat_t A, const padic_ctx_t ctx);
0082
0083 PADIC_MAT_INLINE int
0084 padic_mat_is_empty(const padic_mat_t A)
0085 {
0086 return padic_mat_nrows(A) == 0 || padic_mat_ncols(A) == 0;
0087 }
0088
0089 PADIC_MAT_INLINE int
0090 padic_mat_is_square(const padic_mat_t A)
0091 {
0092 return padic_mat_nrows(A) == padic_mat_ncols(A);
0093 }
0094
0095 int padic_mat_is_canonical(const padic_mat_t A, const padic_ctx_t ctx);
0096
0097 int padic_mat_is_reduced(const padic_mat_t A, const padic_ctx_t ctx);
0098
0099
0100
0101 void padic_mat_set(padic_mat_t B, const padic_mat_t A, const padic_ctx_t ctx);
0102
0103 void padic_mat_swap(padic_mat_t A, padic_mat_t B);
0104
0105 PADIC_MAT_INLINE void
0106 padic_mat_swap_entrywise(padic_mat_t mat1, padic_mat_t mat2)
0107 {
0108 slong i, j;
0109
0110 for (i = 0; i < padic_mat_nrows(mat1); i++)
0111 for (j = 0; j < padic_mat_ncols(mat1); j++)
0112 FLINT_SWAP(fmpz, *padic_mat_entry(mat2, i, j), *padic_mat_entry(mat1, i, j));
0113 }
0114
0115 void padic_mat_zero(padic_mat_t A);
0116
0117 void padic_mat_one(padic_mat_t A);
0118
0119
0120
0121 void padic_mat_set_fmpq_mat(padic_mat_t B,
0122 const fmpq_mat_t A, const padic_ctx_t ctx);
0123
0124 void padic_mat_get_fmpq_mat(fmpq_mat_t B,
0125 const padic_mat_t A, const padic_ctx_t ctx);
0126
0127
0128
0129 void padic_mat_get_entry_padic(padic_t rop,
0130 const padic_mat_t op, slong i, slong j,
0131 const padic_ctx_t ctx);
0132
0133 void padic_mat_set_entry_padic(padic_mat_t rop, slong i, slong j,
0134 const padic_t op, const padic_ctx_t ctx);
0135
0136
0137
0138 int padic_mat_equal(const padic_mat_t A, const padic_mat_t B);
0139
0140 int padic_mat_is_zero(const padic_mat_t A);
0141
0142
0143
0144 #ifdef FLINT_HAVE_FILE
0145 int padic_mat_fprint(FILE * file, const padic_mat_t A, const padic_ctx_t ctx);
0146 int padic_mat_fprint_pretty(FILE * file, const padic_mat_t A, const padic_ctx_t ctx);
0147 #endif
0148
0149 int padic_mat_print(const padic_mat_t A, const padic_ctx_t ctx);
0150 int padic_mat_print_pretty(const padic_mat_t A, const padic_ctx_t ctx);
0151
0152
0153
0154 void padic_mat_randtest(padic_mat_t mat, flint_rand_t state,
0155 const padic_ctx_t ctx);
0156
0157
0158
0159 void padic_mat_transpose(padic_mat_t B, const padic_mat_t A);
0160
0161
0162
0163 void _padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B,
0164 const padic_ctx_t ctx);
0165 void padic_mat_add(padic_mat_t C, const padic_mat_t A, const padic_mat_t B,
0166 const padic_ctx_t ctx);
0167
0168 void _padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B,
0169 const padic_ctx_t ctx);
0170 void padic_mat_sub(padic_mat_t C, const padic_mat_t A, const padic_mat_t B,
0171 const padic_ctx_t ctx);
0172
0173 void _padic_mat_neg(padic_mat_t B, const padic_mat_t A);
0174 void padic_mat_neg(padic_mat_t B, const padic_mat_t A, const padic_ctx_t ctx);
0175
0176
0177
0178 void _padic_mat_scalar_mul_padic(padic_mat_t B,
0179 const padic_mat_t A, const padic_t c,
0180 const padic_ctx_t FLINT_UNUSED(ctx));
0181 void padic_mat_scalar_mul_padic(padic_mat_t B,
0182 const padic_mat_t A, const padic_t c,
0183 const padic_ctx_t ctx);
0184
0185 void _padic_mat_scalar_mul_fmpz(padic_mat_t B,
0186 const padic_mat_t A, const fmpz_t c,
0187 const padic_ctx_t ctx);
0188 void padic_mat_scalar_mul_fmpz(padic_mat_t B,
0189 const padic_mat_t A, const fmpz_t c,
0190 const padic_ctx_t ctx);
0191
0192 void padic_mat_scalar_div_fmpz(padic_mat_t B,
0193 const padic_mat_t A, const fmpz_t c,
0194 const padic_ctx_t ctx);
0195
0196
0197
0198 void padic_mat_mul(padic_mat_t C, const padic_mat_t A, const padic_mat_t B,
0199 const padic_ctx_t ctx);
0200
0201 #ifdef __cplusplus
0202 }
0203 #endif
0204
0205 #endif