| 502 | #endif |
| 503 | |
| 504 | CanonicalForm |
| 505 | map (const CanonicalForm& primElem, const Variable& alpha, |
| 506 | const CanonicalForm& F, const Variable& beta) |
| 507 | { |
| 508 | CanonicalForm G= F; |
| 509 | int order= 0; |
| 510 | while (!G.isOne()) |
| 511 | { |
| 512 | G /= primElem; |
| 513 | order++; |
| 514 | } |
| 515 | #if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20503) |
| 516 | // convert mipo |
| 517 | nmod_poly_t mipo1; |
| 518 | convertFacCF2nmod_poly_t(mipo1,getMipo(beta)); |
| 519 | fq_nmod_ctx_t ctx; |
| 520 | fq_nmod_ctx_init_modulus(ctx,mipo1,"t"); |
| 521 | nmod_poly_clear(mipo1); |
| 522 | // convert mipo2 (alpha) |
| 523 | fq_nmod_poly_t mipo2; |
| 524 | convertFacCF2Fq_nmod_poly_t(mipo2,getMipo(alpha),ctx); |
| 525 | fq_nmod_poly_factor_t fac; |
| 526 | fq_nmod_poly_factor_init(fac,ctx); |
| 527 | fq_nmod_poly_roots(fac, mipo2, 0, ctx); |
| 528 | // roots in fac, #=fac->num |
| 529 | int ind=-1; |
| 530 | fq_nmod_t r0,FLINTbeta; |
| 531 | fq_nmod_init(r0, ctx); |
| 532 | fq_nmod_init(FLINTbeta, ctx); |
| 533 | convertFacCF2Fq_nmod_t(FLINTbeta,beta,ctx); |
| 534 | fmpz_t FLINTorder; |
| 535 | fmpz_set_si(FLINTorder,order); |
| 536 | for(int i=0;i< fac->num;i++) |
| 537 | { |
| 538 | // get the root (-abs.term of linear factor) |
| 539 | fq_nmod_poly_get_coeff(r0,fac->poly+i,0,ctx); |
| 540 | fq_nmod_neg(r0,r0,ctx); |
| 541 | // r^order |
| 542 | fq_nmod_pow(r0,r0,FLINTorder,ctx); |
| 543 | // ==beta? |
| 544 | if (fq_nmod_equal(r0,FLINTbeta,ctx)) |
| 545 | { |
| 546 | ind=i; |
| 547 | break; |
| 548 | } |
| 549 | } |
| 550 | fmpz_clear(FLINTorder); |
| 551 | // convert |
| 552 | fq_nmod_poly_get_coeff(r0,fac->poly+ind,0,ctx); |
| 553 | fq_nmod_neg(r0,r0,ctx); |
| 554 | CanonicalForm r1=convertFq_nmod_t2FacCF(r0,beta,ctx); |
| 555 | // cleanup |
| 556 | fq_nmod_poly_factor_clear(fac,ctx); |
| 557 | fq_nmod_clear(r0, ctx); |
| 558 | fq_nmod_clear(FLINTbeta,ctx); |
| 559 | fq_nmod_poly_clear(mipo2,ctx); |
| 560 | fq_nmod_ctx_clear(ctx); |
| 561 | return r1; |
no test coverage detected