Changeset b97cce6 in git


Ignore:
Timestamp:
Oct 7, 2022, 3:47:59 PM (19 months ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
823db5eb586880d00810d3443c78a45dfbf5a419
Parents:
220bb42fbc1cc6ed2ae16e15cd080008696728fe
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2022-10-07 15:47:59+02:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2022-10-07 15:48:32+02:00
Message:
fix: redNF and related
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/janet.cc

    r220bb4 rb97cce6  
    100100  number coef;
    101101  if (y->root_l<=0) y->root_l=pLength(y->root);
    102   coef=kBucketPolyRed(x->root_b,y->root,y->root_l,NULL,FALSE);
     102  coef=kBucketPolyRed(x->root_b,y->root,y->root_l,NULL);
    103103  nDelete(&coef);
    104104  x->root=kBucketGetLm(x->root_b);
  • kernel/GBEngine/kstd2.cc

    r220bb4 rb97cce6  
    21872187#ifdef HAVE_RINGS
    21882188  BOOLEAN is_ring = rField_is_Ring(currRing);
     2189  if(is_ring) nonorm=TRUE;
    21892190#endif
    21902191#ifdef KDEBUG
     
    21982199//    }
    21992200//  };
     2201#endif
     2202
     2203  loop
     2204  {
     2205    j=kFindDivisibleByInS(strat,&max_ind,&P);
     2206    while ((j>=0)
     2207    && (nonorm)
     2208    && (!n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[j]),currRing->cf)))
     2209      j=kFindNextDivisibleByInS(strat,j+1,max_ind,&P);
     2210    if (j>=0)
     2211    {
     2212#ifdef HAVE_RINGS
     2213      if (!is_ring)
     2214      {
     2215#endif
     2216        int sl=pSize(strat->S[j]);
     2217        int jj=j;
     2218        loop
     2219        {
     2220          int sll;
     2221          jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
     2222          if (jj<0) break;
     2223          if ((!nonorm)
     2224          || (n_DivBy(pGetCoeff(P.p),pGetCoeff(strat->S[jj]),currRing->cf)))
     2225          {
     2226            sll=pSize(strat->S[jj]);
     2227            if (sll<sl)
     2228            {
     2229              #ifdef KDEBUG
     2230              if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
     2231              #endif
     2232              //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
     2233              j=jj;
     2234              sl=sll;
     2235            }
     2236          }
     2237        }
     2238        if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
     2239        {
     2240          pNorm(strat->S[j]);
     2241          //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
     2242        }
     2243#ifdef HAVE_RINGS
     2244      }
     2245#endif
     2246      nNormalize(pGetCoeff(P.p));
     2247#ifdef KDEBUG
     2248      if (TEST_OPT_DEBUG)
     2249      {
     2250        PrintS("red:");
     2251        wrp(h);
     2252        PrintS(" with ");
     2253        wrp(strat->S[j]);
     2254      }
     2255#endif
     2256#ifdef HAVE_PLURAL
     2257      if (rIsPluralRing(currRing))
     2258      {
     2259        number coef;
     2260        nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm);
     2261        nDelete(&coef);
     2262      }
     2263      else
     2264#endif
     2265      {
     2266        kBucketPolyRedNF(P.bucket,strat->S[j],pLength(strat->S[j]),
     2267                            strat->kNoether);
     2268      }
     2269      cnt--;
     2270      if (cnt==0)
     2271      {
     2272        kBucketCanonicalize(P.bucket);
     2273        cnt=REDNF_CANONICALIZE;
     2274      }
     2275      h = kBucketGetLm(P.bucket);   // FRAGE OLIVER
     2276      if (h==NULL)
     2277      {
     2278        kBucketDestroy(&P.bucket);
     2279        return NULL;
     2280      }
     2281      kbTest(P.bucket);
     2282      P.p=h;
     2283      P.t_p=NULL;
     2284      P.SetShortExpVector();
     2285#ifdef KDEBUG
     2286      if (TEST_OPT_DEBUG)
     2287      {
     2288        PrintS("\nto:");
     2289        wrp(h);
     2290        PrintLn();
     2291      }
     2292#endif
     2293    }
     2294    else
     2295    {
     2296      P.p=kBucketClear(P.bucket);
     2297      kBucketDestroy(&P.bucket);
     2298      pNormalize(P.p);
     2299      return P.p;
     2300    }
     2301  }
     2302}
     2303
     2304/*2
     2305*  reduction procedure from global case but with jet bound
     2306*/
     2307
     2308poly redNFBound (poly h,int &max_ind,int nonorm,kStrategy strat,int bound)
     2309{
     2310  h = pJet(h,bound);
     2311  if (h==NULL) return NULL;
     2312  int j;
     2313  max_ind=strat->sl;
     2314
     2315  if (0 > strat->sl)
     2316  {
     2317    return h;
     2318  }
     2319  LObject P(h);
     2320  P.SetShortExpVector();
     2321  P.bucket = kBucketCreate(currRing);
     2322  kBucketInit(P.bucket,P.p,pLength(P.p));
     2323  kbTest(P.bucket);
     2324#ifdef HAVE_RINGS
     2325  BOOLEAN is_ring = rField_is_Ring(currRing);
    22002326#endif
    22012327
     
    22492375      {
    22502376        number coef;
    2251         nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm==0);
     2377        nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm);
    22522378        nDelete(&coef);
    22532379      }
     
    22552381#endif
    22562382      {
    2257         number coef;
    2258         coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),
    2259                             strat->kNoether,nonorm==0);
    2260         nDelete(&coef);
    2261       }
    2262       cnt--;
    2263       if (cnt==0)
    2264       {
    2265         kBucketCanonicalize(P.bucket);
    2266         cnt=REDNF_CANONICALIZE;
    2267       }
    2268       h = kBucketGetLm(P.bucket);   // FRAGE OLIVER
    2269       if (h==NULL)
    2270       {
    2271         kBucketDestroy(&P.bucket);
    2272         return NULL;
    2273       }
    2274       kbTest(P.bucket);
    2275       P.p=h;
    2276       P.t_p=NULL;
    2277       P.SetShortExpVector();
    2278 #ifdef KDEBUG
    2279       if (TEST_OPT_DEBUG)
    2280       {
    2281         PrintS("\nto:");
    2282         wrp(h);
    2283         PrintLn();
    2284       }
    2285 #endif
    2286     }
    2287     else
    2288     {
    2289       P.p=kBucketClear(P.bucket);
    2290       kBucketDestroy(&P.bucket);
    2291       pNormalize(P.p);
    2292       return P.p;
    2293     }
    2294   }
    2295 }
    2296 
    2297 /*2
    2298 *  reduction procedure from global case but with jet bound
    2299 */
    2300 
    2301 poly redNFBound (poly h,int &max_ind,int nonorm,kStrategy strat,int bound)
    2302 {
    2303   h = pJet(h,bound);
    2304   if (h==NULL) return NULL;
    2305   int j;
    2306   max_ind=strat->sl;
    2307 
    2308   if (0 > strat->sl)
    2309   {
    2310     return h;
    2311   }
    2312   LObject P(h);
    2313   P.SetShortExpVector();
    2314   P.bucket = kBucketCreate(currRing);
    2315   kBucketInit(P.bucket,P.p,pLength(P.p));
    2316   kbTest(P.bucket);
    2317 #ifdef HAVE_RINGS
    2318   BOOLEAN is_ring = rField_is_Ring(currRing);
    2319 #endif
    2320 
    2321   loop
    2322   {
    2323     j=kFindDivisibleByInS(strat,&max_ind,&P);
    2324     if (j>=0)
    2325     {
    2326 #ifdef HAVE_RINGS
    2327       if (!is_ring)
    2328       {
    2329 #endif
    2330         int sl=pSize(strat->S[j]);
    2331         int jj=j;
    2332         loop
    2333         {
    2334           int sll;
    2335           jj=kFindNextDivisibleByInS(strat,jj+1,max_ind,&P);
    2336           if (jj<0) break;
    2337           sll=pSize(strat->S[jj]);
    2338           if (sll<sl)
    2339           {
    2340             #ifdef KDEBUG
    2341             if (TEST_OPT_DEBUG) Print("better(S%d:%d -> S%d:%d)\n",j,sl,jj,sll);
    2342             #endif
    2343             //else if (TEST_OPT_PROT) { PrintS("b"); mflush(); }
    2344             j=jj;
    2345             sl=sll;
    2346           }
    2347         }
    2348         if ((nonorm==0) && (!nIsOne(pGetCoeff(strat->S[j]))))
    2349         {
    2350           pNorm(strat->S[j]);
    2351           //if (TEST_OPT_PROT) { PrintS("n"); mflush(); }
    2352         }
    2353 #ifdef HAVE_RINGS
    2354       }
    2355 #endif
    2356       nNormalize(pGetCoeff(P.p));
    2357 #ifdef KDEBUG
    2358       if (TEST_OPT_DEBUG)
    2359       {
    2360         PrintS("red:");
    2361         wrp(h);
    2362         PrintS(" with ");
    2363         wrp(strat->S[j]);
    2364       }
    2365 #endif
    2366 #ifdef HAVE_PLURAL
    2367       if (rIsPluralRing(currRing))
    2368       {
    2369         number coef;
    2370         nc_kBucketPolyRed_NF(P.bucket,strat->S[j],&coef,nonorm==0);
    2371         nDelete(&coef);
    2372       }
    2373       else
    2374 #endif
    2375       {
    2376         number coef;
    2377         coef=kBucketPolyRed(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether,nonorm==0);
     2383        kBucketPolyRedNF(P.bucket,strat->S[j],pLength(strat->S[j]),strat->kNoether);
    23782384        P.p = kBucketClear(P.bucket);
    23792385        P.p = pJet(P.p,bound);
     
    23852391          kBucketInit(P.bucket,P.p,pLength(P.p));
    23862392        }
    2387         nDelete(&coef);
    23882393      }
    23892394      h = kBucketGetLm(P.bucket);   // FRAGE OLIVER
  • kernel/GBEngine/syz0.cc

    r220bb4 rb97cce6  
    685685            pSetComp(lastmonom,l+1);
    686686            //computes the new toRed
    687             number up = kBucketPolyRed(sy0buck,F[l],Flength[l],NULL,FALSE);
     687            number up = kBucketPolyRed(sy0buck,F[l],Flength[l],NULL);
    688688            if (! nIsOne(up))
    689689            {
  • kernel/GBEngine/syz1.cc

    r220bb4 rb97cce6  
    833833            pGetCoeff(p) = nInpNeg(pGetCoeff(p));
    834834            number up = kBucketPolyRed(syzstr->bucket,redset[j],elL[bin[j]],
    835                                        NULL,FALSE);
     835                                       NULL);
    836836            // Thomas: Check whether you need number here
    837837            nDelete(&up);
  • kernel/GBEngine/syz2.cc

    r220bb4 rb97cce6  
    422422      {
    423423        number up = kBucketPolyRed(syzstr->bucket,redWith->m[i],
    424                          pLength(redWith->m[i]), NULL, FALSE);
     424                         pLength(redWith->m[i]), NULL);
    425425        nDelete(&up);
    426426        q = kBucketGetLm(syzstr->bucket);
     
    624624            sySPRedSyz(syzstr,redset[j],q);
    625625            number up = kBucketPolyRed(syzstr->bucket,redset[j].p,
    626                          redset[j].length, NULL, FALSE);
     626                         redset[j].length, NULL);
    627627            nDelete(&up);
    628628            q = kBucketGetLm(syzstr->bucket);
  • kernel/GBEngine/syz3.cc

    r220bb4 rb97cce6  
    497497    if ((red->m[j]!=NULL) && (pDivisibleBy(red->m[j],p)))
    498498    {
    499       n = kBucketPolyRed(bucket,red->m[j], g_l[j], NULL, FALSE);
     499      n = kBucketPolyRed(bucket,red->m[j], g_l[j], NULL);
    500500      nDelete(&n);
    501501      p = kBucketGetLm(bucket);
     
    789789          sySPRedSyz_Kosz(syzstr,new_generators->m[j],new_repr->m[j],p);
    790790          n = kBucketPolyRed(syzstr->bucket,new_generators->m[j],
    791                              pLength(new_generators->m[j]), NULL, FALSE);
     791                             pLength(new_generators->m[j]), NULL);
    792792          p = kBucketGetLm(syzstr->bucket);
    793793#ifdef EXPERIMENT1
     
    811811          assume (old_repr->m[j]!=NULL);
    812812          sySPRedSyz_Kosz(syzstr,ogm[j],old_repr->m[j],p,orp_l[j]);
    813           n = kBucketPolyRed(syzstr->bucket,ogm[j],ogm_l[j], NULL,FALSE);
     813          n = kBucketPolyRed(syzstr->bucket,ogm[j],ogm_l[j], NULL);
    814814          p = kBucketGetLm(syzstr->bucket);
    815815#ifdef EXPERIMENT1
     
    10391039    {
    10401040      n = kBucketPolyRed(syzstr->bucket,add_generators->m[j], g_l[j],
    1041                          NULL, FALSE);
     1041                         NULL);
    10421042      nDelete(&n);
    10431043      p = kBucketGetLm(syzstr->bucket);
     
    13031303          sySPRedSyz_Kosz(syzstr,add_generators->m[j],add_repr->m[j],p);
    13041304          n = kBucketPolyRed(syzstr->bucket,add_generators->m[j],
    1305                    pLength(add_generators->m[j]), NULL, FALSE);
     1305                   pLength(add_generators->m[j]), NULL);
    13061306          p = kBucketGetLm(syzstr->bucket);
    13071307          if ((p==NULL) || (pGetComp(p)<=crit_comp)) break;
     
    15781578          sySPRedSyz_Kosz(syzstr,old_generators->m[j],old_repr->m[j],p);
    15791579          n = kBucketPolyRed(syzstr->bucket,old_generators->m[j], g_l[j],
    1580                              NULL, FALSE);
     1580                             NULL);
    15811581          nDelete(&n);
    15821582          p = kBucketGetLm(syzstr->bucket);
  • kernel/GBEngine/tgb.cc

    r220bb4 rb97cce6  
    18341834      number coef = kBucketPolyRed (P.bucket, strat->S[j],
    18351835                                    strat->lenS[j] /*pLength(strat->S[j]) */ ,
    1836                                     strat->kNoether,FALSE);
     1836                                    strat->kNoether);
    18371837      number m2 = nMult (m, coef);
    18381838      nDelete (&m);
     
    30473047          coef = kBucketPolyRed (P.bucket, strat->S[j],
    30483048                                 strat->lenS[j] /*pLength(strat->S[j]) */ ,
    3049                                  strat->kNoether,FALSE);
     3049                                 strat->kNoether);
    30503050        res=__p_Mult_nn (res, coef, currRing);
    30513051        nDelete (&coef);
     
    48934893  else
    48944894#endif
    4895     coef = kBucketPolyRed (ro.bucket, p, p_len, c->strat->kNoether,FALSE);
     4895    coef = kBucketPolyRed (ro.bucket, p, p_len, c->strat->kNoether);
    48964896  nDelete (&coef);
    48974897}
  • libpolys/polys/kbuckets.cc

    r220bb4 rb97cce6  
    10831083number kBucketPolyRed(kBucket_pt bucket,
    10841084                      poly p1, int l1,
    1085                       poly spNoether,
    1086                       BOOLEAN reduce)
     1085                      poly spNoether)
    10871086{
    10881087  ring r=bucket->bucket_ring;
     
    11081107  {
    11091108    number an = pGetCoeff(p1), bn = pGetCoeff(lm);
    1110 //StringSetS("##### an = "); nWrite(an); PrintS(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
    1111 //StringSetS("##### bn = "); nWrite(bn); PrintS(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
    11121109    /* ksCheckCoeff: divide out gcd from an and bn: */
    11131110    int ct = ksCheckCoeff(&an, &bn,r->cf);
     
    11191116    if ((ct == 0) || (ct == 2))
    11201117    {
    1121       if (reduce)
    1122       {
    1123         if(n_IsMOne(an,r->cf))
    1124         {
    1125           an=n_InpNeg(an,r->cf);
    1126           bn=n_InpNeg(bn,r->cf);
    1127         }
    1128         #if 1 //#ifdef KDEBUG
    1129         else if (!n_IsOne(an,r->cf))
    1130         {
    1131           StringSetS("kBucketPolyRed: ");
    1132           n_Write(an,r->cf);
    1133           StringAppendS("\n");
    1134           PrintS(StringEndS());
    1135         }
    1136         #endif
    1137       }
    11381118      /* correct factor for cancelation by changing sign if an=-1 */
    11391119      if (rField_is_Ring(r))
     
    12161196  kbTest(bucket);
    12171197  return rn;
     1198}
     1199
     1200void kBucketPolyRedNF(kBucket_pt bucket,
     1201                      poly p1, int l1,
     1202                      poly spNoether)
     1203{
     1204  ring r=bucket->bucket_ring;
     1205  assume((!rIsPluralRing(r))||p_LmEqual(p1,kBucketGetLm(bucket), r));
     1206  assume(p1 != NULL &&
     1207         p_DivisibleBy(p1,  kBucketGetLm(bucket), r));
     1208  assume(pLength(p1) == (unsigned) l1);
     1209
     1210  poly a1 = pNext(p1), lm = kBucketExtractLm(bucket);
     1211  BOOLEAN reset_vec=FALSE;
     1212
     1213  /* we shall reduce bucket=bn*lm+... by p1=an*t+a1 where t=lm(p1)
     1214     and an,bn shall be defined further down only if lc(p1)!=1
     1215     we already know: an|bn and t|lm */
     1216  if(a1==NULL)
     1217  {
     1218    p_LmDelete(&lm, r);
     1219    return;
     1220  }
     1221
     1222  #ifdef KDEBUG
     1223  if (n_DivBy(pGetCoeff(lm),pGetCoeff(p1),r->cf))
     1224  #endif
     1225  {
     1226    number c=n_Div(pGetCoeff(lm),pGetCoeff(p1),r->cf);
     1227    //StringSetS("mult cf:");n_Write(c,r->cf);StringAppendS("\n");
     1228    //PrintS(StringEndS());
     1229    #ifdef KDEBUG
     1230    if (n_IsZero(c,r->cf))
     1231    {
     1232      StringSetS("a/b: ");n_Write(pGetCoeff(lm),r->cf);StringAppendS(" / ");
     1233      n_Write(pGetCoeff(p1),r->cf);StringAppendS("\n");PrintS(StringEndS());
     1234    }
     1235    #endif
     1236    p_SetCoeff(lm,c,r);
     1237  }
     1238  #ifdef KDEBUG
     1239  else
     1240  {
     1241    PrintS("bug\n");
     1242  }
     1243  #endif
     1244  if (p_GetComp(p1, r) != p_GetComp(lm, r))
     1245  {
     1246    p_SetCompP(a1, p_GetComp(lm, r), r);
     1247    reset_vec = TRUE;
     1248    p_SetComp(lm, p_GetComp(p1, r), r);
     1249    p_Setm(lm, r);
     1250  }
     1251
     1252  p_ExpVectorSub(lm, p1, r);
     1253  l1--;
     1254
     1255  assume((unsigned)l1==pLength(a1));
     1256
     1257#ifdef HAVE_SHIFTBBA
     1258  poly lmRight;
     1259  poly lm_org;
     1260  if (r->isLPring)
     1261  {
     1262    int firstBlock = p_mFirstVblock(p1, r);
     1263    lm_org=lm;
     1264    k_SplitFrame(lm, lmRight, si_max(firstBlock, 1), r);
     1265  }
     1266#endif
     1267
     1268#ifdef HAVE_SHIFTBBA
     1269  if (r->isLPring)
     1270  {
     1271    poly tmp=r->p_Procs->pp_Mult_mm(a1, lmRight, r);
     1272    kBucket_Minus_m_Mult_p(bucket, lm,tmp, &l1, spNoether);
     1273    p_Delete(&tmp,r);
     1274    p_LmDelete(&lmRight,r);
     1275    p_LmDelete(lm_org,r);
     1276  }
     1277  else
     1278#endif
     1279  {
     1280    kBucket_Minus_m_Mult_p(bucket, lm, a1, &l1, spNoether);
     1281  }
     1282
     1283#if 0
     1284  if (backuped)
     1285    p_SetCoeff0(a1,coef,r);
     1286#endif
     1287
     1288  p_LmDelete(&lm, r);
     1289  if (reset_vec) p_SetCompP(a1, 0, r);
     1290  kbTest(bucket);
     1291  return;
    12181292}
    12191293
     
    14391513*       3  ->  a == 1,  b == 1
    14401514*   this value is used to control the spolys
    1441 *   reduce is set inside "NF" -> a should be 1
    14421515*/
    14431516int ksCheckCoeff(number *a, number *b, const coeffs r)
  • libpolys/polys/kbuckets.h

    r220bb4 rb97cce6  
    8484number kBucketPolyRed(kBucket_pt bucket,
    8585                      poly p, int l,
    86                       poly spNoether,
    87                       BOOLEAN reduce);
     86                      poly spNoether);
     87void kBucketPolyRedNF(kBucket_pt bucket,
     88                      poly p1, int l1,
     89                      poly spNoether);
     90
    8891
    8992
  • libpolys/polys/nc/old.gring.cc

    r220bb4 rb97cce6  
    20762076  {
    20772077    p_Delete(&m, r);
    2078     ctmp = kBucketPolyRed(b,p,pLength(p),NULL,reduce);
     2078    ctmp = kBucketPolyRed(b,p,pLength(p),NULL);
    20792079  }
    20802080  else
     
    20842084    p_Cleardenom_n(pp,r,c2);
    20852085    p_Delete(&m, r);
    2086     ctmp = kBucketPolyRed(b,pp,pLength(pp),NULL,reduce);
     2086    if (reduce)
     2087    {
     2088      kBucketPolyRedNF(b,pp,pLength(pp),NULL);
     2089      ctmp=n_Init(1,r->cf);
     2090    }
     2091    else
     2092      ctmp = kBucketPolyRed(b,pp,pLength(pp),NULL);
    20872093    //cc=*c;
    20882094    //*c=nMult(*c,c2);
Note: See TracChangeset for help on using the changeset viewer.