Changeset edc416 in git


Ignore:
Timestamp:
Jun 17, 2014, 5:57:27 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
e6a143985100941ba5863e562ed668184e2e6b27
Parents:
50a6c59553a4e9ed5c3b72c3937a614ffbeac4f5ef861dca4884e7cc85c510a8c52ad684bddcd892
Message:
Merge pull request #604 from mmklee/bug_fix

Bug fix
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/syzextra/syzextra.cc

    ref861dc redc416  
    388388{
    389389  const int sizeNew = IDELEMS(id);
    390 
     390  typedef int(*cmp_fct)(const void *, const void *);
     391
     392#ifdef HAVE_QSORT_R
    391393#if (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || defined __FREEBSD__ || defined __BSD__ || defined OpenBSD3_1 || defined OpenBSD3_9)
    392394#define qsort_my(m, s, ss, r, cmp) qsort_r(m, s, ss, r, cmp)
     
    394396#define qsort_my(m, s, ss, r, cmp) qsort_r(m, s, ss, cmp, r)
    395397#else
    396 #define qsort_my(m, s, ss, r, cmp) qsort(m, s, ss, cmp)
     398#define qsort_my(m, s, ss, r, cmp) qsort(m, s, ss, (cmp_fct)(cmp))
     399#endif
     400#else
     401#define qsort_my(m, s, ss, r, cmp) qsort(m, s, ss, (cmp_fct)(cmp))
    397402#endif
    398403
  • configure.ac

    ref861dc redc416  
    4242AC_CHECK_HEADERS(unistd.h iostream.h sys/time.h sys/times.h asm/sigcontext.h)
    4343
    44 AC_CHECK_FUNCS(readlink getcwd getwd setenv putenv)
     44AC_CHECK_FUNCS(readlink getcwd getwd setenv putenv qsort_r)
    4545
    4646
  • factory/cf_gcd_smallp.cc

    r50a6c5 redc416  
    676676    if (d0 == 0)
    677677    {
     678      if (inextension)
     679      {
     680        CFList u, v;
     681        ppA= mapDown (ppA, prim_elem, im_prim_elem, alpha, u, v);
     682        ppB= mapDown (ppB, prim_elem, im_prim_elem, alpha, u, v);
     683      }
    678684      coF= N (ppA*(cA/gcdcAcB));
    679685      coG= N (ppB*(cB/gcdcAcB));
  • factory/facAbsFact.cc

    r50a6c5 redc416  
    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

    r50a6c5 redc416  
    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

    r50a6c5 redc416  
    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  if (factors3.length() != result2.length())
     2092    factors3= result2;
     2093  return result;
     2094}
     2095
    20062096//recombine bivariate factors in case one bivariate factorization yields less
    20072097// factors than the other
     
    20212111  CFArray TT;
    20222112  TT= copy (factors1);
     2113  int recombinations= 0;
    20232114  while (T.length() >= 2*s && s <= thres)
    20242115  {
     
    20282119      {
    20292120        delete [] v;
    2030         result.append (prod (T));
     2121        if (recombinations == factors2.length() - 1)
     2122          result.append (prod (T));
     2123        else
     2124          result= Union (result, T);
    20312125        return result;
    20322126      }
     
    20372131      if (find (factors2, buf))
    20382132      {
     2133        recombinations++;
    20392134        T= Difference (T, S);
    20402135        result.append (prod (S));
     
    20472142    if (T.length() < 2*s || T.length() == s)
    20482143    {
     2144      if (recombinations == factors2.length() - 1)
     2145        result.append (prod (T));
     2146      else
     2147        result= Union (result, T);
    20492148      delete [] v;
    2050       result.append (prod (T));
    20512149      return result;
    20522150    }
     
    20592157  if (T.length() < 2*s)
    20602158  {
    2061     result.append (prod (T));
     2159    result= Union (result, T);
    20622160    return result;
    20632161  }
     
    21342232
    21352233void sortByUniFactors (CFList*& Aeval, int AevalLength,
    2136                        const CFList& uniFactors, const CFList& evaluation
     2234                       CFList& uniFactors, CFList& biFactors,
     2235                       const CFList& evaluation
    21372236                      )
    21382237{
     
    21432242  CFList LCs, buf;
    21442243  CFArray l;
    2145   int pos, index;
     2244  int pos, index, checklength;
    21462245  bool leaveLoop=false;
     2246recurse:
    21472247  for (int j= 0; j < AevalLength; j++)
    21482248  {
     
    21732273                                 Aeval[j].length() - uniFactors.length() + 1,
    21742274                                 evalPoint, v);
     2275
     2276      checklength= biFactors.length();
     2277      Aeval[j]= checkOneToOne (Aeval[j], uniFactors, biFactors, evalPoint, v);
     2278      if (checklength > biFactors.length())
     2279      {
     2280        uniFactors= buildUniFactors (biFactors, evaluation.getLast(),
     2281                                     Variable (2));
     2282        goto recurse;
     2283      }
    21752284
    21762285      buf= buildUniFactors (Aeval[j], evalPoint, v);
     
    27762885multiFactorize (const CanonicalForm& F, const ExtensionInfo& info)
    27772886{
    2778 
    27792887  if (F.inCoeffDomain())
    27802888    return CFList (F);
     
    28832991    else
    28842992    {
    2885       if (swapLevel == 1)
    2886       {
    2887         swapLevel= i;
    2888         bufA= swapvar (A, x, z);
    2889       }
    28902993      gcdDerivZ= gcd (bufA, derivZ);
    28912994      if (degree (gcdDerivZ) > 0 && !derivZ.isZero())
     
    29023005      else
    29033006      {
     3007        if (swapLevel == 1)
     3008        {
     3009          swapLevel= i;
     3010          bufA= swapvar (A, x, z);
     3011        }
    29043012        A= bufA;
    29053013        break;
     
    30913199  minFactorsLength= tmin (minFactorsLength, biFactors.length());
    30923200
     3201  CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
     3202
     3203  sortByUniFactors (Aeval2, lengthAeval2, uniFactors, biFactors, evaluation);
     3204
     3205  minFactorsLength= tmin (minFactorsLength, biFactors.length());
     3206
     3207  if (minFactorsLength == 1)
     3208  {
     3209    if (extension)
     3210    {
     3211      CFList source, dest;
     3212      A= mapDown (A, info, source, dest);
     3213    }
     3214    factors.append (A);
     3215    appendSwapDecompress (factors, contentAFactors, N, swapLevel,
     3216                          swapLevel2, x);
     3217    if (!extension)
     3218      normalize (factors);
     3219    delete [] Aeval2;
     3220    return factors;
     3221  }
     3222
    30933223  if (differentSecondVar == lengthAeval2)
    30943224  {
     
    31233253    }
    31243254  }
    3125 
    3126   CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
    3127 
    3128   sortByUniFactors (Aeval2, lengthAeval2, uniFactors, evaluation);
    31293255
    31303256  CFList * oldAeval= new CFList [lengthAeval2]; //TODO use bufAeval2 for this
  • factory/facFqFactorize.h

    r50a6c5 redc416  
    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                      );
  • factory/facSparseHensel.h

    r50a6c5 redc416  
    398398      CanonicalForm B= LC (A);
    399399      if (B.level() < level)
    400         F= -tailcoeff (A/B);
     400      {
     401        CanonicalForm quot;
     402        if (fdivides (B, A, quot))
     403          F= -tailcoeff (quot);
     404      }
    401405    }
    402406  }
Note: See TracChangeset for help on using the changeset viewer.