File indexing completed on 2026-11-07 10:15:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef FQ_NMOD_MPOLY_FACTOR_H
0013 #define FQ_NMOD_MPOLY_FACTOR_H
0014
0015 #ifdef FQ_NMOD_MPOLY_FACTOR_INLINES_C
0016 #define FQ_NMOD_MPOLY_FACTOR_INLINE
0017 #else
0018 #define FQ_NMOD_MPOLY_FACTOR_INLINE static inline
0019 #endif
0020
0021 #include "fq_nmod_mpoly.h"
0022
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026
0027
0028
0029 typedef struct {
0030 fq_nmod_t constant;
0031 fq_nmod_mpoly_struct * poly;
0032 fmpz * exp;
0033 slong num;
0034 slong alloc;
0035 } fq_nmod_mpoly_factor_struct;
0036
0037 typedef fq_nmod_mpoly_factor_struct fq_nmod_mpoly_factor_t[1];
0038
0039 void fq_nmod_mpoly_factor_init(fq_nmod_mpoly_factor_t f,
0040 const fq_nmod_mpoly_ctx_t ctx);
0041
0042 void fq_nmod_mpoly_factor_realloc(fq_nmod_mpoly_factor_t f,
0043 slong alloc, const fq_nmod_mpoly_ctx_t ctx);
0044
0045 void fq_nmod_mpoly_factor_fit_length(fq_nmod_mpoly_factor_t f,
0046 slong len, const fq_nmod_mpoly_ctx_t ctx);
0047
0048 void fq_nmod_mpoly_factor_clear(fq_nmod_mpoly_factor_t f,
0049 const fq_nmod_mpoly_ctx_t ctx);
0050
0051 FQ_NMOD_MPOLY_FACTOR_INLINE
0052 slong fq_nmod_mpoly_factor_length(const fq_nmod_mpoly_factor_t f,
0053 const fq_nmod_mpoly_ctx_t FLINT_UNUSED(ctx))
0054 {
0055 return f->num;
0056 }
0057
0058 void fq_nmod_mpoly_factor_get_constant_fq_nmod(fq_nmod_t c, const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx);
0059
0060 FQ_NMOD_MPOLY_FACTOR_INLINE
0061 void fq_nmod_mpoly_factor_get_base(fq_nmod_mpoly_t p,
0062 const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx)
0063 {
0064 FLINT_ASSERT(i < (ulong) f->num);
0065 fq_nmod_mpoly_set(p, f->poly + i, ctx);
0066 }
0067
0068 FQ_NMOD_MPOLY_FACTOR_INLINE
0069 void fq_nmod_mpoly_factor_swap_base(fq_nmod_mpoly_t p,
0070 const fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t ctx)
0071 {
0072 FLINT_ASSERT(i < (ulong) f->num);
0073 fq_nmod_mpoly_swap(p, f->poly + i, ctx);
0074 }
0075
0076 slong fq_nmod_mpoly_factor_get_exp_si(fq_nmod_mpoly_factor_t f, slong i, const fq_nmod_mpoly_ctx_t FLINT_UNUSED(ctx));
0077
0078 void fq_nmod_mpoly_factor_set(fq_nmod_mpoly_factor_t a,
0079 const fq_nmod_mpoly_factor_t b, const fq_nmod_mpoly_ctx_t ctx);
0080
0081 void fq_nmod_mpoly_factor_print_pretty(const fq_nmod_mpoly_factor_t f,
0082 const char ** vars, const fq_nmod_mpoly_ctx_t ctx);
0083
0084 void fq_nmod_mpoly_factor_append_ui(fq_nmod_mpoly_factor_t f,
0085 const fq_nmod_mpoly_t A, ulong e, const fq_nmod_mpoly_ctx_t ctx);
0086
0087 void fq_nmod_mpoly_factor_append_fmpz(fq_nmod_mpoly_factor_t f,
0088 const fq_nmod_mpoly_t A, const fmpz_t e, const fq_nmod_mpoly_ctx_t ctx);
0089
0090 int fq_nmod_mpoly_factor_content(fq_nmod_mpoly_factor_t f,
0091 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx);
0092
0093 int fq_nmod_mpoly_factor_squarefree(fq_nmod_mpoly_factor_t f,
0094 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx);
0095
0096 int fq_nmod_mpoly_factor_separable(fq_nmod_mpoly_factor_t f,
0097 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx, int sep);
0098
0099 int fq_nmod_mpoly_factor(fq_nmod_mpoly_factor_t f,
0100 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx);
0101
0102 void fq_nmod_mpoly_factor_sort(fq_nmod_mpoly_factor_t f,
0103 const fq_nmod_mpoly_ctx_t ctx);
0104
0105 int fq_nmod_mpoly_factor_cmp(const fq_nmod_mpoly_factor_t A,
0106 const fq_nmod_mpoly_factor_t B, const fq_nmod_mpoly_ctx_t ctx);
0107
0108 FQ_NMOD_MPOLY_FACTOR_INLINE
0109 void fq_nmod_mpoly_factor_swap(fq_nmod_mpoly_factor_t A,
0110 fq_nmod_mpoly_factor_t B, const fq_nmod_mpoly_ctx_t FLINT_UNUSED(ctx))
0111 {
0112 fq_nmod_mpoly_factor_struct t = *A;
0113 *A = *B;
0114 *B = t;
0115 }
0116
0117 void fq_nmod_mpoly_factor_one(fq_nmod_mpoly_factor_t a, const fq_nmod_mpoly_ctx_t ctx);
0118
0119 int fq_nmod_mpoly_factor_expand(fq_nmod_mpoly_t A,
0120 const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx);
0121
0122
0123 FQ_NMOD_MPOLY_FACTOR_INLINE
0124 int fq_nmod_mpoly_factor_matches(const fq_nmod_mpoly_t a,
0125 const fq_nmod_mpoly_factor_t f, const fq_nmod_mpoly_ctx_t ctx)
0126 {
0127 int matches;
0128 fq_nmod_mpoly_t t;
0129 fq_nmod_mpoly_init(t, ctx);
0130 fq_nmod_mpoly_factor_expand(t, f, ctx);
0131 matches = fq_nmod_mpoly_equal(t, a, ctx);
0132 fq_nmod_mpoly_clear(t, ctx);
0133 return matches;
0134 }
0135
0136 void _fq_nmod_mpoly_get_lead0(
0137 fq_nmod_mpoly_t c,
0138 const fq_nmod_mpoly_t A,
0139 const fq_nmod_mpoly_ctx_t ctx);
0140
0141 void _fq_nmod_mpoly_set_lead0(
0142 fq_nmod_mpoly_t A,
0143 const fq_nmod_mpoly_t B,
0144 const fq_nmod_mpoly_t c,
0145 const fq_nmod_mpoly_ctx_t ctx);
0146
0147
0148
0149 void n_fq_bpoly_mul(
0150 n_bpoly_t A,
0151 const n_bpoly_t B,
0152 const n_bpoly_t C,
0153 const fq_nmod_ctx_t ctx);
0154
0155 void n_fq_bpoly_mul_series(
0156 n_bpoly_t A,
0157 const n_bpoly_t B,
0158 const n_bpoly_t C,
0159 slong order,
0160 const fq_nmod_ctx_t ctx);
0161
0162 void n_fq_bpoly_add(
0163 n_bpoly_t A,
0164 const n_bpoly_t B,
0165 const n_bpoly_t C,
0166 const fq_nmod_ctx_t ctx);
0167
0168 void n_fq_bpoly_sub(
0169 n_bpoly_t A,
0170 const n_bpoly_t B,
0171 const n_bpoly_t C,
0172 const fq_nmod_ctx_t ctx);
0173
0174 void n_fq_bpoly_divrem_series(
0175 n_bpoly_t Q,
0176 n_bpoly_t R,
0177 const n_bpoly_t A,
0178 const n_bpoly_t B,
0179 slong order,
0180 const fq_nmod_ctx_t ctx);
0181
0182 int n_fq_bpoly_divides(
0183 n_bpoly_t Q,
0184 const n_bpoly_t A,
0185 const n_bpoly_t B,
0186 const fq_nmod_ctx_t ctx);
0187
0188 void n_fq_bpoly_make_primitive(
0189 n_poly_t g,
0190 n_bpoly_t A,
0191 const fq_nmod_ctx_t ctx);
0192
0193 void fq_nmod_mpoly_get_n_fq_bpoly(
0194 n_bpoly_t A,
0195 const fq_nmod_mpoly_t B,
0196 slong varx,
0197 slong vary,
0198 const fq_nmod_mpoly_ctx_t ctx);
0199
0200 void fq_nmod_mpoly_set_n_fq_bpoly(
0201 fq_nmod_mpoly_t A,
0202 flint_bitcnt_t Abits,
0203 const n_bpoly_t B,
0204 slong varx,
0205 slong vary,
0206 const fq_nmod_mpoly_ctx_t ctx);
0207
0208
0209 int n_fq_bpoly_factor_smprime(
0210 n_poly_t c,
0211 n_tpoly_t F,
0212 n_bpoly_t B,
0213 int allow_shift,
0214 const fq_nmod_ctx_t ctx);
0215
0216 int n_fq_bpoly_factor_lgprime(
0217 n_poly_t c,
0218 n_tpoly_t F,
0219 n_bpoly_t B,
0220 const fq_nmod_ctx_t ctx,
0221 flint_rand_t state);
0222
0223
0224
0225 void n_polyu3_fq_print_pretty(
0226 const n_polyu_t A,
0227 const char * var0,
0228 const char * var1,
0229 const char * var2,
0230 const fq_nmod_ctx_t ctx);
0231
0232 int n_polyu_fq_is_canonical(
0233 const n_polyu_t A,
0234 const fq_nmod_ctx_t ctx);
0235
0236
0237
0238 void n_polyu2n_fq_print_pretty(
0239 const n_polyun_t A,
0240 const char * var0,
0241 const char * var1,
0242 const char * varlast,
0243 const fq_nmod_ctx_t ctx);
0244
0245 void n_polyu3n_fq_print_pretty(
0246 const n_polyun_t A,
0247 const char * var0,
0248 const char * var1,
0249 const char * var2,
0250 const char * varlast,
0251 const fq_nmod_ctx_t ctx);
0252
0253 int n_polyun_fq_is_canonical(
0254 const n_polyun_t A,
0255 const fq_nmod_ctx_t ctx);
0256
0257
0258
0259 typedef struct
0260 {
0261 fq_nmod_mpoly_struct * coeffs;
0262 slong alloc;
0263 slong length;
0264 } fq_nmod_mpolyv_struct;
0265
0266 typedef fq_nmod_mpolyv_struct fq_nmod_mpolyv_t[1];
0267
0268 FQ_NMOD_MPOLY_FACTOR_INLINE
0269 void fq_nmod_mpolyv_init(fq_nmod_mpolyv_t A, const fq_nmod_mpoly_ctx_t FLINT_UNUSED(ctx))
0270 {
0271 A->coeffs = NULL;
0272 A->alloc = 0;
0273 A->length = 0;
0274 }
0275
0276 FQ_NMOD_MPOLY_FACTOR_INLINE
0277 void fq_nmod_mpolyv_swap(fq_nmod_mpolyv_t A, fq_nmod_mpolyv_t B,
0278 const fq_nmod_mpoly_ctx_t FLINT_UNUSED(ctx))
0279 {
0280 fq_nmod_mpolyv_struct t = *A;
0281 *A = *B;
0282 *B = t;
0283 }
0284
0285 void fq_nmod_mpolyv_clear(fq_nmod_mpolyv_t A,
0286 const fq_nmod_mpoly_ctx_t ctx);
0287
0288 void fq_nmod_mpolyv_print_pretty(const fq_nmod_mpolyv_t poly,
0289 const char ** x, const fq_nmod_mpoly_ctx_t ctx);
0290
0291 void fq_nmod_mpolyv_fit_length(fq_nmod_mpolyv_t A, slong length,
0292 const fq_nmod_mpoly_ctx_t ctx);
0293
0294 void fq_nmod_mpolyv_set_coeff(fq_nmod_mpolyv_t A, slong i,
0295 fq_nmod_mpoly_t c, const fq_nmod_mpoly_ctx_t ctx);
0296
0297 void fq_nmod_mpoly_to_mpolyv(fq_nmod_mpolyv_t A,
0298 const fq_nmod_mpoly_t B, const fq_nmod_mpoly_t xalpha,
0299 const fq_nmod_mpoly_ctx_t ctx);
0300
0301 void fq_nmod_mpoly_from_mpolyv(fq_nmod_mpoly_t A,
0302 flint_bitcnt_t Abits, const fq_nmod_mpolyv_t B,
0303 const fq_nmod_mpoly_t xalpha, const fq_nmod_mpoly_ctx_t ctx);
0304
0305 int _fq_nmod_mpoly_vec_content_mpoly(fq_nmod_mpoly_t g,
0306 const fq_nmod_mpoly_struct * A, slong Alen,
0307 const fq_nmod_mpoly_ctx_t ctx);
0308
0309 void _fq_nmod_mpoly_vec_divexact_mpoly(fq_nmod_mpoly_struct * A,
0310 slong Alen, const fq_nmod_mpoly_t c, const fq_nmod_mpoly_ctx_t ctx);
0311
0312 void _fq_nmod_mpoly_vec_mul_mpoly(fq_nmod_mpoly_struct * A,
0313 slong Alen, const fq_nmod_mpoly_t c, const fq_nmod_mpoly_ctx_t ctx);
0314
0315
0316
0317 int _fq_nmod_mpoly_factor_separable(fq_nmod_mpoly_factor_t f,
0318 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx, int sep);
0319
0320 int fq_nmod_mpoly_factor_lcc_wang(
0321 fq_nmod_mpoly_struct * lc_divs,
0322 const fq_nmod_mpoly_factor_t lcAfac,
0323 const n_poly_t Auc,
0324 const n_bpoly_struct * Auf,
0325 slong r,
0326 const n_poly_struct * alpha,
0327 const fq_nmod_mpoly_ctx_t ctx);
0328
0329 int fq_nmod_mpoly_factor_irred_smprime_zassenhaus(
0330 fq_nmod_mpolyv_t fac,
0331 const fq_nmod_mpoly_t A,
0332 const fq_nmod_mpoly_ctx_t ctx,
0333 flint_rand_t state);
0334
0335 int fq_nmod_mpoly_factor_irred_lgprime_zassenhaus(
0336 fq_nmod_mpolyv_t fac,
0337 const fq_nmod_mpoly_t A,
0338 const fq_nmod_mpoly_ctx_t ctx,
0339 flint_rand_t state);
0340
0341 int fq_nmod_mpoly_factor_irred_smprime_wang(
0342 fq_nmod_mpolyv_t fac,
0343 const fq_nmod_mpoly_t A,
0344 const fq_nmod_mpoly_factor_t lcAfac,
0345 const fq_nmod_mpoly_t lcA,
0346 const fq_nmod_mpoly_ctx_t ctx,
0347 flint_rand_t state);
0348
0349 int fq_nmod_mpoly_factor_irred_lgprime_wang(
0350 fq_nmod_mpolyv_t Af,
0351 const fq_nmod_mpoly_t A,
0352 const fq_nmod_mpoly_factor_t lcAfac,
0353 const fq_nmod_mpoly_t lcA,
0354 const fq_nmod_mpoly_ctx_t ctx,
0355 flint_rand_t state);
0356
0357 int fq_nmod_mpoly_factor_irred_smprime_zippel(
0358 fq_nmod_mpolyv_t fac,
0359 const fq_nmod_mpoly_t A,
0360 const fq_nmod_mpoly_factor_t lcAfac,
0361 const fq_nmod_mpoly_t lcA,
0362 const fq_nmod_mpoly_ctx_t ctx,
0363 flint_rand_t state);
0364
0365 int fq_nmod_mpoly_factor_irred_lgprime_zippel(
0366 fq_nmod_mpolyv_t Af,
0367 const fq_nmod_mpoly_t A,
0368 const fq_nmod_mpoly_factor_t lcAfac,
0369 const fq_nmod_mpoly_t lcA,
0370 const fq_nmod_mpoly_ctx_t ctx,
0371 flint_rand_t state);
0372
0373
0374
0375 void fq_nmod_mpoly_compression_do(fq_nmod_mpoly_t L,
0376 const fq_nmod_mpoly_ctx_t Lctx, ulong * Acoeffs, slong Alen,
0377 mpoly_compression_t M);
0378
0379 void fq_nmod_mpoly_compression_undo(fq_nmod_mpoly_t A,
0380 flint_bitcnt_t Abits, const fq_nmod_mpoly_ctx_t Actx, fq_nmod_mpoly_t L,
0381 const fq_nmod_mpoly_ctx_t Lctx, mpoly_compression_t M);
0382
0383
0384
0385 typedef struct {
0386 flint_bitcnt_t bits;
0387 slong w;
0388 slong r;
0389 fq_nmod_poly_struct * inv_prod_dbetas;
0390 fq_nmod_mpoly_struct * inv_prod_dbetas_mvar;
0391 fq_nmod_poly_struct * dbetas;
0392 fq_nmod_mpoly_struct * dbetas_mvar;
0393 fq_nmod_mpoly_struct * prod_mbetas;
0394 fq_nmod_mpolyv_struct * prod_mbetas_coeffs;
0395 fq_nmod_mpoly_struct * mbetas;
0396 fq_nmod_mpoly_struct * deltas;
0397 fq_nmod_mpoly_struct * xalpha;
0398 fq_nmod_mpoly_struct * q;
0399 fq_nmod_mpoly_geobucket_struct * G;
0400 fq_nmod_mpoly_struct * qt;
0401 fq_nmod_mpoly_struct * newt;
0402 fq_nmod_mpolyv_struct * delta_coeffs;
0403 fq_nmod_mpoly_t T;
0404 fq_nmod_mpoly_t Q;
0405 fq_nmod_mpoly_t R;
0406 } fq_nmod_mpoly_pfrac_struct;
0407
0408 typedef fq_nmod_mpoly_pfrac_struct fq_nmod_mpoly_pfrac_t[1];
0409
0410
0411 int fq_nmod_mpoly_pfrac_init(
0412 fq_nmod_mpoly_pfrac_t Iv,
0413 flint_bitcnt_t bits,
0414 slong l, slong r,
0415 const fq_nmod_mpoly_struct * betas,
0416 const fq_nmod_struct * alpha,
0417 const fq_nmod_mpoly_ctx_t ctx);
0418
0419 void fq_nmod_mpoly_pfrac_clear(
0420 fq_nmod_mpoly_pfrac_t Iv,
0421 const fq_nmod_mpoly_ctx_t ctx);
0422
0423 int fq_nmod_mpoly_pfrac(
0424 slong r,
0425 fq_nmod_mpoly_t t,
0426 const slong * deg,
0427 fq_nmod_mpoly_pfrac_t Iv,
0428 const fq_nmod_mpoly_ctx_t ctx);
0429
0430 int fq_nmod_mpoly_hlift(
0431 slong m,
0432 fq_nmod_mpoly_struct * f,
0433 slong r,
0434 const fq_nmod_struct * alpha,
0435 const fq_nmod_mpoly_t A,
0436 const slong * degs,
0437 const fq_nmod_mpoly_ctx_t ctx);
0438
0439 int n_fq_bpoly_hlift2_cubic(
0440 n_fq_bpoly_t A,
0441 n_fq_bpoly_t B0,
0442 n_fq_bpoly_t B1,
0443 const fq_nmod_t alpha_,
0444 slong degree_inner,
0445 const fq_nmod_ctx_t ctx,
0446 nmod_eval_interp_t E,
0447 n_poly_bpoly_stack_t St);
0448
0449 int n_fq_bpoly_hlift2(
0450 n_bpoly_t A,
0451 n_bpoly_t B0,
0452 n_bpoly_t B1,
0453 const fq_nmod_t alpha,
0454 slong degree_inner,
0455 const fq_nmod_ctx_t ctx,
0456 n_poly_bpoly_stack_t St);
0457
0458 int n_fq_bpoly_hlift_cubic(
0459 n_fq_bpoly_t A,
0460 n_fq_bpoly_t B0,
0461 n_fq_bpoly_t B1,
0462 const fq_nmod_t alpha_,
0463 slong degree_inner,
0464 const fq_nmod_ctx_t ctx,
0465 nmod_eval_interp_t E,
0466 n_poly_bpoly_stack_t St);
0467
0468 int n_fq_bpoly_hlift(
0469 slong r,
0470 n_bpoly_t A,
0471 n_bpoly_struct * B,
0472 const fq_nmod_t alpha,
0473 slong degree_inner,
0474 const fq_nmod_ctx_t ctx,
0475 n_poly_bpoly_stack_t FLINT_UNUSED(St));
0476
0477 int n_fq_polyu3_hlift(
0478 slong r,
0479 n_polyun_struct * BB,
0480 n_polyu_t A,
0481 n_polyu_struct * B,
0482 const fq_nmod_t beta,
0483 slong degree_inner,
0484 const fq_nmod_ctx_t ctx,
0485 n_poly_bpoly_stack_t St);
0486
0487 int fq_nmod_mpoly_factor_algo(fq_nmod_mpoly_factor_t f,
0488 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx, unsigned int algo);
0489
0490 int fq_nmod_mpoly_factor_wang(fq_nmod_mpoly_factor_t f,
0491 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx);
0492
0493 int fq_nmod_mpoly_factor_zassenhaus(fq_nmod_mpoly_factor_t f,
0494 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx);
0495
0496 int fq_nmod_mpoly_factor_zippel(fq_nmod_mpoly_factor_t f,
0497 const fq_nmod_mpoly_t A, const fq_nmod_mpoly_ctx_t ctx);
0498
0499 int _fq_nmod_mpoly_eval_rest_n_fq_poly(n_poly_struct * E,
0500 slong * starts, slong * ends, slong * stops, ulong * es,
0501 const ulong * Acoeffs, const ulong * Aexps, slong Alen, slong var,
0502 const n_fq_poly_struct * alphas, const slong * offsets, const slong * shifts,
0503 slong N, ulong mask, slong nvars, const fq_nmod_ctx_t ctx);
0504
0505 void _fq_nmod_mpoly_eval_rest_to_n_fq_bpoly(n_bpoly_t E,
0506 const fq_nmod_mpoly_t A, const n_poly_struct * alphabetas,
0507 const fq_nmod_mpoly_ctx_t ctx);
0508
0509 void _fq_nmod_mpoly_set_n_fq_bpoly_gen1_zero(fq_nmod_mpoly_t A,
0510 flint_bitcnt_t Abits, const n_bpoly_t B, slong var,
0511 const fq_nmod_mpoly_ctx_t ctx);
0512
0513 #ifdef __cplusplus
0514 }
0515 #endif
0516
0517 #endif