Changeset 1e9197 in git


Ignore:
Timestamp:
Nov 27, 2020, 11:06:46 AM (3 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38077648e7239f98078663eb941c3c979511150a')
Children:
815e701a9eb465a5c6526483632b99b0dd38db32
Parents:
a0efc838470abff6a0d11126dd9350fd43451088
Message:
factorization (multivariate) over Zp(a) via FLINT 2.7.0
Location:
factory
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • factory/FLINTconvert.cc

    ra0efc8 r1e9197  
    734734}
    735735
     736#if __FLINT_RELEASE >= 20700
     737static void convFlint_RecPP ( const CanonicalForm & f, ulong * exp, fq_nmod_mpoly_t result, const fq_nmod_mpoly_ctx_t ctx, int N, const fq_nmod_ctx_t fq_ctx )
     738{
     739  // assume f!=0
     740  if ( ! f.inCoeffDomain() )
     741  {
     742    int l = f.level();
     743    for ( CFIterator i = f; i.hasTerms(); i++ )
     744    {
     745      exp[N-l] = i.exp();
     746      convFlint_RecPP( i.coeff(), exp, result, ctx, N, fq_ctx );
     747    }
     748    exp[N-l] = 0;
     749  }
     750  else
     751  {
     752    fq_nmod_t c;
     753    convertFacCF2Fq_nmod_t (c, f, fq_ctx);
     754    fq_nmod_mpoly_push_term_fq_nmod_ui(result,c,exp,ctx);
     755  }
     756}
     757#endif
     758
    736759void convFactoryPFlintMP ( const CanonicalForm & f, nmod_mpoly_t res, nmod_mpoly_ctx_t ctx, int N )
    737760{
     
    765788  Free(exp,N*sizeof(ulong));
    766789}
     790
     791#if __FLINT_RELEASE >= 20700
     792void convFactoryPFlintMP ( const CanonicalForm & f, fq_nmod_mpoly_t res, fq_nmod_mpoly_ctx_t ctx, int N, fq_nmod_ctx_t fq_ctx )
     793{
     794  if (f.isZero()) return;
     795  ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
     796  memset(exp,0,N*sizeof(ulong));
     797  bool save_sym_ff= isOn (SW_SYMMETRIC_FF);
     798  if (save_sym_ff) Off (SW_SYMMETRIC_FF);
     799  convFlint_RecPP( f, exp, res, ctx, N, fq_ctx );
     800  if (save_sym_ff) On(SW_SYMMETRIC_FF);
     801  Free(exp,N*sizeof(ulong));
     802}
     803#endif
    767804
    768805CanonicalForm convFlintMPFactoryP(nmod_mpoly_t f, nmod_mpoly_ctx_t ctx, int N)
     
    953990}
    954991
    955 #endif
    956 
    957 #endif
    958 
    959 
     992#endif // FLINT 2.5.3
     993
     994#if __FLINT_RELEASE >= 20700
     995CFFList
     996convertFLINTFq_nmod_mpoly_factor2FacCFFList (
     997                   fq_nmod_mpoly_factor_t fac,
     998                   const fq_nmod_mpoly_ctx_t& ctx,
     999                   const int N,
     1000                   const fq_nmod_ctx_t& fq_ctx,
     1001                   const Variable alpha)
     1002{
     1003  CFFList result;
     1004
     1005  long i;
     1006
     1007  fq_nmod_t c;
     1008  fq_nmod_init(c,fq_ctx);
     1009  fq_nmod_mpoly_factor_get_constant_fq_nmod(c,fac,ctx);
     1010  result.append(CFFactor(convertFq_nmod_t2FacCF(c,alpha,fq_ctx),1));
     1011  fq_nmod_clear(c,fq_ctx);
     1012
     1013  fq_nmod_mpoly_t p;
     1014  fq_nmod_mpoly_init(p,ctx);
     1015  long exp;
     1016  for (i = 0; i < fac->num; i++)
     1017  {
     1018    fq_nmod_mpoly_factor_get_base(p,fac,i,ctx);
     1019    exp=fq_nmod_mpoly_factor_get_exp_si(fac,i,ctx);
     1020    result.append (CFFactor (convertFq_nmod_mpoly_t2FacCF (
     1021                             p,ctx,N,fq_ctx,alpha), exp));
     1022  }
     1023  fq_nmod_mpoly_clear(p,ctx);
     1024  return result;
     1025}
     1026
     1027void
     1028convertFacCF2Fq_nmod_mpoly_t (fq_nmod_mpoly_t result,
     1029                        const CanonicalForm& f,
     1030                        const fq_nmod_mpoly_ctx_t ctx,
     1031                        const int N,
     1032                        const fq_nmod_ctx_t fq_ctx
     1033                       )
     1034{
     1035  if (f.isZero()) return;
     1036  ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
     1037  memset(exp,0,N*sizeof(ulong));
     1038  convFlint_RecPP( f, exp, result, ctx, N, fq_ctx );
     1039  Free(exp,N*sizeof(ulong));
     1040}
     1041
     1042CanonicalForm
     1043convertFq_nmod_mpoly_t2FacCF (const fq_nmod_mpoly_t f,
     1044                              const fq_nmod_mpoly_ctx_t& ctx,
     1045                              const int N,
     1046                              const fq_nmod_ctx_t& fq_ctx,
     1047                              const Variable alpha)
     1048{
     1049  CanonicalForm result;
     1050  int d=fq_nmod_mpoly_length(f,ctx)-1;
     1051  ulong* exp=(ulong*)Alloc(N*sizeof(ulong));
     1052  fq_nmod_t c;
     1053  fq_nmod_init(c,fq_ctx);
     1054  for(int i=d; i>=0; i--)
     1055  {
     1056    fq_nmod_mpoly_get_term_coeff_fq_nmod(c,f,i,ctx);
     1057    fq_nmod_mpoly_get_term_exp_ui(exp,f,i,ctx);
     1058    CanonicalForm term=convertFq_nmod_t2FacCF(c,alpha,fq_ctx);
     1059    for ( int i = 0; i <N; i++ )
     1060    {
     1061      if (exp[i]!=0) term*=CanonicalForm( Variable( N-i ), exp[i] );
     1062    }
     1063    result+=term;
     1064  }
     1065  Free(exp,N*sizeof(ulong));
     1066  return result;
     1067}
     1068
     1069#endif
     1070#endif // FLINT
     1071
     1072
  • factory/FLINTconvert.h

    ra0efc8 r1e9197  
    4343#if ( __FLINT_RELEASE >= 20503)
    4444#include <flint/fmpq_mpoly.h>
     45#include <flint/fq_nmod_mpoly_factor.h>
    4546#endif
    4647#endif
     
    137138                                        );
    138139
     140/// conversion of a FLINT factorization over Zp(a) to a CFFList
     141CFFList
     142convertFLINTFq_nmod_mpoly_factor2FacCFFList (
     143                   fq_nmod_mpoly_factor_t fac,    ///< [in] a fq_nmod_mpoly_factor_t
     144                   const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
     145                   const int N,                   ///< [in] #vars
     146                   const fq_nmod_ctx_t& fq_ctx,   ///< [in] fq context
     147                   const Variable alpha           ///< [in] alpha
     148                                        );
     149
    139150/// conversion of a factory univariate poly over Z to a FLINT poly over
    140151/// Z/p (for non word size p)
     
    164175convertFq_nmod_t2FacCF (const fq_nmod_t poly, ///< [in] fq_nmod_t
    165176                        const Variable& alpha, ///< [in] algebraic variable
    166                         const fq_nmod_ctx_t ctx ///<[in] context
     177                        const fq_nmod_ctx_t ctx ///<[in] context
    167178                       );
    168179
     
    180191                        const CanonicalForm& f, ///< [in] element of Fq
    181192                        const fq_nmod_ctx_t ctx ///< [in] Fq context
     193                       );
     194
     195/// conversion of a factory polynomial over of F_q to a FLINT fq_nmod_mpoly_t, does not do any
     196/// memory allocation for poly
     197void
     198convertFacCF2Fq_nmod_mpoly_t (fq_nmod_mpoly_t result, ///< [in,out] fq_nmod_mpoly__t
     199                        const CanonicalForm& f,       ///< [in] poly over Fq
     200                        const fq_nmod_mpoly_ctx_t ctx,///< [in] context
     201                        const int N,                  ///< [in] #vars
     202                        const fq_nmod_ctx_t fq_ctx    ///< [in] fq context
    182203                       );
    183204
     
    279300CanonicalForm convFlintMPFactoryP(fmpq_mpoly_t f, fmpq_mpoly_ctx_t ctx, int N);
    280301CanonicalForm convFlintMPFactoryP(fmpz_mpoly_t f, fmpz_mpoly_ctx_t ctx, int N);
    281 #endif
    282 #endif
    283 #endif
     302#endif // FLINT 2.5.3
     303#if __FLINT_RELEASE >= 20700
     304CanonicalForm
     305convertFq_nmod_mpoly_t2FacCF (const fq_nmod_mpoly_t poly,    ///< [in]
     306                              const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
     307                              const int N,                   ///< [in] #vars
     308                              const fq_nmod_ctx_t& fq_ctx,   ///< [in] fq context
     309                              const Variable alpha           ///< [in] alpha
     310                         );
     311#endif // FLINT2.7.0
     312#endif // FLINT
     313#endif
  • factory/cf_factor.cc

    ra0efc8 r1e9197  
    4747#include <flint/nmod_mpoly_factor.h>
    4848#include <flint/fmpq_mpoly_factor.h>
     49#include <flint/fq_nmod_mpoly_factor.h>
    4950#endif
    5051#endif
     
    880881    else // char p, multivariate
    881882    {
    882       #ifdef HAVE_NTL
     883      #if (HAVE_FLINT && __FLINT_RELEASE >= 20700)
     884        // use FLINT
     885        nmod_poly_t FLINTmipo, leadingCoeff;
     886        fq_nmod_ctx_t fq_con;
     887        fq_nmod_mpoly_ctx_t fq_mpoly_ctx;
     888
     889        nmod_poly_init (FLINTmipo, ch);
     890        convertFacCF2nmod_poly_t (FLINTmipo, getMipo (alpha));
     891
     892        fq_nmod_ctx_init_modulus (fq_con, FLINTmipo, "Z");
     893        fq_nmod_mpoly_ctx_init(fq_mpoly_ctx,f.level(),ORD_LEX,fq_con);
     894
     895        fq_nmod_mpoly_t FLINTF;
     896        fq_nmod_mpoly_init(FLINTF,ctx);
     897        convertFacCF2Fq_nmod_mpoly_t(FLINTF,f,fq_mpoly_ctx,f.level(),fq_con);
     898        fq_nmod_mpoly_factor_t res;
     899        fq_nmod_mpoly_factor_init (res, fq_mpoly_ctx);
     900        fq_nmod_mpoly_factor (res, FLINTF, fq_mpoly_ctx);
     901        F= convertFLINTFq_nmod_mpoly_factor2FacCFFList (res, fq_mpoly_ctx,f.level(),fq_con,alpha);
     902        //F.insert (CFFactor (Lc (f), 1));
     903
     904        fq_nmod_mpoly_factor_clear (res, fq_mpoly_ctx);
     905        fq_nmod_mpoly_clear (FLINTF, fq_mpoly_ctx);
     906        nmod_poly_clear (FLINTmipo);
     907        fq_nmod_mpoly_ctx_clear (fq_mpoly_ctx);
     908        fq_nmod_ctx_clear (fq_con);
     909        if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF);
     910        return F;
     911      #elif defined(HAVE_NTL)
    883912      F= FqFactorize (f, alpha);
    884913      #else
    885       factoryError ("multivariate factorization over Z/pZ(alpha) depends on NTL(missing)");
     914      factoryError ("multivariate factorization over Z/pZ(alpha) depends on NTL/Flint(missing)");
    886915      return CFFList (CFFactor (f, 1));
    887916      #endif
     
    896925    else //Q(a)[x1,...,xn]
    897926    {
    898       #ifdef HAVE_NTL
    899927      F= ratFactorize (f, alpha);
    900       #else
    901       factoryError ("multivariate factorization over Q(alpha) depends on NTL(missing)");
    902       return CFFList (CFFactor (f, 1));
    903       #endif
    904928    }
    905929  }
  • factory/facBivar.h

    ra0efc8 r1e9197  
    2727#include "cfNewtonPolygon.h"
    2828#include "fac_util.h"
     29#include "cf_algorithm.h"
    2930
    3031TIMING_DEFINE_PRINT(fac_bi_sqrf)
     
    4243/// @ return @a ratBiSqrfFactorize returns a list of monic factors, the first
    4344///         element is the leading coefficient.
    44 #ifdef HAVE_NTL
    4545inline
    4646CFList
     
    276276}
    277277
    278 #endif
    279 
    280278/// convert a CFFList to a CFList by dropping the multiplicity
    281279CFList conv (const CFFList& L ///< [in] a CFFList
  • factory/facFactorize.h

    ra0efc8 r1e9197  
    173173}
    174174#endif
    175 #endif
    176175
Note: See TracChangeset for help on using the changeset viewer.