File indexing completed on 2026-11-07 10:15:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef FQ_ZECH_H
0013 #define FQ_ZECH_H
0014
0015 #ifdef FQ_ZECH_INLINES_C
0016 #define FQ_ZECH_INLINE
0017 #ifndef FQ_TEMPLATES_INLINE
0018 # define FQ_TEMPLATES_INLINE
0019 #endif
0020 #else
0021 #define FQ_ZECH_INLINE static inline
0022 #ifndef FQ_TEMPLATES_INLINE
0023 # define FQ_TEMPLATES_INLINE static inline
0024 #endif
0025 #endif
0026
0027 #include "fq_zech_types.h"
0028
0029
0030 #ifdef __cplusplus
0031 extern "C" {
0032 #endif
0033
0034 void fq_zech_ctx_init_ui(fq_zech_ctx_t ctx, ulong p, slong d, const char * var);
0035 int _fq_zech_ctx_init_conway_ui(fq_zech_ctx_t ctx, ulong p, slong d, const char * var);
0036 void fq_zech_ctx_init_conway_ui(fq_zech_ctx_t ctx, ulong p, slong d, const char * var);
0037 void fq_zech_ctx_init_random_ui(fq_zech_ctx_t ctx, ulong p, slong d, const char * var);
0038
0039 int fq_zech_ctx_init_fq_nmod_ctx_check(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn);
0040 void fq_zech_ctx_init_fq_nmod_ctx(fq_zech_ctx_t ctx, fq_nmod_ctx_t ctxn);
0041
0042 int fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var);
0043 void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var);
0044
0045 void fq_zech_ctx_init_randtest(fq_zech_ctx_t ctx, flint_rand_t state, int type);
0046 void fq_zech_ctx_init_randtest_reducible(fq_zech_ctx_t ctx, flint_rand_t state, int type);
0047
0048 void fq_zech_ctx_clear(fq_zech_ctx_t ctx);
0049
0050 FQ_ZECH_INLINE
0051 const nmod_poly_struct * fq_zech_ctx_modulus(const fq_zech_ctx_t ctx)
0052 {
0053 return ctx->fq_nmod_ctx->modulus;
0054 }
0055
0056 FQ_ZECH_INLINE
0057 slong fq_zech_ctx_degree(const fq_zech_ctx_t ctx)
0058 {
0059 return ctx->fq_nmod_ctx->modulus->length - 1;
0060 }
0061
0062 FQ_ZECH_INLINE
0063 ulong fq_zech_ctx_prime(const fq_zech_ctx_t ctx)
0064 {
0065 return ctx->fq_nmod_ctx->mod.n;
0066 }
0067
0068 FQ_ZECH_INLINE
0069 ulong fq_zech_ctx_order_ui(const fq_zech_ctx_t ctx)
0070 {
0071 return ctx->qm1 + 1;
0072 }
0073
0074 #ifdef FLINT_HAVE_FILE
0075 int fq_zech_ctx_fprint(FILE * file, const fq_zech_ctx_t ctx);
0076 #endif
0077
0078 void fq_zech_ctx_print(const fq_zech_ctx_t ctx);
0079
0080
0081
0082 FQ_ZECH_INLINE void
0083 fq_zech_init(fq_zech_t rop, const fq_zech_ctx_t ctx)
0084 {
0085 rop->value = ctx->qm1;
0086 }
0087
0088 FQ_ZECH_INLINE void
0089 fq_zech_init2(fq_zech_t rop, const fq_zech_ctx_t ctx)
0090 {
0091 rop->value = ctx->qm1;
0092 }
0093
0094 FQ_ZECH_INLINE void
0095 fq_zech_clear(fq_zech_t FLINT_UNUSED(rop), const fq_zech_ctx_t FLINT_UNUSED(ctx))
0096 {
0097 }
0098
0099 FQ_ZECH_INLINE void
0100 fq_zech_reduce(fq_zech_t rop, const fq_zech_ctx_t ctx)
0101 {
0102 ulong order = fq_zech_ctx_order_ui(ctx);
0103 if (rop->value >= order)
0104 {
0105 rop->value -= order;
0106 }
0107 }
0108
0109
0110
0111 void fq_zech_add(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2,
0112 const fq_zech_ctx_t ctx);
0113
0114 void fq_zech_sub(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2,
0115 const fq_zech_ctx_t ctx);
0116
0117 void fq_zech_sub_one(fq_zech_t rop, const fq_zech_t op1,
0118 const fq_zech_ctx_t ctx);
0119
0120 void fq_zech_neg(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx);
0121
0122 void fq_zech_mul(fq_zech_t rop, const fq_zech_t op1, const fq_zech_t op2,
0123 const fq_zech_ctx_t ctx);
0124
0125 void fq_zech_mul_fmpz(fq_zech_t rop, const fq_zech_t op, const fmpz_t x,
0126 const fq_zech_ctx_t ctx);
0127
0128 void fq_zech_mul_si(fq_zech_t rop, const fq_zech_t op, slong x,
0129 const fq_zech_ctx_t ctx);
0130
0131 void fq_zech_mul_ui(fq_zech_t rop, const fq_zech_t op, ulong x,
0132 const fq_zech_ctx_t ctx);
0133
0134 void fq_zech_sqr(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx);
0135
0136 void fq_zech_inv(fq_zech_t rop, const fq_zech_t op1, const fq_zech_ctx_t ctx);
0137
0138 void _fq_zech_pow(fmpz * rop, const fmpz * op, slong len, const fmpz_t e,
0139 const fmpz * a, const slong *j, slong lena, const fmpz_t p);
0140
0141 void fq_zech_pow(fq_zech_t rop, const fq_zech_t op1, const fmpz_t e,
0142 const fq_zech_ctx_t ctx);
0143
0144 void fq_zech_pow_ui(fq_zech_t rop, const fq_zech_t op1, const ulong e,
0145 const fq_zech_ctx_t ctx);
0146
0147
0148
0149 int fq_zech_sqrt(fq_zech_t rop, const fq_zech_t op1,
0150 const fq_zech_ctx_t ctx);
0151
0152 void fq_zech_pth_root(fq_zech_t rop,
0153 const fq_zech_t op1, const fq_zech_ctx_t ctx);
0154
0155 int fq_zech_is_square(const fq_zech_t op1, const fq_zech_ctx_t ctx);
0156
0157
0158
0159 void fq_zech_randtest(fq_zech_t rop, flint_rand_t state,
0160 const fq_zech_ctx_t ctx);
0161
0162 void fq_zech_randtest_not_zero(fq_zech_t rop, flint_rand_t state,
0163 const fq_zech_ctx_t ctx);
0164
0165 void fq_zech_rand(fq_zech_t rop, flint_rand_t state,
0166 const fq_zech_ctx_t ctx);
0167
0168 void fq_zech_rand_not_zero(fq_zech_t rop, flint_rand_t state,
0169 const fq_zech_ctx_t ctx);
0170
0171
0172
0173 FQ_ZECH_INLINE int
0174 fq_zech_equal(const fq_zech_t op1, const fq_zech_t op2, const fq_zech_ctx_t FLINT_UNUSED(ctx))
0175 {
0176 return op1->value == op2->value;
0177 }
0178
0179 FQ_ZECH_INLINE int
0180 fq_zech_is_zero(const fq_zech_t op, const fq_zech_ctx_t ctx)
0181 {
0182 return op->value == ctx->qm1;
0183 }
0184
0185 FQ_ZECH_INLINE int
0186 fq_zech_is_one(const fq_zech_t op, const fq_zech_ctx_t FLINT_UNUSED(ctx))
0187 {
0188 return op->value == 0;
0189 }
0190
0191
0192
0193 FQ_ZECH_INLINE void
0194 fq_zech_set(fq_zech_t rop, const fq_zech_t op, const fq_zech_ctx_t FLINT_UNUSED(ctx))
0195 {
0196 rop->value = op->value;
0197 }
0198
0199 void fq_zech_set_fmpz(fq_zech_t rop, const fmpz_t x, const fq_zech_ctx_t ctx);
0200
0201 void fq_zech_set_si(fq_zech_t rop, const slong x, const fq_zech_ctx_t ctx);
0202 void fq_zech_set_ui(fq_zech_t rop, const ulong x, const fq_zech_ctx_t ctx);
0203
0204 FQ_ZECH_INLINE void
0205 fq_zech_swap(fq_zech_t op1, fq_zech_t op2, const fq_zech_ctx_t FLINT_UNUSED(ctx))
0206 {
0207 slong temp;
0208 temp = op2->value;
0209 op2->value = op1->value;
0210 op1->value = temp;
0211 }
0212
0213 FQ_ZECH_INLINE void
0214 fq_zech_zero(fq_zech_t rop, const fq_zech_ctx_t ctx)
0215 {
0216 rop->value = ctx->qm1;
0217 }
0218
0219 FQ_ZECH_INLINE void
0220 fq_zech_one(fq_zech_t rop, const fq_zech_ctx_t FLINT_UNUSED(ctx))
0221 {
0222 rop->value = 0;
0223 }
0224
0225 FQ_ZECH_INLINE void
0226 fq_zech_gen(fq_zech_t rop, const fq_zech_ctx_t FLINT_UNUSED(ctx))
0227 {
0228 rop->value = 1;
0229 }
0230
0231
0232 int fq_zech_get_fmpz(fmpz_t a, const fq_zech_t op,
0233 const fq_zech_ctx_t ctx);
0234
0235 void fq_zech_set_fq_nmod(fq_zech_t rop, const fq_nmod_t op,
0236 const fq_zech_ctx_t ctx);
0237
0238 void fq_zech_get_fq_nmod(fq_nmod_t rop, const fq_zech_t op,
0239 const fq_zech_ctx_t ctx);
0240
0241 void fq_zech_get_nmod_poly(nmod_poly_t a, const fq_zech_t b,
0242 const fq_zech_ctx_t ctx);
0243
0244 void fq_zech_set_nmod_poly(fq_zech_t a, const nmod_poly_t b,
0245 const fq_zech_ctx_t ctx);
0246
0247
0248
0249
0250 #ifdef FLINT_HAVE_FILE
0251 int fq_zech_fprint(FILE * file, const fq_zech_t op, const fq_zech_ctx_t FLINT_UNUSED(ctx));
0252 int fq_zech_fprint_pretty(FILE * file, const fq_zech_t op, const fq_zech_ctx_t ctx);
0253 #endif
0254
0255 void fq_zech_print(const fq_zech_t op, const fq_zech_ctx_t ctx);
0256 void fq_zech_print_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx);
0257
0258 char * fq_zech_get_str(const fq_zech_t op, const fq_zech_ctx_t FLINT_UNUSED(ctx));
0259 char * fq_zech_get_str_pretty(const fq_zech_t op, const fq_zech_ctx_t ctx);
0260
0261
0262
0263
0264 void fq_zech_trace(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx);
0265
0266 void fq_zech_frobenius(fq_zech_t rop, const fq_zech_t op, slong e,
0267 const fq_zech_ctx_t ctx);
0268
0269 void fq_zech_norm(fmpz_t rop, const fq_zech_t op, const fq_zech_ctx_t ctx);
0270
0271
0272
0273 void fq_zech_bit_pack(fmpz_t f, const fq_zech_t op, flint_bitcnt_t bit_size,
0274 const fq_zech_ctx_t ctx);
0275
0276 void fq_zech_bit_unpack(fq_zech_t rop, const fmpz_t f, flint_bitcnt_t bit_size,
0277 const fq_zech_ctx_t ctx);
0278
0279
0280
0281 void fq_zech_ctx_init(fq_zech_ctx_t ctx, fmpz_t p, slong d, const char * var);
0282 int _fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, fmpz_t p, slong d, const char * var);
0283 void fq_zech_ctx_init_conway(fq_zech_ctx_t ctx, fmpz_t p, slong d, const char * var);
0284 void fq_zech_ctx_init_random(fq_zech_ctx_t ctx, fmpz_t p, slong d, const char * var);
0285
0286 void fq_zech_ctx_order(fmpz_t f, const fq_zech_ctx_t ctx);
0287
0288 #ifdef T
0289 #undef T
0290 #endif
0291
0292 #define T fq_zech
0293 #define CAP_T FQ_ZECH
0294 #define B nmod
0295 #include "fq_templates.h"
0296 #undef B
0297 #undef CAP_T
0298 #undef T
0299
0300 #ifdef __cplusplus
0301 }
0302 #endif
0303
0304 #endif