Changeset ad0177 in git


Ignore:
Timestamp:
Mar 6, 2012, 9:48:34 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
24c6177e872b135f0188fea998eb45a75e3fde6e
Parents:
54af8a51cc8091a4687fb55bf401e31a0478bc1e
git-author:
Martin Lee <martinlee84@web.de>2012-03-06 21:48:34+01:00
git-committer:
Martin Lee <martinlee84@web.de>2012-04-04 14:42:27+02:00
Message:
chg: use uniFdivides in factorRecombination
chg: take care of GF in uniFdivides and univariate *,/,%
chg: switch on SW_RATIONAL if necessary
Location:
factory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • factory/facFqBivar.cc

    r54af8a5 rad0177  
    4343TIMING_DEFINE_PRINT(fac_hensel_lift12)
    4444
    45 CanonicalForm prodMod0 (const CFList& L, const CanonicalForm& M)
     45CanonicalForm prodMod0 (const CFList& L, const CanonicalForm& M, const modpk& b)
    4646{
    4747  if (L.isEmpty())
     
    5050    return mod (L.getFirst()(0, 1) , M);
    5151  else if (L.length() == 2)
    52     return mod (mulNTL (L.getFirst()(0, 1),L.getLast()(0, 1)), M);
     52    return mod (mulNTL (L.getFirst()(0, 1),L.getLast()(0, 1), b), M);
    5353  else
    5454  {
     
    6060      tmp1.append (i.getItem());
    6161    tmp2= Difference (L, tmp1);
    62     buf1= prodMod0 (tmp1, M);
    63     buf2= prodMod0 (tmp2, M);
    64     return mod (mulNTL (buf1,buf2), M);
     62    buf1= prodMod0 (tmp1, M, b);
     63    buf2= prodMod0 (tmp2, M, b);
     64    return mod (mulNTL (buf1,buf2, b), M);
    6565  }
    6666}
     
    487487  bool recombination= false;
    488488  CanonicalForm test;
    489   CanonicalForm buf0= buf (0, x)*LCBuf;
     489  CanonicalForm buf0= mulNTL (buf (0, x), LCBuf, b);
     490  bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) || getCharacteristic() > 0;
    490491  while (T.length() >= 2*s && s <= thres)
    491492  {
     
    521522      else
    522523      {
    523         test= prodMod0 (S, M);
    524         test *= LCBuf;
    525         test = mod (test, M);
    526         if (b.getp() != 0)
    527           test= b(test);
    528         if (fdivides (test, buf0))
     524        test= prodMod0 (S, M, b);
     525        test= mulNTL (test, LCBuf, b);
     526        test= mod (test, M);
     527        if (uniFdivides (test, buf0))
    529528        {
    530529          S.insert (LCBuf);
     
    534533            g= b(g);
    535534          g /= content (g, x);
     535          if (!isRat)
     536            On (SW_RATIONAL);
    536537          if (fdivides (g, buf, quot))
    537538          {
     
    543544            l -= degree (g);
    544545            M= power (y, l);
    545             buf0= buf (0, x)*LCBuf;
     546            if (!isRat)
     547              Off (SW_RATIONAL);
     548            buf0= mulNTL (buf (0, x), LCBuf, b);
    546549            // compute new possible degree pattern
    547550            bufDegs2= DegreePattern (T);
     
    569572            if (nosubset) break;
    570573          }
     574          if (!isRat)
     575            Off (SW_RATIONAL);
    571576        }
    572577      }
     
    661666  CanonicalForm buf1= mulNTL (buf (1,x), LCBuf, b);
    662667  CanonicalForm test0, test1;
     668  bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) || getCharacteristic() > 0;
    663669  for (CFListIterator i= factors; i.hasItem(); i++, l++)
    664670  {
     
    677683            g= b(g);
    678684          g /= content (g, x);
     685          if (!isRat)
     686            On (SW_RATIONAL);
    679687          if (fdivides (g, buf, quot))
    680688          {
     
    684692            d -= degree (g);
    685693            LCBuf= LC (buf, x);
     694            if (!isRat)
     695              Off (SW_RATIONAL);
    686696            buf0= mulNTL (buf (0,x), LCBuf, b);
    687697            buf1= mulNTL (buf (1,x), LCBuf, b);
     
    699709            }
    700710          }
     711          if (!isRat)
     712            Off (SW_RATIONAL);
    701713        }
    702714      }
  • factory/facFqBivar.h

    r54af8a5 rad0177  
    578578CanonicalForm prodMod0 (const CFList& L,       ///< [in] a list of compressed,
    579579                                               ///< bivariate polynomials
    580                         const CanonicalForm& M ///< [in] a power of Variable (2)
     580                        const CanonicalForm& M,///< [in] a power of Variable (2)
     581                        const modpk& b= modpk()///< [in] coeff bound
    581582                       );
    582583
  • factory/facMul.cc

    r54af8a5 rad0177  
    397397mulNTL (const CanonicalForm& F, const CanonicalForm& G, const modpk& b)
    398398{
     399  if (CFFactory::gettype() == GaloisFieldDomain)
     400    return F*G;
    399401  if (F.inCoeffDomain() || G.inCoeffDomain() || getCharacteristic() == 0)
    400402  {
     
    480482  ASSERT (F.isUnivariate() && G.isUnivariate(), "expected univariate polys");
    481483  ASSERT (F.level() == G.level(), "expected polys of same level");
    482   if (CFFactory::gettype() == GaloisFieldDomain)
    483     return F*G;
    484484  zz_p::init (getCharacteristic());
    485485  Variable alpha;
     
    517517modNTL (const CanonicalForm& F, const CanonicalForm& G, const modpk& b)
    518518{
     519  if (CFFactory::gettype() == GaloisFieldDomain)
     520    return mod (F, G);
    519521  if (F.inCoeffDomain() && G.isUnivariate())
    520522  {
     
    593595  ASSERT (F.isUnivariate() && G.isUnivariate(), "expected univariate polys");
    594596  ASSERT (F.level() == G.level(), "expected polys of same level");
    595   if (CFFactory::gettype() == GaloisFieldDomain)
    596     return mod (F, G);
    597597  zz_p::init (getCharacteristic());
    598598  Variable alpha;
     
    630630divNTL (const CanonicalForm& F, const CanonicalForm& G, const modpk& b)
    631631{
     632  if (CFFactory::gettype() == GaloisFieldDomain)
     633    return div (F, G);
    632634  if (F.inCoeffDomain() && G.isUnivariate())
    633635  {
     
    736738  ASSERT (F.isUnivariate() && G.isUnivariate(), "expected univariate polys");
    737739  ASSERT (F.level() == G.level(), "expected polys of same level");
    738   if (CFFactory::gettype() == GaloisFieldDomain)
    739     return div (F, G);
    740740  zz_p::init (getCharacteristic());
    741741  Variable alpha;
     
    27992799uniFdivides (const CanonicalForm& A, const CanonicalForm& B)
    28002800{
     2801  if (B.isZero())
     2802    return true;
     2803  if (A.isZero())
     2804    return false;
     2805  if (CFFactory::gettype() == GaloisFieldDomain)
     2806    return fdivides (A, B);
    28012807  int p= getCharacteristic();
    28022808  if (p > 0)
     
    28062812    if (hasFirstAlgVar (A, alpha) || hasFirstAlgVar (B, alpha))
    28072813    {
     2814      if (A.inCoeffDomain() || B.inCoeffDomain())
     2815      {
     2816        if (A.inCoeffDomain())
     2817          return true;
     2818        else
     2819          return false;
     2820      }
    28082821      zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha));
    28092822      zz_pE::init (NTLMipo);
     
    28322845  {
    28332846    fmpq_poly_t FLINTA,FLINTB;
    2834     fmpq_poly_init (FLINTA);
    2835     fmpq_poly_init (FLINTB);
    28362847    convertFacCF2Fmpq_poly_t (FLINTA, A);
    28372848    convertFacCF2Fmpq_poly_t (FLINTB, B);
     
    28532864  return R.isZero();
    28542865#else
    2855   return fdivides (A, B); //maybe NTL?
     2866  bool isRat= isOn (SW_RATIONAL);
     2867  if (!isRat)
     2868    On (SW_RATIONAL);
     2869  bool result= fdivides (A, B);
     2870  if (!isRat)
     2871    Off (SW_RATIONAL);
     2872  return result; //maybe NTL?
    28562873#endif
    28572874}
Note: See TracChangeset for help on using the changeset viewer.