Changeset 78242cd in git for factory


Ignore:
Timestamp:
Jun 28, 2020, 3:10:20 PM (4 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
1c0d95d0bcebabfb7213acde81c0ceb20f2448c2
Parents:
63df50ee86f3f0c029f6e254f3c345c9f6fb0dc6
Message:
factory: FindRoots for FLINT
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_map_ext.cc

    r63df50e r78242cd  
    505505  }
    506506  int p= getCharacteristic ();
     507  #ifdef HAVE_FLINT
     508  // convert mipo
     509  nmod_poly_t mipo1;
     510  convertFacCF2nmod_poly_t(mipo1,getMipo(beta));
     511  fq_nmod_ctx_t ctx;
     512  fq_nmod_ctx_init_modulus(ctx,mipo1,"t");
     513  nmod_poly_clear(mipo1);
     514  // convert mipo2 (alpha)
     515  fq_nmod_poly_t mipo2;
     516  convertFacCF2Fq_nmod_poly_t(mipo2,getMipo(alpha),ctx);
     517  fq_nmod_poly_factor_t fac;
     518  fq_nmod_poly_factor_init(fac,ctx);
     519  fq_nmod_poly_roots(fac, mipo2, 0, ctx);
     520  // roots in fac, #=fac->num
     521  int ind=-1;
     522  fq_nmod_t r0,FLINTbeta;
     523  fq_nmod_init(r0, ctx);
     524  fq_nmod_init(FLINTbeta, ctx);
     525  convertFacCF2Fq_nmod_t(FLINTbeta,beta,ctx);
     526  fmpz_t FLINTorder;
     527  fmpz_set_si(FLINTorder,order);
     528  for(int i=0;i< fac->num;i++)
     529  {
     530    // get the root (-abs.term of linear factor)
     531    fq_nmod_poly_get_coeff(r0,fac->poly+i,0,ctx);
     532    fq_nmod_neg(r0,r0,ctx);
     533    // r^order
     534    fq_nmod_pow(r0,r0,FLINTorder,ctx);
     535    // ==beta?
     536    if (fq_nmod_equal(r0,FLINTbeta,ctx))
     537    {
     538       ind=i;
     539       break;
     540    }
     541  }
     542  fmpz_clear(FLINTorder);
     543  // convert
     544  fq_nmod_poly_get_coeff(r0,fac->poly+ind,0,ctx);
     545  fq_nmod_neg(r0,r0,ctx);
     546  CanonicalForm r1=convertFq_nmod_t2FacCF(r0,beta);
     547  // cleanup
     548  fq_nmod_poly_factor_clear(fac,ctx);
     549  fq_nmod_clear(r0, ctx);
     550  fq_nmod_clear(FLINTbeta,ctx);
     551  fq_nmod_poly_clear(mipo2,ctx);
     552  fq_nmod_ctx_clear(ctx);
     553  return r1;
     554  #elif defined(HAVE_NTL)
    507555  if (fac_NTL_char != p)
    508556  {
     
    525573  }
    526574  return (convertNTLzzpE2CF (roots[ind], beta));
     575  #endif
    527576}
    528577
Note: See TracChangeset for help on using the changeset viewer.