Changeset b94a72 in git


Ignore:
Timestamp:
Apr 24, 2020, 6:38:31 PM (3 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
8e903f23324de1e4ec1dc9926b6de0a16de605d6
Parents:
5f544e3856e15c729d9cd4aeb0a80d2c613f4be2
Message:
fix: Tst/Long/primdecint.tst, Tst/New/stdZtests.tst
Location:
kernel/GBEngine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/kspoly.cc

    r5f544e rb94a72  
    312312}
    313313
     314#ifdef HAVE_RINGS
    314315int ksReducePolyGCD(LObject* PR,
    315316                 TObject* PW,
     
    399400    ct = n_ExtGcd(pGetCoeff(p1), pGetCoeff(p2), &an, &bn, tailRing->cf);    // Calculate GCD
    400401#ifdef HAVE_SHIFTBBA
    401     if (n_IsZero(an, tailRing->cf) || n_IsZero(bn, tailRing->cf))
    402     {
    403       // NOTE: not sure why this is not checked in the commutative case, this *does* happen and then zero coeff errors are reported
    404 
    405       // NOTE: we are probably leaking memory of lm=pOne(), but we cannot delete it since it could also be lm=p1
    406       n_Delete(&an, tailRing->cf);
    407       n_Delete(&bn, tailRing->cf);
    408       n_Delete(&ct, tailRing->cf);
    409       return ret;
     402    if(rIsLPRing(tailRing)) /* with this test: error at New/stdZtests.tst, infinite : Long/primdecint.tst */
     403    {
     404      if (n_IsZero(an, tailRing->cf) || n_IsZero(bn, tailRing->cf))
     405      {
     406        // NOTE: not sure why this is not checked in the commutative case, this *does* happen and then zero coeff errors are reported
     407        // NOTE: we are probably leaking memory of lm=pOne(), but we cannot delete it since it could also be lm=p1
     408        n_Delete(&an, tailRing->cf);
     409        n_Delete(&bn, tailRing->cf);
     410        n_Delete(&ct, tailRing->cf);
     411        return ret;
     412      }
    410413    }
    411414#endif
     
    437440  return ret;
    438441}
     442#endif
    439443
    440444/* Computes a reduction of the lead coefficient only. We have already tested
     
    14131417#ifdef HAVE_SHIFTBBA
    14141418  int shift1, shift2;
    1415   if (tailRing->isLPring) {
     1419  if (tailRing->isLPring)
     1420  {
    14161421    // assume: LM is shifted, tail unshifted
    14171422    assume(p_FirstVblock(a1, tailRing) <= 1);
  • kernel/GBEngine/kstd2.cc

    r5f544e rb94a72  
    105105      {
    106106        gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r->cf);
    107         if (o == -1 ||
    108             n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf) == TRUE) {
     107        if (o == -1
     108        || n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf))
     109        {
    109110          ogcd = gcd;
    110111          o = j;
     
    125126      {
    126127        gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r->cf);
    127         if (o == -1 ||
    128             n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf) == TRUE) {
     128        if (o == -1
     129        || n_Greater(n_EucNorm(ogcd, r->cf), n_EucNorm(gcd, r->cf), r->cf))
     130        {
    129131          ogcd = gcd;
    130132          o = j;
     
    157159        {
    158160            mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf);
    159             if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     161            if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     162            {
    160163                return 0;
    161164            }
     
    165168        {
    166169            mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf);
    167             if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     170            if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     171            {
    168172                return 0;
    169173            }
     
    182186        {
    183187            mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf);
    184             if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     188            if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     189            {
    185190                return 0;
    186191            }
     
    190195        {
    191196            mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf);
    192             if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     197            if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     198            {
    193199                return 0;
    194200            }
     
    223229      {
    224230        mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
    225         if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     231        if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     232        {
    226233          o = j;
    227234          orest = rest;
     
    232239      {
    233240        mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r->cf);
    234         if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     241        if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     242        {
    235243          o = j;
    236244          orest = rest;
     
    254262      {
    255263        mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r->cf);
    256         if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     264        if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     265        {
    257266          o = j;
    258267          orest = rest;
     
    263272      {
    264273        mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r->cf);
    265         if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) {
     274        if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf))
     275        {
    266276          o = j;
    267277          orest = rest;
     
    648658    /* check if a reducer of the lead term exists */
    649659    j = kFindDivisibleByInT(strat, h);
    650     if (j < 0) {
     660    if (j < 0)
     661    {
    651662      /* check if a reducer with the same lead monomial exists */
    652663      j = kFindSameLMInT_Z(strat, h);
    653       if (j < 0) {
     664      if (j < 0)
     665      {
    654666        /* check if a reducer of the lead monomial exists, by the above
    655667         * check this is a real divisor of the lead monomial */
     
    683695          }
    684696        }
    685         else
    686         {
     697        else
     698        {
    687699          /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
    688700           * => we try to cut down the lead coefficient at least */
     
    713725        ksReducePolyZ(h, &(strat->T[j]), NULL, NULL, strat);
    714726        ksReducePolyGCD(&h2, &(strat->T[j]), NULL, NULL, strat);
    715         if (!rHasLocalOrMixedOrdering(currRing)) {
     727        if (!rHasLocalOrMixedOrdering(currRing))
     728        {
    716729          redtailBbaAlsoLC_Z(&h2, j, strat);
    717730          h2.pCleardenom();
     
    43504363/* shiftgb stuff */
    43514364#ifdef HAVE_SHIFTBBA
    4352 
    4353 
    43544365ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
    43554366{
     
    45084519      // therefore we call pCleardenom instead of pNorm
    45094520      strat->redTailChange=FALSE;
    4510      
     4521
    45114522      /* if we are computing over Z we always want to try and cut down
    45124523       * the coefficients in the tail terms */
    4513       if (rField_is_Z(currRing) && !rHasLocalOrMixedOrdering(currRing)) {
     4524      if (rField_is_Z(currRing) && !rHasLocalOrMixedOrdering(currRing))
     4525      {
    45144526        redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
    45154527        strat->P.pCleardenom();
     
    46304642          if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
    46314643          {
    4632             if (pLmCmp(strat->T[j].p, strat->S[k]) != 0) { // check whether LM is different
     4644            if (pLmCmp(strat->T[j].p, strat->S[k]) != 0)
     4645            { // check whether LM is different
    46334646              deleteInS(k, strat);
    46344647              --k;
     
    47104723  return (strat->Shdl);
    47114724}
     4725#endif
    47124726
    47134727#ifdef HAVE_SHIFTBBA
     
    47274741* element in t with respect to the given pDivisibleBy
    47284742*/
     4743#ifdef HAVE_SHIFTBBA
    47294744int redFirstShift (LObject* h,kStrategy strat)
    47304745{
  • kernel/GBEngine/kutil.cc

    r5f544e rb94a72  
    234234
    235235#ifdef HAVE_SHIFTBBA
    236 static inline int pLPDivComp(poly p, poly q) {
     236static inline int pLPDivComp(poly p, poly q)
     237{
    237238  if ((currRing->pCompIndex < 0) || (__p_GetComp(p,currRing) == __p_GetComp(q,currRing)))
    238239  {
     
    755756  return -1;
    756757}
    757 
     758#endif
     759
     760#ifdef HAVE_SHIFTBBA
    758761int kFindInTShift(poly p, kStrategy strat)
    759762{
     
    16001603  k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
    16011604
    1602   if (!rHasLocalOrMixedOrdering(currRing)) {
     1605  if (!rHasLocalOrMixedOrdering(currRing))
     1606  {
    16031607    unsigned long sev = pGetShortExpVector(gcd);
    16041608
    1605     for (int j = 0; j < strat->sl; j++) {
     1609    for (int j = 0; j < strat->sl; j++)
     1610    {
    16061611      if (j == i)
    16071612        continue;
    16081613
    1609       if (n_DivBy(d, pGetCoeff(strat->S[j]), currRing->cf) &&
    1610           !(strat->sevS[j] & ~sev) &&
    1611           p_LmDivisibleBy(strat->S[j], gcd, currRing)) {
     1614      if (n_DivBy(d, pGetCoeff(strat->S[j]), currRing->cf)
     1615      && !(strat->sevS[j] & ~sev)
     1616      && p_LmDivisibleBy(strat->S[j], gcd, currRing))
     1617      {
    16121618        nDelete(&d);
    16131619        nDelete(&s);
     
    32303236  strat->Bl = -1;
    32313237}
     3238
    32323239/*2
    32333240*the pairset B of pairs of type (s[i],p) is complete now. It will be updated
     
    72877294    return FALSE;
    72887295  int found = -1;
    7289   for (int i=strat->Bl; i>-1; i--) {
     7296  for (int i=strat->Bl; i>-1; i--)
     7297  {
    72907298    if (pLmEqual(strat->B[i].sig,sig))
    72917299    {
     
    78237831      int j;
    78247832      j = kFindDivisibleByInT(strat, &Ln);
    7825       if (j < 0) {
     7833      if (j < 0)
     7834      {
    78267835        j = kFindDivisibleByInT_Z(strat, &Ln);
    7827         if (j < 0) {
     7836        if (j < 0)
     7837        {
    78287838          break;
    7829         } else {
     7839        }
     7840        else
     7841        {
    78307842          /* reduction not cancelling a tail term, but reducing its coefficient */
    78317843          With = &(strat->T[j]);
     
    1232512337// }
    1232612338
    12327 #ifdef HAVE_SHIFTBBA
    1232812339/*2
    1232912340* put the  lcm(q,p)  into the set B, q is the shift of some s[i]
    1233012341*/
     12342#ifdef HAVE_SHIFTBBA
    1233112343static BOOLEAN enterOneStrongPolyShift (poly q, poly p, int /*ecart*/, int /*isFromQ*/, kStrategy strat, int atR, int /*ecartq*/, int qisFromQ, int shiftcount, int ifromS)
    1233212344{
     
    1249212504  return TRUE;
    1249312505}
     12506#endif
     12507
    1249412508
    1249512509/*2
    1249612510* put the pair (q,p)  into the set B, ecart=ecart(p), q is the shift of some s[i] (ring case)
    1249712511*/
     12512#ifdef HAVE_SHIFTBBA
    1249812513static void enterOnePairRingShift (poly q, poly p, int /*ecart*/, int isFromQ, kStrategy strat, int atR, int /*ecartq*/, int qisFromQ, int shiftcount, int ifromS)
    1249912514{
     
    1273612751  kTest_TS(strat);
    1273712752}
    12738 
     12753#endif
     12754
     12755#ifdef HAVE_SHIFTBBA
    1273912756// adds the strong pair and the normal pair for rings (aka gpoly and spoly)
    1274012757static void enterOneStrongPolyAndEnterOnePairRingShift(poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
     
    1274312760  enterOnePairRingShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "spoly"
    1274412761}
    12745 
     12762#endif
     12763
     12764#ifdef HAVE_SHIFTBBA
    1274612765// creates if possible (q,p), (shifts(q),p)
    1274712766static void enterOnePairWithShifts (int q_inS /*also i*/, poly q, poly p, int ecartp, int p_isFromQ, kStrategy strat, int atR, int p_lastVblock, int q_lastVblock)
     
    1283112850#endif
    1283212851
    12833 #ifdef HAVE_SHIFTBBA
    1283412852
    1283512853#ifdef KDEBUG
     
    1284012858* put the pair (q,p)  into the set B, ecart=ecart(p), q is the shift of some s[i]
    1284112859*/
     12860#ifdef HAVE_SHIFTBBA
    1284212861void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
    1284312862{
     
    1295012969            pLmFree(Lp.lcm);
    1295112970#ifdef CRITERION_DEBUG
    12952             if (TEST_OPT_DEBUG) {
     12971            if (TEST_OPT_DEBUG)
     12972            {
    1295312973              Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
    1295412974            }
     
    1296312983        {
    1296412984#ifdef CRITERION_DEBUG
    12965           if (TEST_OPT_DEBUG) {
     12985          if (TEST_OPT_DEBUG)
     12986          {
    1296612987            Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
    1296712988          }
     
    1302713048            pLmFree(Lp.lcm);
    1302813049#ifdef CRITERION_DEBUG
    13029             if (TEST_OPT_DEBUG) {
     13050            if (TEST_OPT_DEBUG)
     13051            {
    1303013052              Print("--- chain crit using B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
    1303113053            }
     
    1303913061        {
    1304013062#ifdef CRITERION_DEBUG
    13041           if (TEST_OPT_DEBUG) {
     13063          if (TEST_OPT_DEBUG)
     13064          {
    1304213065            Print("--- chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat->B[j].lcm));
    1304313066          }
     
    1316913192  }
    1317013193}
     13194#endif
    1317113195
    1317213196/*3
     
    1317513199* additionally we put the pairs (h, s \sdot h) for s>=1 to L
    1317613200*/
     13201#ifdef HAVE_SHIFTBBA
    1317713202void initenterpairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR)
    1317813203{
     
    1323713262      {
    1323813263        // pairs (shifts(s[1..k]),h), (s[1..k],h)
    13239         for (j=0; j<=k; j++) {
     13264        for (j=0; j<=k; j++)
     13265        {
    1324013266          if (!strat->fromQ[j])
    1324113267          {
     
    1328113307        new_pair=TRUE;
    1328213308        // pairs (shifts(s[1..k]),h), (s[1..k],h)
    13283         for (j=0; j<=k; j++) {
     13309        for (j=0; j<=k; j++)
     13310        {
    1328413311          poly s = strat->S[j];
    1328513312          enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     
    1335513382      {
    1335613383        // pairs (shifts(s[1..k]),h), (s[1..k],h)
    13357         for (j=0; j<=k; j++) {
     13384        for (j=0; j<=k; j++)
     13385        {
    1335813386          if ((pGetComp(h)==pGetComp(strat->S[j]))
    1335913387              || (pGetComp(strat->S[j])==0))
     
    1341713445  }
    1341813446}
     13447#endif
    1341913448
    1342013449/*3
     
    1342313452* additionally we put the pairs (h, s \sdot h) for s>=1 to L
    1342413453*/
     13454#ifdef HAVE_SHIFTBBA
    1342513455void initenterstrongPairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR)
    1342613456{
     
    1348513515      {
    1348613516        // pairs (shifts(s[1..k]),h), (s[1..k],h)
    13487         for (j=0; j<=k; j++) {
     13517        for (j=0; j<=k; j++)
     13518        {
    1348813519          if (!strat->fromQ[j])
    1348913520          {
     
    1351413545        new_pair=TRUE;
    1351513546        // pairs (shifts(s[1..k]),h), (s[1..k],h)
    13516         for (j=0; j<=k; j++) {
     13547        for (j=0; j<=k; j++)
     13548        {
    1351713549          poly s = strat->S[j];
    1351813550          // TODO: cache lastVblock of s[1..k] for later use
     
    1356013592      {
    1356113593        // pairs (shifts(s[1..k]),h), (s[1..k],h)
    13562         for (j=0; j<=k; j++) {
     13594        for (j=0; j<=k; j++)
     13595        {
    1356313596          if ((pGetComp(h)==pGetComp(strat->S[j]))
    1356413597              || (pGetComp(strat->S[j])==0))
     
    1359313626  }
    1359413627}
     13628#endif
    1359513629
    1359613630/*2
     
    1359813632*superfluous elements in S will be deleted
    1359913633*/
     13634#ifdef HAVE_SHIFTBBA
    1360013635void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR)
    1360113636{
     
    1362113656  }
    1362213657}
     13658#endif
    1362313659
    1362413660/*2
     
    1362613662* assumes that p is already in T!
    1362713663*/
     13664#ifdef HAVE_SHIFTBBA
    1362813665void enterTShift(LObject p, kStrategy strat, int atT)
    1362913666{
Note: See TracChangeset for help on using the changeset viewer.