Changeset 9e2029c in git


Ignore:
Timestamp:
Jun 5, 2014, 5:11:56 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
0bd659380ba176abcaad091e0fdef5817cb9954d
Parents:
f8df35286530f57c88ffeb98595d16aa5edd60f4
git-author:
Martin Lee <martinlee84@web.de>2014-06-05 17:11:56+02:00
git-committer:
Martin Lee <martinlee84@web.de>2014-06-17 14:08:30+02:00
Message:
chg: more checks for one to one correspondence of bi. factors and multi. factors
Location:
factory
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • factory/facAbsFact.cc

    rf8df35 r9e2029c  
    460460  else if (biFactors.length() > minFactorsLength)
    461461    refineBiFactors (A, biFactors, Aeval2, evaluation, minFactorsLength);
     462  minFactorsLength= tmin (minFactorsLength, biFactors.length());
     463
     464  CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
     465
     466  sortByUniFactors (Aeval2, lengthAeval2, uniFactors, biFactors, evaluation);
     467
     468  minFactorsLength= tmin (minFactorsLength, biFactors.length());
     469
     470  if (minFactorsLength == 1)
     471  {
     472    factors.append (CFAFactor (A, 1, 1));
     473    decompress (factors, N);
     474    if (isOn (SW_RATIONAL))
     475      normalize (factors);
     476    delete [] Aeval2;
     477    return factors;
     478  }
    462479
    463480  bool found= false;
     
    502519    }
    503520  }
    504 
    505   CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
    506 
    507   sortByUniFactors (Aeval2, lengthAeval2, uniFactors, evaluation);
    508521
    509522  CFList * oldAeval= new CFList [lengthAeval2];
  • factory/facFactorize.cc

    rf8df35 r9e2029c  
    394394  minFactorsLength= tmin (minFactorsLength, biFactors.length());
    395395
     396  CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
     397
     398  sortByUniFactors (Aeval2, lengthAeval2, uniFactors, biFactors, evaluation);
     399
     400  minFactorsLength= tmin (minFactorsLength, biFactors.length());
     401
     402  if (minFactorsLength == 1)
     403  {
     404    factors.append (A);
     405    appendSwapDecompress (factors, contentAFactors, N, 0, 0, x);
     406    if (isOn (SW_RATIONAL))
     407      normalize (factors);
     408    delete [] Aeval2;
     409    return factors;
     410  }
     411
    396412  if (differentSecondVar == lengthAeval2)
    397413  {
     
    421437    }
    422438  }
    423 
    424   CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
    425 
    426   sortByUniFactors (Aeval2, lengthAeval2, uniFactors, evaluation);
    427439
    428440  CFList * oldAeval= new CFList [lengthAeval2];
  • factory/facFqFactorize.cc

    rf8df35 r9e2029c  
    20042004}
    20052005
     2006void
     2007checkHelper (const CanonicalForm& f1, CFList& factors1, CFList& factors2,
     2008             CFList& l1, CFList& l2)
     2009{
     2010  CanonicalForm g1= f1, g2;
     2011  CFListIterator iter1= factors1, iter2= factors2;
     2012  for (; iter1.hasItem(); iter1++, iter2++)
     2013  {
     2014    g2= gcd (g1, iter1.getItem());
     2015    if (!g2.inCoeffDomain())
     2016    {
     2017      l1.append (iter1.getItem());
     2018      l2.append (iter2.getItem());
     2019      g1 /= g2;
     2020    }
     2021  }
     2022  factors1= Difference (factors1, l1);
     2023  factors2= Difference (factors2, l2);
     2024}
     2025
     2026/// check if univariate factors @a factors2 of @a factors3 coincide with
     2027/// univariate factors of @a factors1 and recombine if necessary.
     2028/// The recombined factors of @a factors1 are returned and @a factors3 is
     2029/// recombined accordingly.
     2030CFList
     2031checkOneToOne (const CFList& factors1, const CFList& factors2, CFList& factors3,
     2032               const CanonicalForm& evalPoint, const Variable& x)
     2033{
     2034  CFList uniFactorsOfFactors1;
     2035  CFList result, result2;
     2036  CFList bad1= factors2;
     2037  CFListIterator iter, iter2, iter3;
     2038  CanonicalForm tmp;
     2039  int pos;
     2040
     2041  for (iter= factors1; iter.hasItem(); iter++)
     2042  {
     2043    tmp= iter.getItem() (evalPoint, x);
     2044    tmp /= Lc (tmp);
     2045    if (pos= findItem (factors2, tmp))
     2046    {
     2047      result2.append (getItem (factors3, pos));
     2048      result.append (iter.getItem());
     2049      bad1= Difference (bad1, CFList (tmp));
     2050    }
     2051    else
     2052      uniFactorsOfFactors1.append (tmp);
     2053  }
     2054
     2055  CFList bad2, bad3;
     2056  bad2= Difference (factors1, result);
     2057  bad3= Difference (factors3, result2);
     2058  CFList tmp2, tmp3;
     2059  CanonicalForm g1, g2, g3, g4;
     2060
     2061  while (!uniFactorsOfFactors1.isEmpty())
     2062  {
     2063    tmp= uniFactorsOfFactors1.getFirst();
     2064    checkHelper (tmp, bad1, bad3, tmp2, tmp3);
     2065    g1= prod (tmp2);
     2066    g2= prod (tmp3);
     2067    tmp2= CFList();
     2068    tmp3= CFList();
     2069    checkHelper (g1, uniFactorsOfFactors1, bad2, tmp2, tmp3);
     2070    g3= prod (tmp2);
     2071    g4= prod (tmp3);
     2072    tmp2= CFList();
     2073    tmp3= CFList();
     2074    do
     2075    {
     2076      checkHelper (g3, bad1, bad3, tmp2, tmp3);
     2077      g1 *= prod (tmp2);
     2078      g2 *= prod (tmp3);
     2079      tmp2= CFList();
     2080      tmp3= CFList();
     2081      checkHelper (g1, uniFactorsOfFactors1, bad2, tmp2, tmp3);
     2082      g3 *= prod (tmp2);
     2083      g4 *= prod (tmp3);
     2084      tmp2= CFList();
     2085      tmp3= CFList();
     2086    } while (!bad2.isEmpty() && !bad3.isEmpty());
     2087    result.append (g4);
     2088    result2.append (g2);
     2089  }
     2090
     2091  factors3= result2;
     2092  return result;
     2093}
     2094
    20062095//recombine bivariate factors in case one bivariate factorization yields less
    20072096// factors than the other
     
    20212110  CFArray TT;
    20222111  TT= copy (factors1);
     2112  int recombinations= 0;
    20232113  while (T.length() >= 2*s && s <= thres)
    20242114  {
     
    20282118      {
    20292119        delete [] v;
    2030         result.append (prod (T));
     2120        if (recombinations == factors2.length() - 1)
     2121          result.append (prod (T));
     2122        else
     2123          result= Union (result, T);
    20312124        return result;
    20322125      }
     
    20372130      if (find (factors2, buf))
    20382131      {
     2132        recombinations++;
    20392133        T= Difference (T, S);
    20402134        result.append (prod (S));
     
    20472141    if (T.length() < 2*s || T.length() == s)
    20482142    {
     2143      if (recombinations == factors2.length() - 1)
     2144        result.append (prod (T));
     2145      else
     2146        result= Union (result, T);
    20492147      delete [] v;
    2050       result.append (prod (T));
    20512148      return result;
    20522149    }
     
    20592156  if (T.length() < 2*s)
    20602157  {
    2061     result.append (prod (T));
     2158    result= Union (result, T);
    20622159    return result;
    20632160  }
     
    21342231
    21352232void sortByUniFactors (CFList*& Aeval, int AevalLength,
    2136                        const CFList& uniFactors, const CFList& evaluation
     2233                       CFList& uniFactors, CFList& biFactors,
     2234                       const CFList& evaluation
    21372235                      )
    21382236{
     
    21432241  CFList LCs, buf;
    21442242  CFArray l;
    2145   int pos, index;
     2243  int pos, index, checklength;
    21462244  bool leaveLoop=false;
     2245recurse:
    21472246  for (int j= 0; j < AevalLength; j++)
    21482247  {
     
    21732272                                 Aeval[j].length() - uniFactors.length() + 1,
    21742273                                 evalPoint, v);
     2274
     2275      checklength= biFactors.length();
     2276      Aeval[j]= checkOneToOne (Aeval[j], uniFactors, biFactors, evalPoint, v);
     2277      if (checklength > biFactors.length())
     2278      {
     2279        uniFactors= buildUniFactors (biFactors, evaluation.getLast(),
     2280                                     Variable (2));
     2281        goto recurse;
     2282      }
    21752283
    21762284      buf= buildUniFactors (Aeval[j], evalPoint, v);
     
    27762884multiFactorize (const CanonicalForm& F, const ExtensionInfo& info)
    27772885{
    2778 
    27792886  if (F.inCoeffDomain())
    27802887    return CFList (F);
     
    30913198  minFactorsLength= tmin (minFactorsLength, biFactors.length());
    30923199
     3200  CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
     3201
     3202  sortByUniFactors (Aeval2, lengthAeval2, uniFactors, biFactors, evaluation);
     3203
     3204  minFactorsLength= tmin (minFactorsLength, biFactors.length());
     3205
     3206  if (minFactorsLength == 1)
     3207  {
     3208    if (extension)
     3209    {
     3210      CFList source, dest;
     3211      A= mapDown (A, info, source, dest);
     3212    }
     3213    factors.append (A);
     3214    appendSwapDecompress (factors, contentAFactors, N, swapLevel,
     3215                          swapLevel2, x);
     3216    if (!extension)
     3217      normalize (factors);
     3218    delete [] Aeval2;
     3219    return factors;
     3220  }
     3221
    30933222  if (differentSecondVar == lengthAeval2)
    30943223  {
     
    31233252    }
    31243253  }
    3125 
    3126   CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
    3127 
    3128   sortByUniFactors (Aeval2, lengthAeval2, uniFactors, evaluation);
    31293254
    31303255  CFList * oldAeval= new CFList [lengthAeval2]; //TODO use bufAeval2 for this
  • factory/facFqFactorize.h

    rf8df35 r9e2029c  
    565565
    566566/// refine a bivariate factorization of A with l factors to one with
    567 /// minFactorsLength
     567/// minFactorsLength if possible
    568568void
    569569refineBiFactors (const CanonicalForm& A,  ///< [in] some poly
     
    589589
    590590/// sort bivariate factors in Aeval such that their corresponding univariate
    591 /// factors coincide with uniFactors
     591/// factors coincide with uniFactors, uniFactors and biFactors may get
     592/// recombined if necessary
    592593void sortByUniFactors (CFList*& Aeval,          ///< [in,out] array of bivariate
    593594                                                ///< factors
    594595                       int AevalLength,         ///< [in] length of Aeval
    595                        const CFList& uniFactors,///< [in] univariate factors
     596                       CFList& uniFactors,      ///< [in,out] univariate factors
     597                       CFList& biFactors,       ///< [in,out] bivariate factors
    596598                       const CFList& evaluation ///< [in] evaluation point
    597599                      );
Note: See TracChangeset for help on using the changeset viewer.