File indexing completed on 2026-11-07 10:15:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef FQ_H
0015 #define FQ_H
0016
0017 #ifdef FQ_INLINES_C
0018 #define FQ_INLINE
0019 #define FQ_TEMPLATES_INLINE
0020 #else
0021 #define FQ_INLINE static inline
0022 #define FQ_TEMPLATES_INLINE static inline
0023 #endif
0024
0025 #include "fq_types.h"
0026
0027
0028
0029 #ifdef __cplusplus
0030 extern "C" {
0031 #endif
0032
0033 void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char * var);
0034 int _fq_ctx_init_conway_ui(fq_ctx_t ctx, ulong p, slong d, const char * var);
0035 void fq_ctx_init_conway_ui(fq_ctx_t ctx, ulong p, slong d, const char * var);
0036 int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char * var);
0037 void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char * var);
0038 void fq_ctx_init_modulus(fq_ctx_t ctx, const fmpz_mod_poly_t modulus, const fmpz_mod_ctx_t ctxp, const char * var);
0039
0040 void fq_ctx_init_randtest(fq_ctx_t ctx, flint_rand_t state, int type);
0041 void fq_ctx_init_randtest_reducible(fq_ctx_t ctx, flint_rand_t state, int type);
0042
0043 void fq_ctx_clear(fq_ctx_t ctx);
0044
0045 FQ_INLINE const fmpz_mod_poly_struct* fq_ctx_modulus(const fq_ctx_t ctx)
0046 {
0047 return ctx->modulus;
0048 }
0049
0050 FQ_INLINE slong fq_ctx_degree(const fq_ctx_t ctx)
0051 {
0052 return ctx->modulus->length - 1;
0053 }
0054
0055 FQ_INLINE const fmpz * fq_ctx_prime(const fq_ctx_t ctx)
0056 {
0057 return ctx->ctxp->n;
0058 }
0059
0060 void fq_ctx_order(fmpz_t f, const fq_ctx_t ctx);
0061
0062 #ifdef FLINT_HAVE_FILE
0063 int fq_ctx_fprint(FILE * file, const fq_ctx_t ctx);
0064 #endif
0065
0066 void fq_ctx_print(const fq_ctx_t ctx);
0067
0068
0069
0070 void fq_init(fq_t rop, const fq_ctx_t FLINT_UNUSED(ctx));
0071 void fq_init2(fq_t rop, const fq_ctx_t ctx);
0072
0073 void fq_clear(fq_t rop, const fq_ctx_t FLINT_UNUSED(ctx));
0074
0075 void _fq_sparse_reduce(fmpz * R, slong lenR, const fq_ctx_t ctx);
0076 void _fq_dense_reduce(fmpz * R, slong lenR, const fq_ctx_t ctx);
0077 void _fq_reduce(fmpz * R, slong lenR, const fq_ctx_t ctx);
0078 void fq_reduce(fq_t rop, const fq_ctx_t ctx);
0079
0080
0081
0082 void fq_add(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx);
0083 void fq_sub(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx);
0084
0085 void fq_sub_one(fq_t rop, const fq_t op1, const fq_ctx_t ctx);
0086
0087 void fq_neg(fq_t rop, const fq_t op1, const fq_ctx_t ctx);
0088
0089 void fq_mul(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx);
0090 void fq_mul_fmpz(fq_t rop, const fq_t op, const fmpz_t x, const fq_ctx_t ctx);
0091 void fq_mul_si(fq_t rop, const fq_t op, slong x, const fq_ctx_t ctx);
0092 void fq_mul_ui(fq_t rop, const fq_t op, ulong x, const fq_ctx_t ctx);
0093
0094 void fq_sqr(fq_t rop, const fq_t op, const fq_ctx_t ctx);
0095
0096 void fq_inv(fq_t rop, const fq_t op1, const fq_ctx_t ctx);
0097
0098 void _fq_pow(fmpz *rop, const fmpz *op, slong len, const fmpz_t e, const fq_ctx_t ctx);
0099 void fq_pow(fq_t rop, const fq_t op1, const fmpz_t e, const fq_ctx_t ctx);
0100 void fq_pow_ui(fq_t rop, const fq_t op, const ulong e, const fq_ctx_t ctx);
0101
0102
0103
0104 int fq_sqrt(fq_t rop, const fq_t op, const fq_ctx_t ctx);
0105
0106 void fq_pth_root(fq_t rop, const fq_t op1, const fq_ctx_t ctx);
0107
0108 int fq_is_square(const fq_t op, const fq_ctx_t ctx);
0109
0110
0111
0112 void fq_randtest(fq_t rop, flint_rand_t state, const fq_ctx_t ctx);
0113 void fq_randtest_dense(fq_t rop, flint_rand_t state, const fq_ctx_t ctx);
0114 void fq_randtest_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx);
0115
0116 void fq_rand(fq_t rop, flint_rand_t state, const fq_ctx_t ctx);
0117 void fq_rand_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx);
0118
0119
0120
0121 int fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t FLINT_UNUSED(ctx));
0122
0123 int fq_is_zero(const fq_t op, const fq_ctx_t FLINT_UNUSED(ctx));
0124 int fq_is_one(const fq_t op, const fq_ctx_t FLINT_UNUSED(ctx));
0125
0126
0127
0128 void fq_set(fq_t rop, const fq_t op, const fq_ctx_t FLINT_UNUSED(ctx));
0129 void fq_set_ui(fq_t rop, const ulong x, const fq_ctx_t ctx);
0130 void fq_set_si(fq_t rop, const slong x, const fq_ctx_t ctx);
0131 void fq_set_fmpz(fq_t rop, const fmpz_t x, const fq_ctx_t ctx);
0132 void fq_set_fmpz_poly(fq_t a, const fmpz_poly_t b, const fq_ctx_t ctx);
0133 void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx);
0134
0135 int fq_get_fmpz(fmpz_t a, const fq_t b, const fq_ctx_t FLINT_UNUSED(ctx));
0136 void fq_get_fmpz_poly(fmpz_poly_t a, const fq_t b, const fq_ctx_t FLINT_UNUSED(ctx));
0137 void fq_get_fmpz_mod_poly(fmpz_mod_poly_t a, const fq_t b, const fq_ctx_t ctx);
0138
0139 void fq_zero(fq_t rop, const fq_ctx_t FLINT_UNUSED(ctx));
0140 void fq_one(fq_t rop, const fq_ctx_t FLINT_UNUSED(ctx));
0141
0142 void fq_swap(fq_t op1, fq_t op2, const fq_ctx_t FLINT_UNUSED(ctx));
0143
0144 void fq_gen(fq_t rop, const fq_ctx_t ctx);
0145
0146
0147
0148 #ifdef FLINT_HAVE_FILE
0149 int fq_fprint(FILE * file, const fq_t op, const fq_ctx_t FLINT_UNUSED(ctx));
0150 void fq_print(const fq_t op, const fq_ctx_t FLINT_UNUSED(ctx));
0151 int fq_fprint_pretty(FILE * file, const fq_t op, const fq_ctx_t ctx);
0152 int fq_print_pretty(const fq_t op, const fq_ctx_t ctx);
0153 #endif
0154
0155 char * fq_get_str(const fq_t op, const fq_ctx_t FLINT_UNUSED(ctx));
0156 char * fq_get_str_pretty(const fq_t op, const fq_ctx_t ctx);
0157
0158
0159
0160 void _fq_trace(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx);
0161 void fq_trace(fmpz_t rop, const fq_t op, const fq_ctx_t ctx);
0162
0163 void _fq_frobenius(fmpz *rop, const fmpz *op, slong len, slong e, const fq_ctx_t ctx);
0164 void fq_frobenius(fq_t rop, const fq_t op, slong e, const fq_ctx_t ctx);
0165
0166 void _fq_norm(fmpz_t rop, const fmpz *op, slong len, const fq_ctx_t ctx);
0167 void fq_norm(fmpz_t rop, const fq_t op, const fq_ctx_t ctx);
0168
0169
0170
0171
0172 void fq_bit_pack(fmpz_t f, const fq_t op, flint_bitcnt_t bit_size, const fq_ctx_t FLINT_UNUSED(ctx));
0173
0174 void fq_bit_unpack(fq_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_ctx_t ctx);
0175
0176
0177
0178 void __fq_ctx_prime(fmpz_t p, fq_ctx_t ctx);
0179
0180 #ifdef T
0181 #undef T
0182 #endif
0183
0184 #define T fq
0185 #define CAP_T FQ
0186 #define B fmpz_mod
0187 #include "fq_templates.h"
0188 #undef B
0189 #undef CAP_T
0190 #undef T
0191
0192 #ifdef __cplusplus
0193 }
0194 #endif
0195
0196 #endif