Changeset 44cd9a in git


Ignore:
Timestamp:
Aug 21, 2013, 1:30:17 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
849b7c0914e5ad7a169d24144d3e469708518d0b
Parents:
ffae30a2130f2ca69e796b942659b22f5597fc03
git-author:
Martin Lee <martinlee84@web.de>2013-08-21 13:30:17+02:00
git-committer:
Martin Lee <martinlee84@web.de>2013-08-30 13:48:37+02:00
Message:
chg: added convex dense compression
chg: changes to uniAbsFactorize
chg: more documentation
Location:
factory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • factory/facAbsBiFact.cc

    rffae30 r44cd9a  
    3636TIMING_DEFINE_PRINT(fac_evalpoint)
    3737
    38 CFAFList uniAbsFactorize (const CanonicalForm& F)
     38CFAFList uniAbsFactorize (const CanonicalForm& F, bool full)
    3939{
    40   CFFList rationalFactors= factorize (F);
    41   CFFListIterator i= rationalFactors;
    42   CanonicalForm LcF= rationalFactors.getFirst().factor();
    43   i++;
     40  CFAFList result;
     41  if (degree (F) == 1)
     42  {
     43    bool isRat= isOn (SW_RATIONAL);
     44    On (SW_RATIONAL);
     45    result= CFAFList (CFAFactor (F/Lc(F), 1, 1));
     46    result.insert (CFAFactor (Lc (F), 1, 1));
     47    if (!isRat)
     48      Off (SW_RATIONAL);
     49    return result;
     50  }
     51  CanonicalForm LcF= 1;
    4452  Variable alpha;
    45   CFAFList result;
    4653  CFFList QaFactors;
    4754  CFFListIterator iter;
    48   for (; i.hasItem(); i++)
    49   {
    50     if (degree (i.getItem().factor()) == 1)
    51     {
    52       result.append (CFAFactor (i.getItem().factor(), 1, i.getItem().exp()));
    53       continue;
    54     }
    55     alpha= rootOf (i.getItem().factor());
    56     QaFactors= factorize (i.getItem().factor(), alpha);
    57     iter= QaFactors;
    58     if (iter.getItem().factor().inCoeffDomain())
    59     {
    60       LcF *= iter.getItem().factor();
    61       iter++;
    62     }
    63     for (;iter.hasItem(); iter++)
    64     {
    65       if (degree (iter.getItem().factor()) == 1)
    66       {
    67         result.append (CFAFactor (iter.getItem().factor(), getMipo (alpha),
    68                                   i.getItem().exp()));
    69         break;
    70       }
     55  alpha= rootOf (F);
     56  QaFactors= factorize (F, alpha);
     57  iter= QaFactors;
     58  if (iter.getItem().factor().inCoeffDomain())
     59  {
     60    LcF = iter.getItem().factor();
     61    iter++;
     62  }
     63  for (;iter.hasItem(); iter++)
     64  {
     65    if (full)
     66      result.append (CFAFactor (iter.getItem().factor(), getMipo (alpha),
     67                                iter.getItem().exp()));
     68    if (!full && degree (iter.getItem().factor()) == 1)
     69    {
     70      result.append (CFAFactor (iter.getItem().factor(), getMipo (alpha),
     71                                iter.getItem().exp()));
     72      break;
    7173    }
    7274  }
     
    271273  F /= icontent (F);
    272274  On (SW_RATIONAL);
     275
     276  mpz_t * M=new mpz_t [4];
     277  mpz_init (M[0]);
     278  mpz_init (M[1]);
     279  mpz_init (M[2]);
     280  mpz_init (M[3]);
     281
     282  mpz_t * S=new mpz_t [2];
     283  mpz_init (S[0]);
     284  mpz_init (S[1]);
     285
     286  F= compress (F, M, S);
     287
     288  if (F.isUnivariate())
     289  {
     290    if (degree (F) == 1)
     291    {
     292      mpz_clear (M[0]);
     293      mpz_clear (M[1]);
     294      mpz_clear (M[2]);
     295      mpz_clear (M[3]);
     296      delete [] M;
     297
     298      mpz_clear (S[0]);
     299      mpz_clear (S[1]);
     300      delete [] S;
     301      if (!isRat)
     302        Off (SW_RATIONAL);
     303      return CFAFList (CFAFactor (G, 1, 1));
     304    }
     305    CFAFList result= uniAbsFactorize (F, full);
     306    if (result.getFirst().factor().inCoeffDomain())
     307      result.removeFirst();
     308    for (CFAFListIterator iter=result; iter.hasItem(); iter++)
     309      iter.getItem()= CFAFactor (decompress (iter.getItem().factor(), M, S),
     310                                 iter.getItem().minpoly(),iter.getItem().exp());
     311    mpz_clear (M[0]);
     312    mpz_clear (M[1]);
     313    mpz_clear (M[2]);
     314    mpz_clear (M[3]);
     315    delete [] M;
     316
     317    mpz_clear (S[0]);
     318    mpz_clear (S[1]);
     319    delete [] S;
     320    if (!isRat)
     321      Off (SW_RATIONAL);
     322    return result;
     323  }
     324
     325  if (degree (F, 1) == 1 || degree (F, 2) == 1)
     326  {
     327    mpz_clear (M[0]);
     328    mpz_clear (M[1]);
     329    mpz_clear (M[2]);
     330    mpz_clear (M[3]);
     331    delete [] M;
     332
     333    mpz_clear (S[0]);
     334    mpz_clear (S[1]);
     335    delete [] S;
     336    if (!isRat)
     337      Off (SW_RATIONAL);
     338    return CFAFList (CFAFactor (G, 1, 1));
     339  }
    273340  int minTdeg, tdegF= totaldegree (F);
    274341  CanonicalForm Fp, smallestFactor;
     
    305372          On (SW_RATIONAL);
    306373        setCharacteristic(0);
     374        mpz_clear (M[0]);
     375        mpz_clear (M[1]);
     376        mpz_clear (M[2]);
     377        mpz_clear (M[3]);
     378        delete [] M;
     379
     380        mpz_clear (S[0]);
     381        mpz_clear (S[1]);
     382        delete [] S;
    307383        return CFAFList (CFAFactor (G, 1, 1));
    308384      }
     
    314390          if (isRat)
    315391            On (SW_RATIONAL);
     392          mpz_clear (M[0]);
     393          mpz_clear (M[1]);
     394          mpz_clear (M[2]);
     395          mpz_clear (M[3]);
     396          delete [] M;
     397
     398          mpz_clear (S[0]);
     399          mpz_clear (S[1]);
     400          delete [] S;
    316401          return CFAFList (CFAFactor (G, 1, 1));
    317402        }
     
    729814  {
    730815    if (full)
    731       result.append (CFAFactor (i.getItem(), getMipo (alpha), 1));
     816      result.append (CFAFactor (decompress (i.getItem(), M, S),
     817                                getMipo (alpha), 1));
    732818
    733819    if (totaldegree (i.getItem()) == minTdeg)
    734820    {
    735821      if (!full)
    736         result= CFAFList (CFAFactor (i.getItem(), getMipo (alpha), 1));
     822        result= CFAFList (CFAFactor (decompress (i.getItem(), M, S),
     823                                     getMipo (alpha), 1));
    737824      found= true;
    738825
     
    754841    Off (SW_RATIONAL);
    755842
     843  mpz_clear (M[0]);
     844  mpz_clear (M[1]);
     845  mpz_clear (M[2]);
     846  mpz_clear (M[3]);
     847  delete [] M;
     848
     849  mpz_clear (S[0]);
     850  mpz_clear (S[1]);
     851  delete [] S;
     852
    756853  return result;
    757854}
  • factory/facAbsBiFact.h

    rffae30 r44cd9a  
    2121/// primitive wrt. any of its variables and irreducible over Q
    2222///
    23 /// @return absFactorizeMain returns a list whose entries contain three entities:
     23/// @return absBiFactorizeMain returns a list whose entries contain three
     24///         entities:
    2425///         an absolute irreducible factor, an irreducible univariate polynomial
    2526///         that defines the minimal field extension over which the irreducible
    26 ///         factor is defined and the multiplicity of the absolute irreducible
     27///         factor is defined, and the multiplicity of the absolute irreducible
    2728///         factor
    2829CFAFList absBiFactorizeMain (const CanonicalForm& F, ///<[in] s.a.
    29                              bool full= false
     30                             bool full= false        ///<[in] true if all
     31                                                     ///< factors should be
     32                                                     ///< returned
    3033                            );
    3134#endif
     
    4548///         an absolute irreducible factor, an irreducible univariate polynomial
    4649///         that defines the minimal field extension over which the irreducible
    47 ///         factor is defined and the multiplicity of the absolute irreducible
     50///         factor is defined, and the multiplicity of the absolute irreducible
    4851///         factor
    49 CFAFList uniAbsFactorize (const CanonicalForm& F ///<[in] univariate poly over Q
     52CFAFList uniAbsFactorize (const CanonicalForm& F, ///<[in] univariate poly
     53                                                  ///< irreducible over Q
     54                          bool full= false        ///<[in] true if all factors
     55                                                  ///< should be returned
    5056                         );
    5157
Note: See TracChangeset for help on using the changeset viewer.