Changeset 36ef97a in git for factory/cfNewtonPolygon.cc


Ignore:
Timestamp:
Feb 28, 2013, 12:27:27 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '2234726c50d679d6664181a5c72f75a6fd64a787')
Children:
f224fda57b6b8846990a1284ec08a294e5b2f0f7
Parents:
160ec65155bebf896fb6d52bbe233c0c557a8c0e
git-author:
Martin Lee <martinlee84@web.de>2013-02-28 12:27:27+01:00
git-committer:
Martin Lee <martinlee84@web.de>2013-05-02 11:42:35+02:00
Message:
chg: added absolute irreducibility test
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cfNewtonPolygon.cc

    r160ec6 r36ef97a  
    857857bool irreducibilityTest (const CanonicalForm& F)
    858858{
     859  ASSERT (getNumVars (F) == 2, "expected bivariate polynomial");
     860  ASSERT (getCharacteristic() == 0, "expected polynomial over integers or rationals");
     861
    859862  int sizeOfNewtonPolygon;
    860863  int ** newtonPolyg= newtonPolygon (F, sizeOfNewtonPolygon);
     
    872875        if (isRat)
    873876          Off (SW_RATIONAL);
    874         CanonicalForm tmp= gcd (newtonPolyg[0][0],newtonPolyg[0][1]);
     877        CanonicalForm tmp= gcd (newtonPolyg[0][0],newtonPolyg[0][1]); // maybe it's better to use plain intgcd
    875878        tmp= gcd (tmp, newtonPolyg[1][0]);
    876879        tmp= gcd (tmp, newtonPolyg[1][1]);
     
    891894  return false;
    892895}
     896
     897bool absIrredTest (const CanonicalForm& F)
     898{
     899  ASSERT (getNumVars (F) == 2, "expected bivariate polynomial");
     900  ASSERT (factorize (F).length() <= 2, " expected irreducible polynomial");
     901
     902  int sizeOfNewtonPolygon;
     903  int ** newtonPolyg= newtonPolygon (F, sizeOfNewtonPolygon);
     904  bool isRat= isOn (SW_RATIONAL);
     905  if (isRat)
     906    Off (SW_RATIONAL);
     907  int p=getCharacteristic();
     908  int d=1;
     909  char bufGFName='Z';
     910  bool GF= (CFFactory::gettype()==GaloisFieldDomain);
     911  if (GF)
     912  {
     913    d= getGFDegree();
     914    bufGFName=gf_name;
     915  }
     916
     917  setCharacteristic(0);
     918
     919  CanonicalForm g= gcd (newtonPolyg[0][0], newtonPolyg[0][1]); //maybe it's better to use plain intgcd
     920
     921  int i= 1;
     922  while (!g.isOne() && i < sizeOfNewtonPolygon)
     923  {
     924    g= gcd (g, newtonPolyg[i][0]);
     925    g= gcd (g, newtonPolyg[i][1]);
     926    i++;
     927  }
     928
     929  bool result= g.isOne();
     930
     931  if (GF)
     932    setCharacteristic (p, d, bufGFName);
     933  else
     934    setCharacteristic(p);
     935
     936  if (isRat)
     937    On (SW_RATIONAL);
     938
     939  return result;
     940}
     941
Note: See TracChangeset for help on using the changeset viewer.