Changeset 4abcd2 in git


Ignore:
Timestamp:
Jun 29, 2019, 3:08:10 PM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
03bb93fba98bf9a4940362065c868e03f40d30490c8bd5e3c25fc9eee3515f8acf944ee5ebe1696b38f64f390d4436be348da6ef47e2af0b9b28e73bd9ee4473fdf11f08fe02b858ed26cfb2acacddb7
Parents:
6fe48efa5355b153c6b4c1888a39b03726d3ca4c
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2019-06-29 15:08:10+02:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2019-06-29 15:08:45+02:00
Message:
add: gcd via flint (over QQ,ZZ/p)
Location:
libpolys/polys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/clapsing.cc

    r6fe48e r4abcd2  
    2020#include "monomials/ring.h"
    2121#include "simpleideals.h"
     22#include "polys/flintconv.h"
     23#include "polys/flint_mpoly.h"
    2224
    2325
     
    5557    return p_GcdMon(g,f,r);
    5658  }
    57 
     59  #ifdef HAVE_FLINT
     60  #if __FLINT_RELEASE >= 20503
     61  if (rField_is_Zp(r))
     62  {
     63    nmod_mpoly_ctx_t ctx;
     64    if (!convSingRFlintR(ctx,r))
     65    {
     66      return Flint_GCD_MP(f,pLength(f),g,pLength(g),ctx,r);
     67    }
     68  }
     69  else if (rField_is_Q(r))
     70  {
     71    fmpq_mpoly_ctx_t ctx;
     72    if (!convSingRFlintR(ctx,r))
     73    {
     74//    printf("FlintQ\n");
     75      poly res=Flint_GCD_MP(f,pLength(f),g,pLength(g),ctx,r);
     76      res=p_Cleardenom(res,r);
     77    }
     78  }
     79  #endif
     80  #endif
    5881  Off(SW_RATIONAL);
    5982  if (rField_is_Q(r) || rField_is_Zp(r) || rField_is_Z(r)
     
    6386    CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g, r ) );
    6487    res=convFactoryPSingP( gcd( F, G ) , r);
    65     if (rField_is_Zp(r)) p_Norm(res,r);
     88    if ( rField_is_Zp(r)) p_Norm(res,r);
    6689  }
    6790  // and over Q(a) / Fp(a)
  • libpolys/polys/flint_mpoly.cc

    r6fe48e r4abcd2  
    195195  return pres;
    196196}
     197poly Flint_GCD_MP(poly p,int lp,poly q,int lq,nmod_mpoly_ctx_t ctx,const ring r)
     198{
     199  nmod_mpoly_t pp,qq,res;
     200  convSingPFlintMP(pp,ctx,p,lp,r);
     201  convSingPFlintMP(qq,ctx,q,lq,r);
     202  int bits=SI_LOG2(r->bitmask);
     203  nmod_mpoly_init3(res,lp*lq,bits,ctx);
     204  int ok=nmod_mpoly_gcd(res,pp,qq,ctx);
     205  poly pres;
     206  if (ok)
     207  {
     208    pres=convFlintMPSingP(res,ctx,r);
     209    p_Test(pres,r);
     210  }
     211  else
     212  {
     213    pres=p_One(r);
     214  }
     215  nmod_mpoly_clear(res,ctx);
     216  nmod_mpoly_clear(pp,ctx);
     217  nmod_mpoly_clear(qq,ctx);
     218  nmod_mpoly_ctx_clear(ctx);
     219  return pres;
     220}
     221
     222poly Flint_GCD_MP(poly p,int lp,poly q,int lq,fmpq_mpoly_ctx_t ctx,const ring r)
     223{
     224  fmpq_mpoly_t pp,qq,res;
     225  convSingPFlintMP(pp,ctx,p,lp,r);
     226  convSingPFlintMP(qq,ctx,q,lq,r);
     227  int bits=SI_LOG2(r->bitmask);
     228  fmpq_mpoly_init3(res,lp*lq,bits,ctx);
     229  int ok=fmpq_mpoly_gcd(res,pp,qq,ctx);
     230  poly pres;
     231  if (ok)
     232  {
     233    pres=convFlintMPSingP(res,ctx,r);
     234    p_Test(pres,r);
     235  }
     236  else
     237  {
     238    pres=p_One(r);
     239  }
     240  fmpq_mpoly_clear(res,ctx);
     241  fmpq_mpoly_clear(pp,ctx);
     242  fmpq_mpoly_clear(qq,ctx);
     243  fmpq_mpoly_ctx_clear(ctx);
     244  return pres;
     245}
    197246#endif
    198247#endif
  • libpolys/polys/flint_mpoly.h

    r6fe48e r4abcd2  
    1313
    1414#if __FLINT_RELEASE >= 20503
    15 #include <flint/fmpz.h>
    1615#include <flint/fmpq.h>
    17 #include <flint/fmpz_poly.h>
    1816#include <flint/fmpq_poly.h>
    1917#include <flint/fmpq_mpoly.h>
     
    2725poly convFlintMPSingP(nmod_mpoly_t p, nmod_mpoly_ctx_t ctx, const ring r);
    2826poly Flint_Mult_MP(poly p,int lp,poly q,int lq,nmod_mpoly_ctx_t ctx, const ring r);
     27poly Flint_GCD_MP(poly p,int lp,poly q,int lq,nmod_mpoly_ctx_t ctx,const ring r);
     28poly Flint_GCD_MP(poly p,int lp,poly q,int lq,fmpq_mpoly_ctx_t ctx,const ring r);
    2929#endif
    3030#endif
Note: See TracChangeset for help on using the changeset viewer.