Changeset 5038cd in git
- Timestamp:
- Nov 23, 2000, 6:34:13 PM (23 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 85342036e5a4c81e1cace3f56c0dc8c1c1c655e0
- Parents:
- 3d3d161d5697190f14e10031ef2c3cbb81a36c9f
- Location:
- Singular
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/kInline.cc
r3d3d16 r5038cd 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: kInline.cc,v 1.1 6 2000-11-16 09:54:49obachman Exp $9 * Version: $Id: kInline.cc,v 1.17 2000-11-23 17:34:07 obachman Exp $ 10 10 *******************************************************************/ 11 11 #ifndef KINLINE_CC … … 37 37 tailBin = omGetStickyBinOfBin(currRing->PolyBin); 38 38 #endif 39 pOrigFDeg = pFDeg; 40 pOrigLDeg = pLDeg; 39 41 } 40 42 … … 49 51 if (currRing != tailRing) 50 52 rKillModifiedRing(tailRing); 53 pLDeg = pOrigLDeg; 54 pFDeg = pOrigFDeg; 51 55 } 52 56 … … 284 288 p = p_LmDeleteAndNext(p, currRing); 285 289 } 290 is_normalized = FALSE; 286 291 } 287 292 … … 436 441 } 437 442 438 KINLINE void sLObject::SetLmTail(poly lm, poly p_tail, int p_Length, int use_bucket, ring tailRing) 439 { 443 KINLINE void sLObject::PrepareRed(BOOLEAN use_bucket) 444 { 445 if (bucket == NULL) 446 { 447 int l = GetpLength(); 448 if (use_bucket && l > 1) 449 { 450 poly tp = GetLmTailRing(); 451 bucket = kBucketCreate(tailRing); 452 kBucketInit(bucket, pNext(tp), l-1); 453 pNext(tp) = NULL; 454 if (p != NULL) pNext(p) = NULL; 455 pLength = 0; 456 } 457 } 458 } 459 460 KINLINE void sLObject::SetLmTail(poly lm, poly p_tail, int p_Length, int use_bucket, ring tailRing, poly _last) 461 { 462 440 463 Set(lm, tailRing); 441 464 if (use_bucket) … … 449 472 { 450 473 pNext(lm) = p_tail; 451 pLength = p_Length; 452 } 474 pLength = p_Length + 1; 475 last = _last; 476 } 477 453 478 } 454 479 … … 478 503 poly _p = (t_p != NULL ? t_p : p); 479 504 assume(_p != NULL); 480 int dummy;505 int shorter; 481 506 pNext(_p) = tailRing->p_Procs->p_Minus_mm_Mult_qq(pNext(_p), m, q, 482 dummy,spNoether,tailRing); 507 shorter,spNoether, 508 tailRing, last); 509 pLength += lq - shorter; 483 510 } 484 511 } … … 493 520 { 494 521 kBucketDestroy(&bucket); 522 p = t_p = NULL; 495 523 return; 496 524 } 497 525 Set(_p, tailRing); 498 526 } 499 } 500 501 KINLINE void sLObject::CanonicalizeP() 527 else 528 { 529 pLength--; 530 } 531 } 532 533 KINLINE poly sLObject::CanonicalizeP() 502 534 { 503 535 kTest_L(this); 536 int i = -1; 504 537 505 538 if (bucket != NULL) 506 kBucketCanonicalize(bucket);539 i = kBucketCanonicalize(bucket); 507 540 508 541 if (p == NULL) 509 542 p = k_LmInit_tailRing_2_currRing(t_p, tailRing); 543 544 if (i >= 0) pNext(p) = bucket->buckets[i]; 545 return p; 510 546 } 511 547 … … 554 590 } 555 591 592 KINLINE void sLObject::Copy() 593 { 594 if (bucket != NULL) 595 { 596 int i = kBucketCanonicalize(bucket); 597 kBucket_pt new_bucket = kBucketCreate(tailRing); 598 kBucketInit(new_bucket, 599 p_Copy(bucket->buckets[i], tailRing), 600 bucket->buckets_length[i]); 601 bucket = new_bucket; 602 if (t_p != NULL) pNext(t_p) = NULL; 603 if (p != NULL) pNext(p) = NULL; 604 } 605 TObject::Copy(); 606 last = NULL; 607 } 608 609 KINLINE poly sLObject::CopyGetP() 610 { 611 last = NULL; 612 if (bucket != NULL) 613 { 614 int i = kBucketCanonicalize(bucket); 615 poly bp = p_Copy(bucket->buckets[i], tailRing); 616 pLength = bucket->buckets_length[i] + 1; 617 if (bp != NULL) 618 { 619 assume(t_p != NULL || p != NULL); 620 if (t_p != NULL) pNext(t_p) = bp; 621 else pNext(p) = bp; 622 } 623 bucket = NULL; 624 } 625 return sLObject::GetP(); 626 } 627 628 556 629 KINLINE long sLObject::pLDeg() 557 630 { … … 569 642 return ::pLDeg(tp, &length, tailRing); 570 643 } 644 KINLINE long sLObject::pLDeg(BOOLEAN deg_last) 645 { 646 if (! deg_last || bucket != NULL) return sLObject::pLDeg(); 647 648 if (last == NULL || pLength == 0) 649 last = pLast((t_p != NULL ? t_p : p), pLength); 650 #ifdef HAVE_ASSUME 651 long fdeg; 652 fdeg = ::pLDeg(GetLmTailRing(), &length, tailRing); 653 assume (pLength == length && fdeg == ::pFDeg(last, tailRing)); 654 return fdeg; 655 #else 656 length = pLength; 657 return ::pFDeg(last, tailRing); 658 #endif 659 } 660 571 661 KINLINE long sLObject::SetDegStuffReturnLDeg() 572 662 { … … 576 666 return d; 577 667 } 578 KINLINE long sLObject::SetLength() 579 { 580 // this can be improved 581 this->pLDeg(); 668 KINLINE long sLObject::SetDegStuffReturnLDeg(BOOLEAN use_last) 669 { 670 FDeg = this->pFDeg(); 671 long d = this->pLDeg(use_last); 672 ecart = d - FDeg; 673 return d; 674 } 675 KINLINE int sLObject::GetpLength() 676 { 677 if (bucket == NULL) 678 return sTObject::GetpLength(); 679 int i = kBucketCanonicalize(bucket); 680 return bucket->buckets_length[i] + 1; 681 } 682 KINLINE int sLObject::SetLength(BOOLEAN length_pLength) 683 { 684 if (length_pLength) 685 length = this->GetpLength(); 686 else 687 this->pLDeg(); 582 688 return length; 583 689 } -
Singular/kbuckets.cc
r3d3d16 r5038cd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kbuckets.cc,v 1. 19 2000-10-26 06:39:26obachman Exp $ */4 /* $Id: kbuckets.cc,v 1.20 2000-11-23 17:34:08 obachman Exp $ */ 5 5 6 6 #include "mod2.h" … … 445 445 int i, l1; 446 446 poly p1 = p; 447 poly last; 447 448 448 449 if (*l <= 0) … … 482 483 else 483 484 { 485 int shorter = 0; 484 486 pSetCoeff0(m, nNeg(pGetCoeff(m))); 485 p1 = bucket->bucket_ring->p_Procs->pp_Mult_mm(p1, m, s pNoether, bucket->bucket_ring);487 p1 = bucket->bucket_ring->p_Procs->pp_Mult_mm(p1, m, shorter, spNoether, bucket->bucket_ring, last); 486 488 pSetCoeff0(m, nNeg(pGetCoeff(m))); 489 l1 -= shorter; 487 490 } 488 491 -
Singular/kspoly.cc
r3d3d16 r5038cd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kspoly.cc,v 1. 19 2000-11-14 16:04:53obachman Exp $ */4 /* $Id: kspoly.cc,v 1.20 2000-11-23 17:34:08 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - Routines for Spoly creation and reductions … … 101 101 102 102 // and finally, 103 PR->Tail_Minus_mm_Mult_qq(lm, t2, 104 (PR->bucket != NULL ? PW->GetpLength() - 1 : 0), 105 spNoether); 103 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether); 106 104 PR->LmDeleteAndIter(); 107 105 return ret; … … 121 119 poly p1 = Pair->p1; 122 120 poly p2 = Pair->p2; 121 poly last; 123 122 Pair->tailRing = tailRing; 124 123 … … 131 130 int co=0, ct = ksCheckCoeff(&lc1, &lc2); 132 131 133 int l1=0, l2=0 ;132 int l1=0, l2=0, shorter=0; 134 133 135 134 if (p_GetComp(p1, currRing)!=p_GetComp(p2, currRing)) … … 155 154 pSetCoeff0(m2, lc1); // and now, m1 * LT(p1) == m2 * LT(p2) 156 155 157 if ( use_buckets &&R != NULL)158 { 159 l1 = (R[Pair->i_r1])-> pLength- 1;160 l2 = (R[Pair->i_r2])-> pLength- 1;156 if (R != NULL) 157 { 158 l1 = (R[Pair->i_r1])->GetpLength() - 1; 159 l2 = (R[Pair->i_r2])->GetpLength() - 1; 161 160 } 162 161 163 162 // get m2 * a2 164 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, s pNoether, tailRing);165 Pair->SetLmTail(m2, a2, l2 , use_buckets, tailRing);163 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, shorter,spNoether,tailRing,last); 164 Pair->SetLmTail(m2, a2, l2-shorter, use_buckets, tailRing, last); 166 165 167 166 // get m2*a2 - m1*a1 … … 208 207 number coef; 209 208 209 pAssume(!pHaveCommonMonoms(Red.p, With.p)); 210 210 ret = ksReducePoly(&Red, &With, spNoether, &coef); 211 211 -
Singular/kstd1.cc
r3d3d16 r5038cd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd1.cc,v 1.6 5 2000-11-22 17:35:33 SingularExp $ */4 /* $Id: kstd1.cc,v 1.66 2000-11-23 17:34:08 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: … … 77 77 //static BOOLEAN posInLOldFlag; 78 78 /*FALSE, if posInL == posInL10*/ 79 80 /*0 implementation*/ 81 82 /*2 83 *p is a polynomial in the set s; 84 *recompute p and its ecart e with respect to the new noether 85 *(cut every monomial of pNext(p) above noether) 86 */ 87 void deleteHCs (TObject* p,kStrategy strat) 88 { 89 poly p1; 90 int o; 91 92 if (strat->kHEdgeFound) 93 { 94 p1 = (*p).p; 95 o = pFDeg(p1); 96 while (pNext(p1) != NULL) 97 { 98 if (pLmCmp(pNext(p1),strat->kNoether) == -1) 99 { 100 pDelete(&(pNext(p1))); 101 (*p).ecart = pLDeg((*p).p,&((*p).length))-o; 102 p->pLength = 0; 103 } 104 else 105 { 106 pIter(p1); 107 } 108 } 109 } 110 } 111 112 79 // returns TRUE if mora should use buckets, false otherwise 80 static BOOLEAN kMoraUseBucket(kStrategy strat); 81 82 static void kOptimizeLDeg(pFDegProc fdeg, pLDegProc ldeg, kStrategy strat) 83 { 84 if (fdeg == pDeg) 85 { 86 if (ldeg == pLDeg1) 87 pLDeg = pLDeg1_Deg; 88 if (ldeg == pLDeg1c) 89 pLDeg = pLDeg1c_Deg; 90 } 91 else if (fdeg == pTotaldegree) 92 { 93 if (ldeg == pLDeg1) 94 pLDeg = pLDeg1_Totaldegree; 95 if (ldeg == pLDeg1c) 96 pLDeg = pLDeg1c_Totaldegree; 97 } 98 99 if (strat->ak == 0 && !rIsSyzIndexRing(currRing)) 100 strat->length_pLength = TRUE; 101 102 if ((ldeg == pLDeg0c && !rIsSyzIndexRing(currRing)) || 103 (ldeg == pLDeg0 && strat->ak == 0)) 104 { 105 strat->LDegLast = TRUE; 106 } 107 else 108 { 109 strat->LDegLast = FALSE; 110 } 111 } 112 113 113 114 static int doRed (LObject* h, TObject* with,BOOLEAN intoT,kStrategy strat) 114 115 { … … 135 136 L.Copy(); 136 137 h->GetP(); 138 h->SetLength(strat->length_pLength); 137 139 ret = ksReducePoly(&L, with, strat->kNoether, NULL, strat); 138 140 if (ret) … … 158 160 } 159 161 160 #if 0161 /*2162 * reduces h with elements from T choosing first possible163 * element in T with respect to the given ecart164 */165 162 int redEcart (LObject* h,kStrategy strat) 166 163 { … … 169 166 int j = 0; 170 167 int pass = 0; 171 unsigned long not_sev;172 173 d = pFDeg((*h).p)+(*h).ecart;174 reddeg = strat->LazyDegree+d;175 h->sev = pGetShortExpVector(h->p);176 not_sev = ~ h->sev;177 loop178 {179 if (j > strat->tl)180 {181 if (strat->honey) pLDeg((*h).p,&((*h).length));182 return 1;183 }184 if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], (*h).p, not_sev))185 {186 //if (strat->interpt) test_int_std(strat->kIdeal);187 /*- compute the s-polynomial -*/188 pi = strat->T[j].p;189 ei = strat->T[j].ecart;190 li = strat->T[j].length;191 ii = j;192 /*193 * the polynomial to reduce with (up to the moment) is;194 * pi with ecart ei and length li195 */196 i = j;197 loop198 {199 /*- takes the first possible with respect to ecart -*/200 if (ei <= (*h).ecart) break;201 i++;202 if (i > strat->tl) break;203 if ((((strat->T[i]).ecart < ei)204 || (((strat->T[i]).ecart == ei)205 && ((strat->T[i]).length < li)))206 && pLmShortDivisibleBy(strat->T[i].p, strat->sevT[i],207 (*h).p, not_sev))208 {209 /*210 * the polynomial to reduce with is now;211 */212 pi = strat->T[i].p;213 ei = strat->T[i].ecart;214 li = strat->T[i].length;215 ii = i;216 }217 }218 /*219 * end of search: have to reduce with pi220 */221 if (ei > (*h).ecart)222 {223 /*224 * It is not possible to reduce h with smaller ecart;225 * if possible h goes to the lazy-set L,i.e226 * if its position in L would be not the last one227 */228 strat->fromT = TRUE;229 if (strat->Ll >= 0) /*- L is not empty -*/230 {231 if (strat->honey) pLDeg((*h).p,&((*h).length));232 at = strat->posInL(strat->L,strat->Ll,(*h),strat);233 if (at <= strat->Ll)234 {235 /*- h will not become the next element to reduce -*/236 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);237 if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);238 (*h).p = NULL;239 strat->fromT = FALSE;240 return -1;241 }242 }243 }244 doRed(h,&(strat->T[ii]),strat->fromT,strat);245 strat->fromT=FALSE;246 if ((*h).p == NULL)247 {248 if (h->lcm!=NULL) pLmFree((*h).lcm);249 return 0;250 }251 h->sev = pGetShortExpVector(h->p);252 not_sev = ~ h->sev;253 /*computes the ecart*/254 if (strat->honey)255 {256 if (ei <= (*h).ecart)257 (*h).ecart = d-pFDeg((*h).p);258 else259 (*h).ecart = d-pFDeg((*h).p)+ei-(*h).ecart;260 // pLDeg((*h).p,&((*h).length));261 //(*h).length = pLength((*h).p);262 }263 else264 (*h).ecart = pLDeg((*h).p,&((*h).length))-pFDeg((*h).p);265 if (strat->syzComp!=0)266 {267 if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))268 {269 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");270 return -2;271 }272 273 }274 /*- try to reduce the s-polynomial -*/275 pass++;276 d = pFDeg((*h).p)+(*h).ecart;277 /*278 *test whether the polynomial should go to the lazyset L279 *-if the degree jumps280 *-if the number of pre-defined reductions jumps281 */282 if ((strat->Ll >= 0)283 && ((d >= reddeg) || (pass > strat->LazyPass)))284 {285 if (strat->honey) pLDeg((*h).p,&((*h).length));286 at = strat->posInL(strat->L,strat->Ll,*h,strat);287 if (at <= strat->Ll)288 {289 i=strat->sl+1;290 do291 {292 i--;293 if (i<0) return 1;294 } while (!pLmShortDivisibleBy(strat->S[i], strat->sevS[i],295 (*h).p, not_sev));296 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);297 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);298 (*h).p = NULL;299 return -1;300 }301 }302 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))303 {304 Print(".%d",d);mflush();305 reddeg = d+1;306 }307 j = 0;308 }309 else310 {311 j++;312 }313 }314 }315 #else316 int redEcart (LObject* h,kStrategy strat)317 {318 poly pi;319 int i,at,reddeg,d,ei,li,ii;320 int j = 0;321 int pass = 0;322 168 323 169 d = h->GetpFDeg()+ h->ecart; … … 329 175 if (j < 0) 330 176 { 331 if (strat->honey) h->SetLength( );177 if (strat->honey) h->SetLength(strat->length_pLength); 332 178 return 1; 333 179 } … … 347 193 /*- takes the first possible with respect to ecart -*/ 348 194 i++; 349 // i = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h, i); 195 #if 1 350 196 if (i > strat->tl) break; 351 197 if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei && … … 353 199 && 354 200 pLmShortDivisibleBy(strat->T[i].p, strat->sevT[i], h->p, ~h->sev)) 201 #else 202 j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h, i); 203 if (j < 0) break; 204 i = j; 205 if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei && 206 strat->T[i].length < li)) 207 #endif 355 208 { 356 209 // the polynomial to reduce with is now … … 373 226 { 374 227 h->SetLmCurrRing(); 375 if (strat->honey) h->SetLength(); 228 if (strat->honey && strat->posInLDependsOnLength) 229 h->SetLength(strat->length_pLength); 376 230 assume(h->FDeg == h->pFDeg()); 377 at = strat->posInL(strat->L,strat->Ll, (*h),strat);231 at = strat->posInL(strat->L,strat->Ll,h,strat); 378 232 if (at <= strat->Ll) 379 233 { 234 h->CanonicalizeP(); 380 235 /*- h will not become the next element to reduce -*/ 381 h->CanonicalizeP();382 236 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); 383 237 #ifdef KDEBUG … … 415 269 else 416 270 // this has the side effect of setting h->length 417 h->ecart = h->pLDeg( ) - h->GetpFDeg();271 h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg(); 418 272 419 273 if (strat->syzComp!=0) … … 440 294 { 441 295 h->SetLmCurrRing(); 442 if (strat->honey) h->SetLength(); 296 if (strat->honey && strat->posInLDependsOnLength) 297 h->SetLength(strat->length_pLength); 443 298 assume(h->FDeg == h->pFDeg()); 444 at = strat->posInL(strat->L,strat->Ll, *h,strat);299 at = strat->posInL(strat->L,strat->Ll,h,strat); 445 300 if (at <= strat->Ll) 446 301 { 447 302 if (kFindDivisibleByInS(strat->S, strat->sevS, strat->sl, h) < 0) 303 { 304 if (strat->honey && !strat->posInLDependsOnLength) 305 h->SetLength(strat->length_pLength); 448 306 return 1; 307 } 449 308 h->CanonicalizeP(); 450 309 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); … … 463 322 } 464 323 } 465 #endif466 324 467 325 /*2 … … 488 346 if (j < 0) 489 347 { 490 if ( ! strat->homog)491 h->SetDegStuffReturnLDeg( );348 if (strat->homog) 349 h->SetDegStuffReturnLDeg(strat->LDegLast); 492 350 return 1; 493 351 } … … 529 387 if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); 530 388 #endif 389 if (strat->homog) 390 h->SetDegStuffReturnLDeg(strat->LDegLast); 531 391 return -2; 532 392 } … … 534 394 if (!strat->homog) 535 395 { 536 d = h->SetDegStuffReturnLDeg( );396 d = h->SetDegStuffReturnLDeg(strat->LDegLast); 537 397 /*- try to reduce the s-polynomial -*/ 538 398 pass++; … … 546 406 { 547 407 h->SetLmCurrRing(); 548 at = strat->posInL(strat->L,strat->Ll, *h,strat);408 at = strat->posInL(strat->L,strat->Ll,h,strat); 549 409 if (at <= strat->Ll) 550 410 { … … 579 439 int j = 0; 580 440 int z = 10; 581 int o = pFDeg(h);441 int o = H.SetpFDeg(); 582 442 H.ecart = pLDeg(H.p,&H.length)-o; 583 443 if (flag==0) cancelunit(&H); … … 657 517 } 658 518 /*- try to reduce the s-polynomial -*/ 659 o = pFDeg(H.p);519 o = H.SetpFDeg(); 660 520 cancelunit(&H); 661 521 H.ecart = pLDeg(H.p,&(H.length))-o; … … 681 541 for (i=1; i<=strat->Ll; i++) 682 542 { 683 at = strat->posInL(strat->L,i-1, strat->L[i],strat);543 at = strat->posInL(strat->L,i-1,&(strat->L[i]),strat); 684 544 if (at != i) 685 545 { … … 762 622 *(should be minimal) 763 623 */ 764 BOOLEAN hasPurePower ( poly p,int last, int *length,kStrategy strat)624 BOOLEAN hasPurePower (const poly p,int last, int *length,kStrategy strat) 765 625 { 766 626 poly h; … … 769 629 if (pNext(p) == strat->tail) 770 630 return FALSE; 771 if (pMinComp(p) == strat->ak) 772 { 773 *length = 0; 774 h = p; 631 pp_Test(p, currRing, strat->tailRing); 632 if (p_MinComp(p, currRing, strat->tailRing) == strat->ak) 633 { 634 i = p_IsPurePower(p, currRing); 635 if (i == last) 636 { 637 *length = 0; 638 return TRUE; 639 } 640 *length = 1; 641 h = pNext(p); 775 642 while (h != NULL) 776 643 { 777 i = p IsPurePower(h);644 i = p_IsPurePower(h, strat->tailRing); 778 645 if (i==last) return TRUE; 779 646 (*length)++; … … 782 649 } 783 650 return FALSE; 651 } 652 653 BOOLEAN hasPurePower (LObject *L,int last, int *length,kStrategy strat) 654 { 655 if (L->bucket != NULL) 656 { 657 poly p = L->CanonicalizeP(); 658 BOOLEAN ret = hasPurePower(p, last, length, strat); 659 pNext(p) = NULL; 660 return ret; 661 } 662 else 663 { 664 return hasPurePower(L->p, last, length, strat); 665 } 784 666 } 785 667 … … 788 670 * in the case of looking for the pure powers 789 671 */ 790 int posInL10 (LSet const set, int length, const LObject &p,kStrategy const strat)672 int posInL10 (LSet const set, int length, LObject* p,kStrategy const strat) 791 673 { 792 674 int j,dp,dL; 793 675 794 676 if (length<0) return 0; 795 if (hasPurePower(p .p,strat->lastAxis,&dp,strat))796 { 797 int op= p FDeg(p.p)+p.ecart;677 if (hasPurePower(p,strat->lastAxis,&dp,strat)) 678 { 679 int op= p->GetpFDeg() +p->ecart; 798 680 for (j=length; j>=0; j--) 799 681 { 800 if (!hasPurePower( set[j].p,strat->lastAxis,&dL,strat))682 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) 801 683 return j+1; 802 684 if (dp < dL) 803 685 return j+1; 804 686 if ((dp == dL) 805 && (pFDeg(set[j].p)+set[j].ecart >= op))687 && (set[j].GetpFDeg()+set[j].ecart >= op)) 806 688 return j+1; 807 689 } … … 811 693 { 812 694 if (j<0) break; 813 if (!hasPurePower( set[j].p,strat->lastAxis,&dL,strat)) break;695 if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break; 814 696 j--; 815 697 } 816 698 return strat->posInLOld(set,j,p,strat); 817 699 } 700 818 701 819 702 /*2 … … 828 711 { 829 712 if (j<0) break; 830 if (hasPurePower( strat->L[j].p,strat->lastAxis,&dL,strat))713 if (hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat)) 831 714 { 832 715 p=strat->L[strat->Ll]; … … 846 729 { 847 730 pLmFree(strat->L[j].p); /*deletes the short spoly and computes*/ 848 strat->L[j].p=ksOldCreateSpoly(strat->L[j].p1, 849 strat->L[j].p2, 850 strat->kNoether); /*the real one*/ 731 poly m1 = NULL, m2 = NULL; 732 // check that spoly creation is ok 733 while (strat->tailRing != currRing && 734 !kCheckSpolyCreation(&(strat->L[j]), strat, m1, m2)) 735 { 736 assume(m1 == NULL && m2 == NULL); 737 // if not, change to a ring where exponents are at least 738 // large enough 739 kStratChangeTailRing(strat); 740 } 741 /* create the real one */ 742 ksCreateSpoly(&(strat->L[j]), strat->kNoether, FALSE, 743 strat->tailRing, m1, m2, strat->R); 744 851 745 if (!strat->honey) 852 746 strat->initEcart(&strat->L[j]); 853 747 else 854 strat->L[j].length = pLength(strat->L[j].p); 855 if (hasPurePower(strat->L[j].p,strat->lastAxis,&dL,strat)) 748 strat->L[j].SetLength(strat->length_pLength); 749 750 BOOLEAN pp = hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat); 751 752 if (strat->use_buckets) strat->L[j].PrepareRed(TRUE); 753 754 if (pp) 856 755 { 857 756 p=strat->L[strat->Ll]; … … 873 772 { 874 773 int i = 0; 774 kTest_TS(strat); 875 775 while (i <= strat->Ll) 876 776 { … … 886 786 { 887 787 pLmFree(strat->L[i].p); 888 strat->L[i].p = ksOldCreateSpoly(strat->L[i].p1, 889 strat->L[i].p2, 890 strat->kNoether); 788 poly m1 = NULL, m2 = NULL; 789 // check that spoly creation is ok 790 while (strat->tailRing != currRing && 791 !kCheckSpolyCreation(&(strat->L[i]), strat, m1, m2)) 792 { 793 assume(m1 == NULL && m2 == NULL); 794 // if not, change to a ring where exponents are at least 795 // large enough 796 kStratChangeTailRing(strat); 797 } 798 /* create the real one */ 799 ksCreateSpoly(&(strat->L[i]), strat->kNoether, FALSE, 800 strat->tailRing, m1, m2, strat->R); 891 801 strat->L[i].SetpFDeg(); 892 strat->L[i].ecart = pLDeg(strat->L[i].p,&strat->L[i].length) 893 -strat->L[i].GetpFDeg(); 802 strat->L[i].ecart 803 = strat->L[i].pLDeg(strat->LDegLast) - strat->L[i].GetpFDeg(); 804 if (strat->use_buckets) strat->L[i].PrepareRed(TRUE); 894 805 } 895 806 } 896 807 else 897 deleteHC(& strat->L[i].p,&strat->L[i].ecart,&strat->L[i].length,strat);898 if (strat->L[i]. p == NULL)808 deleteHC(&(strat->L[i]), strat); 809 if (strat->L[i].IsNull()) 899 810 deleteInL(strat->L,&strat->Ll,i,strat); 900 811 else 812 { 813 #ifdef KDEBUG 814 kTest_L(&(strat->L[i]), strat->tailRing, TRUE, i, strat->T, strat->tl); 815 #endif 901 816 i++; 902 } 817 } 818 } 819 kTest_TS(strat); 903 820 } 904 821 … … 914 831 { 915 832 p = strat->T[i]; 916 deleteHC s(&p,strat);833 deleteHC(&p,strat, TRUE); 917 834 /*- tries to cancel a unit: -*/ 918 835 cancelunit(&p); … … 934 851 if (strat->update) 935 852 { 853 kTest_TS(strat); 936 854 strat->update = (strat->tl == -1); 937 855 if (TEST_OPT_WEIGHTM) … … 951 869 } 952 870 pLDeg=pLDegOld; 871 kOptimizeLDeg(pFDeg, pLDeg, strat); 953 872 if (ecartWeights) 954 873 { … … 965 884 return; 966 885 if (!BTEST1(20)) /*- take the first possible -*/ 886 { 967 887 strat->red = redFirst; 888 strat->use_buckets = kMoraUseBucket(strat); 889 } 968 890 updateT(strat); 969 891 strat->posInT = posInT2; 970 892 reorderT(strat); 971 893 } 894 kTest_TS(strat); 972 895 } 973 896 … … 1022 945 strat->posInLOldFlag = FALSE; 1023 946 strat->posInL = posInL10; 947 strat->posInLDependsOnLength = TRUE; 1024 948 updateL(strat); 1025 949 reorderL(strat); … … 1104 1028 mflush(); 1105 1029 } 1106 } 1030 kOptimizeLDeg(pFDeg, pLDeg, strat); 1031 } 1032 1033 #ifdef HAVE_ASSUME 1034 static int mora_count = 0; 1035 static int mora_loop_count; 1036 #endif 1107 1037 1108 1038 ideal mora (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) 1109 1039 { 1040 #ifdef HAVE_ASSUME 1041 mora_count++; 1042 mora_loop_count = 0; 1043 #endif 1044 #ifdef KDEBUG 1045 om_Opts.MinTrack = 5; 1046 #endif 1110 1047 int srmax; 1111 1048 int lrmax = 0; … … 1143 1080 } 1144 1081 srmax = strat->sl; 1082 kTest_TS(strat); 1083 strat->use_buckets = kMoraUseBucket(strat); 1145 1084 /*- compute-------------------------------------------*/ 1146 1085 while (strat->Ll >= 0) 1147 1086 { 1148 kTest_TS(strat); 1087 #ifdef HAVE_ASSUME 1088 mora_loop_count++; 1089 #endif 1149 1090 if (lrmax< strat->Ll) lrmax=strat->Ll; /*stat*/ 1150 1091 //test_int_std(strat->kIdeal); 1151 1092 if (TEST_OPT_DEBUG) messageSets(strat); 1152 1093 if (TEST_OPT_DEGBOUND 1153 && (strat->L[strat->Ll].ecart+ pFDeg(strat->L[strat->Ll].p)> Kstd1_deg))1094 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)) 1154 1095 { 1155 1096 /* … … 1159 1100 */ 1160 1101 while ((strat->Ll >= 0) 1161 && (strat->L[strat->Ll].ecart+ pFDeg(strat->L[strat->Ll].p)> Kstd1_deg)1102 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg) 1162 1103 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)) 1163 1104 { … … 1173 1114 if (strat->Ll==0) strat->interpt=TRUE; 1174 1115 strat->Ll--; 1116 1117 // create the real Spoly 1175 1118 if (pNext(strat->P.p) == strat->tail) 1176 1119 { 1177 pLmFree(strat->P.p);/*- deletes the short spoly and computes -*/ 1178 strat->P.p = ksOldCreateSpoly(strat->P.p1, 1179 strat->P.p2, 1180 strat->kNoether);/*- the real one -*/ 1181 if (!strat->honey) 1120 /*- deletes the short spoly and computes -*/ 1121 pLmFree(strat->P.p); 1122 strat->P.p = NULL; 1123 poly m1 = NULL, m2 = NULL; 1124 // check that spoly creation is ok 1125 while (strat->tailRing != currRing && 1126 !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) 1127 { 1128 assume(m1 == NULL && m2 == NULL); 1129 // if not, change to a ring where exponents are large enough 1130 kStratChangeTailRing(strat); 1131 } 1132 /* create the real one */ 1133 ksCreateSpoly(&(strat->P), strat->kNoether, strat->use_buckets, 1134 strat->tailRing, m1, m2, strat->R); 1135 if (!strat->use_buckets) 1136 strat->P.SetLength(strat->length_pLength); 1137 } 1138 else if (strat->P.p1 == NULL) 1139 { 1140 // for input polys, prepare reduction 1141 strat->P.SetLength(strat->length_pLength); 1142 strat->P.PrepareRed(strat->use_buckets); 1143 } 1144 1145 1146 if (TEST_OPT_PROT) 1147 message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat); 1148 1149 strat->red(&strat->P,strat);/*- reduction of the element choosen from L -*/ 1150 1151 if (strat->P.p != NULL) 1152 { 1153 strat->P.GetP(); 1154 assume(strat->P.sev == 0 || strat->P.sev == pGetShortExpVector(strat->P.p)); 1155 if (TEST_OPT_PROT) PrintS("s");/*- statistic -*/ 1156 /*- enter P.p into s and b: -*/ 1157 if (!TEST_OPT_INTSTRATEGY) 1158 strat->P.pNorm(); 1159 1160 strat->P.p = redtail(strat->P.p,strat->sl,strat); 1161 if (strat->redTailChange) 1162 { 1163 strat->P.pLength = 0; 1164 strat->P.last = NULL; 1165 } 1166 1167 if ((!strat->noTailReduction) && (!strat->honey)) 1168 { 1182 1169 strat->initEcart(&strat->P); 1183 else 1184 strat->P.length = pLength(strat->P.p); 1185 } 1186 { 1187 if (TEST_OPT_PROT) message(strat->P.ecart+(strat->P.p == NULL ? 0 : pFDeg(strat->P.p)),&olddeg,&reduc,strat); 1188 strat->red(&strat->P,strat);/*- reduction of the element choosen from L -*/ 1189 } 1190 if (strat->P.p != NULL) 1191 { 1192 assume(strat->P.sev == 0 || strat->P.sev == pGetShortExpVector(strat->P.p)); 1193 if (TEST_OPT_PROT) PrintS("s");/*- statistic -*/ 1194 /*- enter P.p into s and b: -*/ 1195 if (!TEST_OPT_INTSTRATEGY) 1196 { 1197 pNorm(strat->P.p); 1198 } 1199 strat->P.p = redtail(strat->P.p,strat->sl,strat); 1200 if ((!strat->noTailReduction) && (!strat->honey)) 1201 { 1202 strat->initEcart(&strat->P); 1203 } 1204 if (TEST_OPT_INTSTRATEGY) 1205 { 1206 //pContent(strat->P.p); 1207 pCleardenom(strat->P.p);// also does a pContent 1208 } 1209 cancelunit(&strat->P);/*- tries to cancel a unit -*/ 1210 enterT(strat->P,strat); 1211 { 1212 int pos; 1213 { 1214 enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat); 1215 if (strat->sl==-1) 1216 { 1217 pos=0; 1218 } 1219 else 1220 { 1221 pos = posInS(strat->S,strat->sl,strat->P.p); 1222 } 1223 strat->enterS(strat->P,pos,strat, strat->tl); 1224 } 1225 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); 1226 } 1227 kTest_TS(strat); 1228 if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); 1229 strat->P.lcm=NULL; 1170 } 1171 if (TEST_OPT_INTSTRATEGY) 1172 strat->P.pCleardenom(); 1173 cancelunit(&strat->P);/*- tries to cancel a unit -*/ 1174 enterT(strat->P,strat); 1175 int pos; 1176 { 1177 enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl); 1178 if (strat->sl==-1) 1179 { 1180 pos=0; 1181 } 1182 else 1183 { 1184 pos = posInS(strat->S,strat->sl,strat->P.p); 1185 } 1186 strat->enterS(strat->P,pos,strat, strat->tl); 1187 } 1188 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); 1189 if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); 1190 strat->P.lcm=NULL; 1230 1191 #ifdef KDEBUG 1231 1192 memset(&strat->P,0,sizeof(strat->P)); … … 1250 1211 } 1251 1212 } 1213 kTest_TS(strat); 1252 1214 } 1253 1215 /*- complete reduction of the standard basis------------------------ -*/ … … 1356 1318 h.length = pLength(h.p); 1357 1319 h.sev = strat->sevS[i]; 1320 h.SetpFDeg(); 1358 1321 enterT(h,strat); 1359 1322 } … … 1480 1443 h.p = strat->S[j]; 1481 1444 h.ecart = strat->ecartS[j]; 1482 h. length = pLength(h.p);1445 h.pLength = h.length = pLength(h.p); 1483 1446 if (strat->sevS[j] == 0) strat->sevS[j] = pGetShortExpVector(h.p); 1484 1447 else assume(strat->sevS[j] == pGetShortExpVector(h.p)); 1485 1448 h.sev = strat->sevS[j]; 1486 h. length = pLength(h.p);1449 h.SetpFDeg(); 1487 1450 enterT(h,strat); 1488 1451 } … … 1873 1836 return shdl; 1874 1837 } 1838 1839 // returns TRUE if mora should use buckets, false otherwise 1840 static BOOLEAN kMoraUseBucket(kStrategy strat) 1841 { 1842 if (TEST_OPT_NOT_BUCKETS) 1843 return FALSE; 1844 if (strat->red == redFirst) 1845 { 1846 if (strat->homog && !strat->syzComp) 1847 return TRUE; 1848 else 1849 return FALSE; 1850 } 1851 else 1852 { 1853 assume(strat->red == redEcart); 1854 if (strat->honey && !strat->syzComp) 1855 return TRUE; 1856 else 1857 return FALSE; 1858 } 1859 } -
Singular/kstd2.cc
r3d3d16 r5038cd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1.6 1 2000-11-16 09:54:50obachman Exp $ */4 /* $Id: kstd2.cc,v 1.62 2000-11-23 17:34:09 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 31 31 // number of first divisor, otherwise 32 32 int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT, 33 const int tl, const LObject* L )33 const int tl, const LObject* L, int start) 34 34 { 35 35 unsigned long not_sev = ~L->sev; 36 int j = 0;36 int j = start; 37 37 poly p; 38 38 ring r; … … 75 75 } 76 76 } 77 return -1;78 77 } 79 78 … … 108 107 static int redHomog (LObject* h,kStrategy strat) 109 108 { 110 if (strat->tl<0) return 1;109 // if (strat->tl<0) return 1; 111 110 #ifdef KDEBUG 112 111 if (TEST_OPT_DEBUG) … … 123 122 h->SetShortExpVector(); 124 123 j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h); 125 if (j < 0) return 1; 124 if (j < 0) 125 { 126 h->SetpFDeg(); 127 return 1; 128 } 126 129 127 130 // now we found one which is divisible -- reduce it … … 131 134 if (TEST_OPT_DEBUG) 132 135 { 133 Print("\n %pto ", h->t_p);136 Print("\nto ", h->t_p); 134 137 h->wrp(); 135 138 PrintLn(); … … 159 162 int pass = 0; 160 163 assume(h->pFDeg() == h->FDeg); 161 int reddeg = h->FDeg;164 long reddeg = h->GetpFDeg(); 162 165 163 166 h->SetShortExpVector(); … … 203 206 { 204 207 h->SetLmCurrRing(); 205 at = posInL11(strat->L,strat->Ll, *h,strat);208 at = posInL11(strat->L,strat->Ll,h,strat); 206 209 if (at <= strat->Ll) 207 210 { … … 236 239 237 240 poly h_p; 238 int i,j,at, reddeg,d,pass,ei, ii, h_d;241 int i,j,at,pass,ei, ii, h_d; 239 242 unsigned long not_sev; 240 243 long reddeg,d; 244 241 245 pass = j = 0; 242 d = reddeg = h-> FDeg+ h->ecart;246 d = reddeg = h->GetpFDeg() + h->ecart; 243 247 h->SetShortExpVector(); 244 248 h_p = h->GetLmTailRing(); … … 289 293 if (strat->Ll >= 0) /* L is not empty */ 290 294 { 291 at = strat->posInL(strat->L,strat->Ll, *h,strat);295 at = strat->posInL(strat->L,strat->Ll,h,strat); 292 296 293 297 if(at <= strat->Ll) … … 354 358 { 355 359 h->SetLmCurrRing(); 356 at = strat->posInL(strat->L,strat->Ll, *h,strat);360 at = strat->posInL(strat->L,strat->Ll,h,strat); 357 361 if (at <= strat->Ll) 358 362 { … … 483 487 } 484 488 489 #ifdef KDEBUG 490 static int bba_count = 0; 491 #endif 492 485 493 ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) 486 494 { 495 #ifdef KDEBUG 496 bba_count++; 497 int loop_count = 0; 498 #endif 487 499 om_Opts.MinTrack = 5; 488 500 int srmax,lrmax, red_result; … … 500 512 reduc = olddeg = lrmax = 0; 501 513 502 if (!TEST_OPT_NOT_BUCKETS && 503 (strat->red == redHomog || strat->red == redHoney)) 514 if (!TEST_OPT_NOT_BUCKETS) 504 515 strat->use_buckets = 1; 505 516 … … 515 526 if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/ 516 527 #ifdef KDEBUG 528 loop_count++; 517 529 if (TEST_OPT_DEBUG) messageSets(strat); 518 530 #endif … … 536 548 if (pNext(strat->P.p) == strat->tail) 537 549 { 550 // deletes the short spoly 551 pLmFree(strat->P.p); 552 strat->P.p = NULL; 538 553 poly m1 = NULL, m2 = NULL; 539 /* check that spoly creation is ok */ 554 555 // check that spoly creation is ok 540 556 while (strat->tailRing != currRing && 541 !kCheckSpolyCreation( strat, m1, m2))557 !kCheckSpolyCreation(&(strat->P), strat, m1, m2)) 542 558 { 543 559 assume(m1 == NULL && m2 == NULL); … … 546 562 kStratChangeTailRing(strat); 547 563 } 548 /* deletes the short spoly and computes */ 549 pLmFree(strat->P.p); 550 strat->P.p=NULL; 551 /* create the real one */ 564 // create the real one 552 565 ksCreateSpoly(&(strat->P), strat->kNoether, strat->use_buckets, 553 566 strat->tailRing, m1, m2, strat->R); 554 567 } 555 556 if ((strat->P.p1==NULL) && (strat->minim>0)) 557 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); 558 568 else if (strat->P.p1 == NULL) 569 { 570 if (strat->minim > 0) 571 strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing); 572 // for input polys, prepare reduction 573 strat->P.PrepareRed(strat->use_buckets); 574 } 575 559 576 if (TEST_OPT_PROT) 560 577 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), … … 569 586 /* statistic */ 570 587 if (TEST_OPT_PROT) PrintS("s"); 588 589 // get the polynomial (canonicalize bucket, make sure P.p is set) 571 590 strat->P.GetP(strat->lmBin); 572 /* enter P.p into s and L */ 573 { 574 int pos=posInS(strat->S,strat->sl,strat->P.p); 575 if (TEST_OPT_INTSTRATEGY) 591 592 int pos=posInS(strat->S,strat->sl,strat->P.p); 593 594 // reduce the tail and normailze poly 595 if (TEST_OPT_INTSTRATEGY) 596 { 597 strat->P.pCleardenom(); 598 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 576 599 { 600 strat->P.p = redtailBba(&(strat->P),pos-1,strat); 601 if (strat->redTailChange) strat->P.pLength = 0; 577 602 strat->P.pCleardenom(); 578 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 579 { 580 strat->P.p = redtailBba(&(strat->P),pos-1,strat); 581 if (strat->redTailChange) strat->P.pLength = 0; 582 strat->P.pCleardenom(); 583 } 603 } 604 } 605 else 606 { 607 strat->P.pNorm(); 608 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 609 { 610 strat->P.p = redtailBba(&(strat->P),pos-1,strat); 611 if (strat->redTailChange) strat->P.pLength = 0; 612 } 613 } 614 615 #ifdef KDEBUG 616 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} 617 #endif 618 619 // min_std stuff 620 if ((strat->P.p1==NULL) && (strat->minim>0)) 621 { 622 if (strat->minim==1) 623 { 624 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); 625 p_Delete(&strat->P.p2, currRing, strat->tailRing); 584 626 } 585 627 else 586 628 { 587 strat->P.pNorm(); 588 if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) 589 { 590 strat->P.p = redtailBba(&(strat->P),pos-1,strat); 591 if (strat->redTailChange) strat->P.pLength = 0; 592 } 629 strat->M->m[minimcnt]=strat->P.p2; 630 strat->P.p2=NULL; 593 631 } 594 #ifdef KDEBUG 595 if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();} 596 #endif 597 if ((strat->P.p1==NULL) && (strat->minim>0)) 598 { 599 if (strat->minim==1) 600 { 601 strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing); 602 p_Delete(&strat->P.p2, currRing, strat->tailRing); 603 } 604 else 605 { 606 strat->M->m[minimcnt]=strat->P.p2; 607 strat->P.p2=NULL; 608 } 609 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) 610 pNext(strat->M->m[minimcnt]) 611 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), 612 strat->tailRing, currRing, 613 currRing->PolyBin); 614 minimcnt++; 615 } 616 617 // put stuff into T-Set 618 enterT(strat->P, strat); 619 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); 620 // posInS only depends on the leading term 621 strat->enterS(strat->P, pos, strat, strat->tl); 622 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); 623 } 632 if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL) 633 pNext(strat->M->m[minimcnt]) 634 = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]), 635 strat->tailRing, currRing, 636 currRing->PolyBin); 637 minimcnt++; 638 } 639 640 // enter into S, L, and T 641 enterT(strat->P, strat); 642 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); 643 // posInS only depends on the leading term 644 strat->enterS(strat->P, pos, strat, strat->tl); 645 if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); 624 646 if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); 625 647 if (strat->sl>srmax) srmax = strat->sl; -
Singular/kutil.cc
r3d3d16 r5038cd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.7 8 2000-11-16 09:54:51obachman Exp $ */4 /* $Id: kutil.cc,v 1.79 2000-11-23 17:34:09 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 12 12 // #define PDEBUG 2 13 13 // #define PDIV_DEBUG 14 14 #include <limits.h> 15 15 #include <stdlib.h> 16 16 #include <string.h> … … 20 20 #define KDEBUG 2 21 21 #endif 22 // define if enterL, enterT should use memmove instead of doing it manually 23 // on topgun, this is slightly faster (see monodromy_l.tst) 24 #define ENTER_USE_MEMMOVE 25 22 26 #include "tok.h" 23 27 #include "kutil.h" … … 90 94 *works only for orderings with ecart =pFDeg(end)-pFDeg(start) 91 95 */ 96 void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext) 97 { 98 if (strat->kHEdgeFound) 99 { 100 kTest_L(L); 101 poly p1; 102 poly p = L->GetLmTailRing(); 103 int l = 1; 104 if (L->bucket != NULL) 105 { 106 kBucketClear(L->bucket, &pNext(p), &L->pLength); 107 L->pLength++; 108 } 109 110 if (!fromNext && p_Cmp(p,strat->kNoether, L->tailRing) == -1) 111 { 112 L->Delete(); 113 L->Clear(); 114 L->ecart = -1; 115 return; 116 } 117 p1 = p; 118 while (pNext(p1)!=NULL) 119 { 120 if (p_LmCmp(pNext(p1), strat->kNoether, L->tailRing) == -1) 121 { 122 if (L->last != NULL) 123 L->last = p1; 124 p_Delete(&pNext(p1), L->tailRing); 125 if (p1 == p) 126 { 127 if (L->t_p != NULL) 128 { 129 assume(L->p != NULL && p == L->t_p); 130 pNext(L->p) = NULL; 131 } 132 } 133 if (L->pLength != 0) L->pLength = l; 134 // Hmmm when called from updateT, then only 135 // reset ecart when cut 136 if (fromNext) 137 L->ecart = L->pLDeg() - L->GetpFDeg(); 138 break; 139 } 140 l++; 141 pIter(p1); 142 } 143 if (L->bucket != NULL) 144 { 145 if (L->pLength > 1) 146 { 147 kBucketInit(L->bucket, pNext(p), L->pLength - 1); 148 pNext(p) = NULL; 149 if (L->t_p != NULL) pNext(L->t_p) = NULL; 150 L->pLength = 0; 151 } 152 else 153 kBucketDestroy(&L->bucket); 154 } 155 if (! fromNext) 156 { 157 L->SetpFDeg(); 158 L->ecart = L->pLDeg() - L->GetpFDeg(); 159 } 160 kTest_L(L); 161 } 162 } 163 92 164 void deleteHC(poly* p, int* e, int* l,kStrategy strat) 93 165 { 94 poly p1; 95 96 if (strat->kHEdgeFound) 97 { 98 if (pCmp(*p,strat->kNoether) == -1) 99 { 100 pDelete(p); 101 *l = 0; 102 *e = -1; 103 return; 104 } 105 p1 = *p; 106 while (pNext(p1)!=NULL) 107 { 108 if (pLmCmp(pNext(p1), strat->kNoether) == -1) 109 pDelete(&pNext(p1)); 110 else 111 pIter(p1); 112 } 113 *e = pLDeg(*p,l)-pFDeg(*p); 114 } 166 LObject L(*p, currRing, strat->tailRing); 167 168 deleteHC(&L, strat); 169 *p = L.p; 170 *e = L.ecart; 171 *l = L.length; 172 if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing); 115 173 } 116 174 … … 141 199 L->ecart = 0; 142 200 L->length = 1; 143 L->pLength = 1; // let pLength be determined dynamically 201 if (L->pLength > 0) L->pLength = 1; 202 if (L->last != NULL) L->last = p; 203 144 204 if (L->t_p != NULL && pNext(L->t_p) != NULL) 145 205 pNext(L->t_p) = NULL; … … 460 520 } 461 521 462 if (T->pLength != 0 && 463 T->pLength != pLength(p)) 522 if (i >= 0 && T->pLength != 0 && T->pLength != pLength(p)) 464 523 { 465 524 return dReportError("%c[%d] pLength error: has %d, specified to have %d", … … 491 550 if (testp) 492 551 { 552 poly pn = NULL; 493 553 if (L->bucket != NULL) 494 554 { 495 555 kFalseReturn(kbTest(L->bucket)); 496 556 r_assume(L->bucket->bucket_ring == L->tailRing); 557 if (L->p != NULL && pNext(L->p) != NULL) 558 { 559 pn = pNext(L->p); 560 pNext(L->p) = NULL; 561 } 497 562 } 498 563 kFalseReturn(kTest_T(L, strat_tailRing, lpos, 'L')); 564 if (pn != NULL) 565 pNext(L->p) = pn; 566 499 567 ring r; 500 568 poly p; … … 504 572 return dReportError("L[%d] wrong sev: has %o, specified to have %o", 505 573 lpos, p_GetShortExpVector(p, r), L->sev); 574 } 575 if (lpos > 0 && L->last != NULL && pLast(p) != L->last) 576 { 577 return dReportError("L[%d] last wrong: has %p specified to have %p", 578 lpos, pLast(p), L->last); 506 579 } 507 580 } … … 618 691 for (i=0; i<=strat->Ll; i++) 619 692 { 620 if (strat->L[i].i_r1 >= 0 && 621 (strat->L[i].i_r1 > strat->tl || 622 strat->L[i].T_1(strat)->p != strat->L[i].p1)) 623 return dReportError("L[%d].i_r1 out of sync", i); 624 if (strat->L[i].i_r2 >= 0 && 625 (strat->L[i].i_r2 > strat->tl || 626 strat->L[i].T_2(strat)->p != strat->L[i].p2)) 627 return dReportError("L[%d].i_r2 out of sync", i); 693 if (strat->L[i].p1 != NULL && strat->L[i].p2) 694 { 695 if (strat->L[i].i_r1 < 0 || 696 strat->L[i].i_r1 > strat->tl || 697 strat->L[i].T_1(strat)->p != strat->L[i].p1) 698 return dReportError("L[%d].i_r1 out of sync", i); 699 if (strat->L[i].i_r2 < 0 || 700 strat->L[i].i_r2 > strat->tl || 701 strat->L[i].T_2(strat)->p != strat->L[i].p2); 702 } 703 else 704 { 705 if (strat->L[i].i_r1 != -1) 706 return dReportError("L[%d].i_r1 out of sync", i); 707 if (strat->L[i].i_r2 != -1) 708 return dReportError("L[%d].i_r2 out of sync", i); 709 } 628 710 } 629 711 return TRUE; … … 691 773 { 692 774 /* not found : */ 775 if (set[j].bucket != NULL) 776 { 777 kBucketDeleteAndDestroy(&set[j].bucket); 778 pNext(p) = NULL; 779 if (set[j].t_p != NULL) pNext(set[j].t_p) = NULL; 780 } 693 781 if (set[j].t_p != NULL) 694 782 { … … 700 788 pDelete(&p); 701 789 } 702 if (set[j].bucket != NULL)703 kBucketDeleteAndDestroy(&set[j].bucket);704 790 break; 705 791 } … … 751 837 int i; 752 838 // this should be corrected 753 p.FDeg = p.pFDeg();839 assume(p.FDeg == p.pFDeg()); 754 840 if ((*length)>=0) 755 841 { 756 842 if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmax); 843 if (at <= (*length)) 844 #ifdef ENTER_USE_MEMMOVE 845 memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject)); 846 #else 757 847 for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1]; 848 #endif 758 849 } 759 850 else at = 0; … … 990 1081 nDelete(&(Lp.p->coef)); 991 1082 } 992 l = strat->posInL(strat->B,strat->Bl, Lp,strat);1083 l = strat->posInL(strat->B,strat->Bl,&Lp,strat); 993 1084 enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l); 994 1085 } … … 1052 1143 nDelete(&(Lp.p->coef)); 1053 1144 } 1054 l = strat->posInL(strat->L,strat->Ll, Lp,strat);1145 l = strat->posInL(strat->L,strat->Ll,&Lp,strat); 1055 1146 enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,l); 1056 1147 } … … 1194 1285 for (i=strat->Bl; i>=0; i--) 1195 1286 { 1196 j = strat->posInL(strat->L,j-1, strat->B[i],strat);1287 j = strat->posInL(strat->L,j-1,&(strat->B[i]),strat); 1197 1288 enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j); 1198 1289 } … … 1228 1319 for (i=strat->Bl; i>=0; i--) 1229 1320 { 1230 j = strat->posInL(strat->L,j, strat->B[i],strat);1321 j = strat->posInL(strat->L,j,&(strat->B[i]),strat); 1231 1322 enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j); 1232 1323 } … … 1635 1726 * int o; 1636 1727 * 1637 * o = p FDeg(p.p);1728 * o = p.GetpFDeg(); 1638 1729 * loop 1639 1730 * { … … 1651 1742 if (length==-1) return 0; 1652 1743 1653 int o = p FDeg(p.p);1744 int o = p.GetpFDeg(); 1654 1745 int op = set[length].GetpFDeg(); 1655 1746 … … 1691 1782 if (length==-1) return 0; 1692 1783 1693 int o = p FDeg(p.p);1784 int o = p.GetpFDeg(); 1694 1785 int op = set[length].GetpFDeg(); 1695 1786 … … 1736 1827 if (length==-1) return 0; 1737 1828 1738 int o = p FDeg(p.p);1829 int o = p.GetpFDeg(); 1739 1830 1740 1831 if (set[length].GetpFDeg() <= o) … … 1770 1861 * int o; 1771 1862 * 1772 * o = p FDeg(p.p)+p.ecart;1863 * o = p.GetpFDeg()+p.ecart; 1773 1864 * loop 1774 1865 * { … … 1787 1878 if (length==-1) return 0; 1788 1879 1789 int o = p FDeg(p.p) + p.ecart;1880 int o = p.GetpFDeg() + p.ecart; 1790 1881 int op = set[length].GetpFDeg()+set[length].ecart; 1791 1882 … … 1829 1920 * int o; 1830 1921 * 1831 * o = p FDeg(p.p)+p.ecart;1922 * o = p.GetpFDeg()+p.ecart; 1832 1923 * loop 1833 1924 * { … … 1847 1938 if (length==-1) return 0; 1848 1939 1849 int o = p FDeg(p.p) + p.ecart;1940 int o = p.GetpFDeg() + p.ecart; 1850 1941 int op = set[length].GetpFDeg()+set[length].ecart; 1851 1942 … … 1893 1984 int cc = (-1+2*currRing->order[0]==ringorder_c); 1894 1985 /* cc==1 for (c,..), cc==-1 for (C,..) */ 1895 int o = p FDeg(p.p) + p.ecart;1986 int o = p.GetpFDeg() + p.ecart; 1896 1987 int c = pGetComp(p.p)*cc; 1897 1988 … … 1957 2048 1958 2049 int o = p.ecart; 1959 int op=p FDeg(p.p);2050 int op=p.GetpFDeg(); 1960 2051 1961 2052 if (set[length].ecart < o) … … 2009 2100 */ 2010 2101 int posInLSpecial (const LSet set, const int length, 2011 const LObject &p,const kStrategy strat)2102 LObject *p,const kStrategy strat) 2012 2103 { 2013 2104 if (length<0) return 0; 2014 2105 2015 int d=p FDeg(p.p);2106 int d=p->GetpFDeg(); 2016 2107 int op=set[length].GetpFDeg(); 2017 2108 2018 2109 if ((op > d) 2019 || ((op == d) && (p .p1!=NULL)&&(set[length].p1==NULL))2020 || (pLmCmp(set[length].p,p .p)== pOrdSgn))2110 || ((op == d) && (p->p1!=NULL)&&(set[length].p1==NULL)) 2111 || (pLmCmp(set[length].p,p->p)== pOrdSgn)) 2021 2112 return length+1; 2022 2113 … … 2030 2121 op=set[an].GetpFDeg(); 2031 2122 if ((op > d) 2032 || ((op == d) && (p .p1!=NULL) && (set[an].p1==NULL))2033 || (pLmCmp(set[an].p,p .p)== pOrdSgn))2123 || ((op == d) && (p->p1!=NULL) && (set[an].p1==NULL)) 2124 || (pLmCmp(set[an].p,p->p)== pOrdSgn)) 2034 2125 return en; 2035 2126 return an; … … 2038 2129 op=set[i].GetpFDeg(); 2039 2130 if ((op>d) 2040 || ((op==d) && (p .p1!=NULL) && (set[i].p1==NULL))2041 || (pLmCmp(set[i].p,p .p) == pOrdSgn))2131 || ((op==d) && (p->p1!=NULL) && (set[i].p1==NULL)) 2132 || (pLmCmp(set[i].p,p->p) == pOrdSgn)) 2042 2133 an=i; 2043 2134 else … … 2052 2143 */ 2053 2144 int posInL0 (const LSet set, const int length, 2054 const LObject &p,const kStrategy strat)2145 LObject* p,const kStrategy strat) 2055 2146 { 2056 2147 if (length<0) return 0; 2057 2148 2058 if (pLmCmp(set[length].p,p .p)== pOrdSgn)2149 if (pLmCmp(set[length].p,p->p)== pOrdSgn) 2059 2150 return length+1; 2060 2151 … … 2066 2157 if (an >= en-1) 2067 2158 { 2068 if (pLmCmp(set[an].p,p .p) == pOrdSgn) return en;2159 if (pLmCmp(set[an].p,p->p) == pOrdSgn) return en; 2069 2160 return an; 2070 2161 } 2071 2162 i=(an+en) / 2; 2072 if (pLmCmp(set[i].p,p .p) == pOrdSgn) an=i;2163 if (pLmCmp(set[i].p,p->p) == pOrdSgn) an=i; 2073 2164 else en=i; 2074 2165 /*aend. fuer lazy == in !=- machen */ … … 2083 2174 */ 2084 2175 int posInL11 (const LSet set, const int length, 2085 const LObject &p,const kStrategy strat)2176 LObject* p,const kStrategy strat) 2086 2177 /*{ 2087 2178 * int j=0; 2088 2179 * int o; 2089 2180 * 2090 * o = p FDeg(p.p);2181 * o = p->GetpFDeg(); 2091 2182 * loop 2092 2183 * { 2093 2184 * if (j > length) return j; 2094 2185 * if ((set[j].GetpFDeg() < o)) return j; 2095 * if ((set[j].GetpFDeg() == o) && (pLmCmp(set[j].p,p .p) == -pOrdSgn))2186 * if ((set[j].GetpFDeg() == o) && (pLmCmp(set[j].p,p->p) == -pOrdSgn)) 2096 2187 * { 2097 2188 * return j; … … 2104 2195 if (length<0) return 0; 2105 2196 2106 int o = p FDeg(p.p);2197 int o = p->GetpFDeg(); 2107 2198 int op = set[length].GetpFDeg(); 2108 2199 2109 2200 if ((op > o) 2110 || ((op == o) && (pLmCmp(set[length].p,p .p) != -pOrdSgn)))2201 || ((op == o) && (pLmCmp(set[length].p,p->p) != -pOrdSgn))) 2111 2202 return length+1; 2112 2203 int i; … … 2119 2210 op = set[an].GetpFDeg(); 2120 2211 if ((op > o) 2121 || ((op == o) && (pLmCmp(set[an].p,p .p) != -pOrdSgn)))2212 || ((op == o) && (pLmCmp(set[an].p,p->p) != -pOrdSgn))) 2122 2213 return en; 2123 2214 return an; … … 2126 2217 op = set[i].GetpFDeg(); 2127 2218 if ((op > o) 2128 || ((op == o) && (pLmCmp(set[i].p,p .p) != -pOrdSgn)))2219 || ((op == o) && (pLmCmp(set[i].p,p->p) != -pOrdSgn))) 2129 2220 an=i; 2130 2221 else … … 2139 2230 */ 2140 2231 int posInL110 (const LSet set, const int length, 2141 const LObject &p,const kStrategy strat)2232 LObject* p,const kStrategy strat) 2142 2233 { 2143 2234 if (length<0) return 0; 2144 2235 2145 int o = p FDeg(p.p);2236 int o = p->GetpFDeg(); 2146 2237 int op = set[length].GetpFDeg(); 2147 2238 2148 2239 if ((op > o) 2149 || ((op == o) && (set[length].length >2*p .length))2150 || ((op == o) && (set[length].length <= 2*p .length)2151 && (pLmCmp(set[length].p,p .p) != -pOrdSgn)))2240 || ((op == o) && (set[length].length >2*p->length)) 2241 || ((op == o) && (set[length].length <= 2*p->length) 2242 && (pLmCmp(set[length].p,p->p) != -pOrdSgn))) 2152 2243 return length+1; 2153 2244 int i; … … 2160 2251 op = set[an].GetpFDeg(); 2161 2252 if ((op > o) 2162 || ((op == o) && (set[an].length >2*p .length))2163 || ((op == o) && (set[an].length <=2*p .length)2164 && (pLmCmp(set[an].p,p .p) != -pOrdSgn)))2253 || ((op == o) && (set[an].length >2*p->length)) 2254 || ((op == o) && (set[an].length <=2*p->length) 2255 && (pLmCmp(set[an].p,p->p) != -pOrdSgn))) 2165 2256 return en; 2166 2257 return an; … … 2169 2260 op = set[i].GetpFDeg(); 2170 2261 if ((op > o) 2171 || ((op == o) && (set[i].length > 2*p .length))2172 || ((op == o) && (set[i].length <= 2*p .length)2173 && (pLmCmp(set[i].p,p .p) != -pOrdSgn)))2262 || ((op == o) && (set[i].length > 2*p->length)) 2263 || ((op == o) && (set[i].length <= 2*p->length) 2264 && (pLmCmp(set[i].p,p->p) != -pOrdSgn))) 2174 2265 an=i; 2175 2266 else … … 2185 2276 */ 2186 2277 int posInL13 (const LSet set, const int length, 2187 const LObject &p,const kStrategy strat)2278 LObject* p,const kStrategy strat) 2188 2279 { 2189 2280 if (length<0) return 0; 2190 2281 2191 int o = p FDeg(p.p);2282 int o = p->GetpFDeg(); 2192 2283 2193 2284 if (set[length].GetpFDeg() > o) … … 2220 2311 */ 2221 2312 int posInL15 (const LSet set, const int length, 2222 const LObject &p,const kStrategy strat)2313 LObject* p,const kStrategy strat) 2223 2314 /*{ 2224 2315 * int j=0; 2225 2316 * int o; 2226 2317 * 2227 * o = p .ecart+pFDeg(p.p);2318 * o = p->ecart+p->GetpFDeg(); 2228 2319 * loop 2229 2320 * { … … 2231 2322 * if (set[j].GetpFDeg()+set[j].ecart < o) return j; 2232 2323 * if ((set[j].GetpFDeg()+set[j].ecart == o) 2233 * && (pLmCmp(set[j].p,p .p) == -pOrdSgn))2324 * && (pLmCmp(set[j].p,p->p) == -pOrdSgn)) 2234 2325 * { 2235 2326 * return j; … … 2242 2333 if (length<0) return 0; 2243 2334 2244 int o = p FDeg(p.p) + p.ecart;2335 int o = p->GetpFDeg() + p->ecart; 2245 2336 int op = set[length].GetpFDeg() + set[length].ecart; 2246 2337 2247 2338 if ((op > o) 2248 || ((op == o) && (pLmCmp(set[length].p,p .p) != -pOrdSgn)))2339 || ((op == o) && (pLmCmp(set[length].p,p->p) != -pOrdSgn))) 2249 2340 return length+1; 2250 2341 int i; … … 2257 2348 op = set[an].GetpFDeg() + set[an].ecart; 2258 2349 if ((op > o) 2259 || ((op == o) && (pLmCmp(set[an].p,p .p) != -pOrdSgn)))2350 || ((op == o) && (pLmCmp(set[an].p,p->p) != -pOrdSgn))) 2260 2351 return en; 2261 2352 return an; … … 2264 2355 op = set[i].GetpFDeg() + set[i].ecart; 2265 2356 if ((op > o) 2266 || ((op == o) && (pLmCmp(set[i].p,p .p) != -pOrdSgn)))2357 || ((op == o) && (pLmCmp(set[i].p,p->p) != -pOrdSgn))) 2267 2358 an=i; 2268 2359 else … … 2279 2370 */ 2280 2371 int posInL17 (const LSet set, const int length, 2281 const LObject &p,const kStrategy strat)2372 LObject* p,const kStrategy strat) 2282 2373 { 2283 2374 if (length<0) return 0; 2284 2375 2285 int o = p FDeg(p.p) + p.ecart;2376 int o = p->GetpFDeg() + p->ecart; 2286 2377 2287 2378 if ((set[length].GetpFDeg() + set[length].ecart > o) 2288 2379 || ((set[length].GetpFDeg() + set[length].ecart == o) 2289 && (set[length].ecart > p .ecart))2380 && (set[length].ecart > p->ecart)) 2290 2381 || ((set[length].GetpFDeg() + set[length].ecart == o) 2291 && (set[length].ecart == p .ecart)2292 && (pLmCmp(set[length].p,p .p) != -pOrdSgn)))2382 && (set[length].ecart == p->ecart) 2383 && (pLmCmp(set[length].p,p->p) != -pOrdSgn))) 2293 2384 return length+1; 2294 2385 int i; … … 2301 2392 if ((set[an].GetpFDeg() + set[an].ecart > o) 2302 2393 || ((set[an].GetpFDeg() + set[an].ecart == o) 2303 && (set[an].ecart > p .ecart))2394 && (set[an].ecart > p->ecart)) 2304 2395 || ((set[an].GetpFDeg() + set[an].ecart == o) 2305 && (set[an].ecart == p .ecart)2306 && (pLmCmp(set[an].p,p .p) != -pOrdSgn)))2396 && (set[an].ecart == p->ecart) 2397 && (pLmCmp(set[an].p,p->p) != -pOrdSgn))) 2307 2398 return en; 2308 2399 return an; … … 2311 2402 if ((set[i].GetpFDeg() + set[i].ecart > o) 2312 2403 || ((set[i].GetpFDeg() + set[i].ecart == o) 2313 && (set[i].ecart > p .ecart))2404 && (set[i].ecart > p->ecart)) 2314 2405 || ((set[i].GetpFDeg() +set[i].ecart == o) 2315 && (set[i].ecart == p .ecart)2316 && (pLmCmp(set[i].p,p .p) != -pOrdSgn)))2406 && (set[i].ecart == p->ecart) 2407 && (pLmCmp(set[i].p,p->p) != -pOrdSgn))) 2317 2408 an=i; 2318 2409 else … … 2327 2418 */ 2328 2419 int posInL17_c (const LSet set, const int length, 2329 const LObject &p,const kStrategy strat)2420 LObject* p,const kStrategy strat) 2330 2421 { 2331 2422 if (length<0) return 0; … … 2333 2424 int cc = (-1+2*currRing->order[0]==ringorder_c); 2334 2425 /* cc==1 for (c,..), cc==-1 for (C,..) */ 2335 int c = pGetComp(p .p)*cc;2336 int o = p FDeg(p.p) + p.ecart;2426 int c = pGetComp(p->p)*cc; 2427 int o = p->GetpFDeg() + p->ecart; 2337 2428 2338 2429 if (pGetComp(set[length].p)*cc > c) … … 2342 2433 if ((set[length].GetpFDeg() + set[length].ecart > o) 2343 2434 || ((set[length].GetpFDeg() + set[length].ecart == o) 2344 && (set[length].ecart > p .ecart))2435 && (set[length].ecart > p->ecart)) 2345 2436 || ((set[length].GetpFDeg() + set[length].ecart == o) 2346 && (set[length].ecart == p .ecart)2347 && (pLmCmp(set[length].p,p .p) != -pOrdSgn)))2437 && (set[length].ecart == p->ecart) 2438 && (pLmCmp(set[length].p,p->p) != -pOrdSgn))) 2348 2439 return length+1; 2349 2440 } … … 2361 2452 if ((set[an].GetpFDeg() + set[an].ecart > o) 2362 2453 || ((set[an].GetpFDeg() + set[an].ecart == o) 2363 && (set[an].ecart > p .ecart))2454 && (set[an].ecart > p->ecart)) 2364 2455 || ((set[an].GetpFDeg() + set[an].ecart == o) 2365 && (set[an].ecart == p .ecart)2366 && (pLmCmp(set[an].p,p .p) != -pOrdSgn)))2456 && (set[an].ecart == p->ecart) 2457 && (pLmCmp(set[an].p,p->p) != -pOrdSgn))) 2367 2458 return en; 2368 2459 } … … 2376 2467 if ((set[i].GetpFDeg() + set[i].ecart > o) 2377 2468 || ((set[i].GetpFDeg() + set[i].ecart == o) 2378 && (set[i].ecart > p .ecart))2469 && (set[i].ecart > p->ecart)) 2379 2470 || ((set[i].GetpFDeg() +set[i].ecart == o) 2380 && (set[i].ecart == p .ecart)2381 && (pLmCmp(set[i].p,p .p) != -pOrdSgn)))2471 && (set[i].ecart == p->ecart) 2472 && (pLmCmp(set[i].p,p->p) != -pOrdSgn))) 2382 2473 an=i; 2383 2474 else … … 2388 2479 } 2389 2480 } 2481 2482 /*************************************************************** 2483 * 2484 * Tail reductions 2485 * 2486 ***************************************************************/ 2487 static TObject* 2488 kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T, 2489 long ecart = LONG_MAX) 2490 { 2491 int j = 0; 2492 const unsigned long not_sev = ~L->sev; 2493 const unsigned long* sev = strat->sevS; 2494 poly p; 2495 ring r; 2496 L->GetLm(p, r); 2497 2498 assume(~not_sev == p_GetShortExpVector(p, r)); 2499 2500 if (r == currRing) 2501 { 2502 while (1) 2503 { 2504 if (j > pos) return NULL; 2505 #if defined(PDEBUG) || defined(PDIV_DEBUG) 2506 if (p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) && 2507 (ecart== LONG_MAX || ecart>= strat->ecartS[j])) 2508 break; 2509 #else 2510 if (!(sev[j] & not_sev) && 2511 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && 2512 p_LmDivisibleBy(strat->S[j], p, r)) 2513 break; 2514 2515 #endif 2516 j++; 2517 } 2518 // if called from NF, T objects do not exist: 2519 if (strat->tl < 0) 2520 { 2521 T->Set(strat->S[j], r); 2522 return T; 2523 } 2524 else 2525 { 2526 assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL); 2527 return strat->S_2_T(j); 2528 } 2529 } 2530 else 2531 { 2532 TObject* t; 2533 while (1) 2534 { 2535 if (j > pos) return NULL; 2536 #if defined(PDEBUG) || defined(PDIV_DEBUG) 2537 t = strat->S_2_T(j); 2538 assume(t != NULL && t->t_p != NULL && t->tailRing == r); 2539 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) && 2540 (ecart== LONG_MAX || ecart>= strat->ecartS[j])) 2541 return t; 2542 #else 2543 if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j])) 2544 { 2545 t = strat->S_2_T(j); 2546 assume(t != NULL && t->t_p != NULL && t->tailRing == r); 2547 if (p_LmDivisibleBy(t->t_p, p, r)) return t; 2548 } 2549 #endif 2550 j++; 2551 } 2552 } 2553 } 2554 2555 2556 poly redtail (LObject* L, int pos, kStrategy strat) 2557 { 2558 poly h, hn; 2559 int j; 2560 unsigned long not_sev; 2561 strat->redTailChange=FALSE; 2562 poly p = L->p; 2563 if (strat->noTailReduction || pNext(p) == NULL) 2564 return p; 2565 2566 LObject Ln(strat->tailRing); 2567 TObject* With; 2568 // placeholder in case strat->tl < 0 2569 TObject With_s(strat->tailRing); 2570 h = p; 2571 hn = pNext(h); 2572 long op = pFDeg(hn, strat->tailRing); 2573 long e; 2574 int l; 2575 BOOLEAN save_HE=strat->kHEdgeFound; 2576 strat->kHEdgeFound |= 2577 ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL; 2578 2579 while(hn != NULL) 2580 { 2581 e = pLDeg(hn, &l, strat->tailRing) - op; 2582 while (1) 2583 { 2584 kTest_TS(strat); 2585 Ln.Set(hn, strat->tailRing); 2586 Ln.sev = p_GetShortExpVector(hn, strat->tailRing); 2587 if (strat->kHEdgeFound) 2588 With = kFindDivisibleByInS(strat, pos, &Ln, &With_s); 2589 else 2590 With = kFindDivisibleByInS(strat, pos, &Ln, &With_s, e); 2591 if (With == NULL) break; 2592 strat->redTailChange=TRUE; 2593 if (ksReducePolyTail(L, With, h, strat->kNoether)) 2594 { 2595 // reducing the tail would violate the exp bound 2596 if (kStratChangeTailRing(strat, L)) 2597 { 2598 strat->kHEdgeFound = save_HE; 2599 return redtail(L, pos, strat); 2600 } 2601 else 2602 return NULL; 2603 } 2604 hn = pNext(h); 2605 if (hn == NULL) goto all_done; 2606 op = pFDeg(hn, strat->tailRing); 2607 e = pLDeg(hn, &l) - op; 2608 kTest_TS(strat); 2609 } 2610 h = hn; 2611 hn = pNext(h); 2612 } 2613 2614 all_done: 2615 strat->kHEdgeFound = save_HE; 2616 return p; 2617 } 2618 2619 #define OLD_RED_TAIL 2620 #ifdef OLD_RED_TAIL 2390 2621 /*2 2391 2622 * reduces h using the set S … … 2398 2629 poly redtail (poly p, int pos, kStrategy strat) 2399 2630 { 2400 if ((!strat->noTailReduction) 2401 && (pNext(p)!=NULL)) 2631 if ((!strat->noTailReduction) && (pNext(p)!=NULL)) 2402 2632 { 2403 2633 int j, e, l; … … 2418 2648 { 2419 2649 if (pLmShortDivisibleBy(strat->S[j], strat->sevS[j], hn, not_sev) 2420 && ((e >= strat->ecartS[j]) 2421 || strat->kHEdgeFound) 2422 ) 2650 && 2651 ((e >= strat->ecartS[j]) || strat->kHEdgeFound)) 2423 2652 { 2424 2653 strat->redTailChange=TRUE; … … 2448 2677 return p; 2449 2678 } 2450 2451 /*22452 *compute the normalform of the tail p->next of p2453 *with respect to S2454 */2455 TObject* kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T)2456 {2457 int j = 0;2458 const unsigned long not_sev = ~L->sev;2459 const unsigned long* sev = strat->sevS;2460 poly p;2461 ring r;2462 L->GetLm(p, r);2463 2464 assume(~not_sev == p_GetShortExpVector(p, r));2465 2466 if (r == currRing)2467 {2468 while (1)2469 {2470 if (j > pos) return NULL;2471 #if defined(PDEBUG) || defined(PDIV_DEBUG)2472 if (p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r))2473 break;2474 2679 #else 2475 if (!(sev[j] & not_sev) && 2476 p_LmDivisibleBy(strat->S[j], p, r)) 2477 break; 2478 2680 poly redtail (poly p, int pos, kStrategy strat) 2681 { 2682 LObject L(p, currRing); 2683 return redtail(&L, pos, strat); 2684 } 2479 2685 #endif 2480 j++;2481 }2482 // if called from NF, T objects do not exist:2483 if (strat->tl < 0)2484 {2485 T->Set(strat->S[j], r);2486 return T;2487 }2488 else2489 {2490 assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL);2491 return strat->S_2_T(j);2492 }2493 }2494 else2495 {2496 TObject* t;2497 while (1)2498 {2499 if (j > pos) return NULL;2500 #if defined(PDEBUG) || defined(PDIV_DEBUG)2501 t = strat->S_2_T(j);2502 assume(t != NULL && t->t_p != NULL && t->tailRing == r);2503 if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r))2504 return t;2505 #else2506 if (! (sev[j] & not_sev))2507 {2508 t = strat->S_2_T(j);2509 assume(t != NULL && t->t_p != NULL && t->tailRing == r);2510 if (p_LmDivisibleBy(t->t_p, p, r)) return t;2511 }2512 #endif2513 j++;2514 }2515 }2516 }2517 2686 2518 2687 poly redtailBba (LObject* L, int pos, kStrategy strat) … … 2641 2810 2642 2811 #endif 2812 2643 2813 2644 2814 /*2 … … 2672 2842 { 2673 2843 //pContent(h.p); 2674 pCleardenom(h.p); // also does a pContent2844 h.pCleardenom(); // also does a pContent 2675 2845 } 2676 2846 else 2677 2847 { 2678 pNorm(h.p);2848 h.pNorm(); 2679 2849 } 2680 2850 strat->initEcart(&h); 2681 2851 if (pOrdSgn==-1) 2682 2852 { 2683 deleteHC(&h .p, &h.ecart, &h.length,strat);2853 deleteHC(&h, strat); 2684 2854 } 2685 2855 if (h.p!=NULL) … … 2707 2877 { 2708 2878 //pContent(h.p); 2709 pCleardenom(h.p); // also does a pContent2879 h.pCleardenom(); // also does a pContent 2710 2880 } 2711 2881 else 2712 2882 { 2713 pNorm(h.p);2883 h.pNorm(); 2714 2884 } 2715 2885 strat->initEcart(&h); … … 2717 2887 { 2718 2888 cancelunit(&h); /*- tries to cancel a unit -*/ 2719 deleteHC(&h .p, &h.ecart, &h.length,strat);2889 deleteHC(&h, strat); 2720 2890 } 2721 2891 if (TEST_OPT_DEGBOUND … … 2771 2941 { 2772 2942 //pContent(h.p); 2773 pCleardenom(h.p); // also does a pContent2943 h.pCleardenom(); // also does a pContent 2774 2944 } 2775 2945 else 2776 2946 { 2777 pNorm(h.p);2947 h.pNorm(); 2778 2948 } 2779 2949 strat->initEcart(&h); 2780 2950 if (pOrdSgn==-1) 2781 2951 { 2782 deleteHC(&h .p, &h.ecart, &h.length,strat);2952 deleteHC(&h,strat); 2783 2953 } 2784 2954 if (h.p!=NULL) … … 2806 2976 { 2807 2977 //pContent(h.p); 2808 pCleardenom(h.p); // also does a pContent2978 h.pCleardenom(); // also does a pContent 2809 2979 } 2810 2980 else 2811 2981 { 2812 pNorm(h.p);2982 h.pNorm(); 2813 2983 } 2814 2984 strat->initEcart(&h); … … 2816 2986 { 2817 2987 cancelunit(&h); /*- tries to cancel a unit -*/ 2818 deleteHC(&h .p, &h.ecart, &h.length,strat);2988 deleteHC(&h, strat); 2819 2989 } 2820 2990 if (TEST_OPT_DEGBOUND … … 2829 2999 else 2830 3000 { 2831 pos = strat->posInL(strat->L,strat->Ll, h,strat);3001 pos = strat->posInL(strat->L,strat->Ll,&h,strat); 2832 3002 } 2833 3003 h.sev = pGetShortExpVector(h.p); … … 2875 3045 //{ 2876 3046 // //pContent(h.p); 2877 // pCleardenom(h.p); // also does a pContent3047 // h.pCleardenom(); // also does a pContent 2878 3048 //} 2879 3049 //else 2880 3050 //{ 2881 // pNorm(h.p);3051 // h.pNorm(); 2882 3052 //} 2883 3053 strat->initEcart(&h); 2884 3054 if (pOrdSgn==-1) 2885 3055 { 2886 deleteHC(&h .p, &h.ecart, &h.length,strat);3056 deleteHC(&h,strat); 2887 3057 } 2888 3058 if (h.p!=NULL) … … 2895 3065 } 2896 3066 h.sev = pGetShortExpVector(h.p); 3067 h.SetpFDeg(); 2897 3068 strat->enterS(h,pos,strat, strat->tl+1); 2898 3069 enterT(h, strat); … … 2916 3087 if (pOrdSgn==-1) 2917 3088 { 2918 deleteHC(&h.p, &h.ecart, &h.length,strat);3089 deleteHC(&h,strat); 2919 3090 } 2920 3091 if (TEST_OPT_DEGBOUND … … 2934 3105 strat->enterS(h,pos,strat, strat->tl+1); 2935 3106 h.length = pLength(h.p); 3107 h.SetpFDeg(); 2936 3108 enterT(h,strat); 2937 3109 } … … 2948 3120 if (TEST_OPT_INTSTRATEGY) 2949 3121 { 2950 pCleardenom(h.p);3122 h.pCleardenom(); 2951 3123 } 2952 3124 else 2953 3125 { 2954 pNorm(h.p);3126 h.pNorm(); 2955 3127 } 2956 3128 if(strat->sl>=0) … … 2971 3143 if (TEST_OPT_INTSTRATEGY) 2972 3144 { 2973 pCleardenom(h.p);3145 h.pCleardenom(); 2974 3146 } 2975 3147 else 2976 3148 { 2977 pNorm(h.p); 3149 h.is_normalized = 0; 3150 h.pNorm(); 2978 3151 } 2979 3152 h.sev = pGetShortExpVector(h.p); 3153 h.SetpFDeg(); 2980 3154 pos = posInS(strat->S,strat->sl,h.p); 2981 3155 enterpairsSpecial(h.p,strat->sl,h.ecart,pos,strat,strat->tl+1); … … 2987 3161 { 2988 3162 h.sev = pGetShortExpVector(h.p); 3163 h.SetpFDeg(); 2989 3164 strat->enterS(h,0,strat, strat->tl+1); 2990 3165 enterT(h,strat); … … 3119 3294 int j=0; 3120 3295 int e,l; 3121 poly h1;3122 3296 unsigned long not_sev = ~ pGetShortExpVector(h); 3123 3297 … … 3130 3304 && ((e >= strat->ecartS[j]) || strat->kHEdgeFound)) 3131 3305 { 3132 h1 = ksOldSpolyRedNew(strat->S[j],h,strat->kNoether); 3306 #ifdef KDEBUG 3307 if (TEST_OPT_DEBUG) 3308 PrintS("reduce "); wrp(h); Print(" with S[%d] (",j);wrp(strat->S[j]); 3309 #endif 3310 h = ksOldSpolyRed(strat->S[j],h,strat->kNoether); 3311 #ifdef KDEBUG 3133 3312 if(TEST_OPT_DEBUG) 3134 { 3135 PrintS("reduce "); wrp(h); Print(" with S[%d] (",j);wrp(strat->S[j]); 3136 PrintS(")\nto "); wrp(h1); PrintLn(); 3137 } 3138 pDelete(&h); 3139 if (h1 == NULL) return NULL; 3140 h = h1; 3313 PrintS(")\nto "); wrp(h); PrintLn(); 3314 #endif 3315 // pDelete(&h); 3316 if (h == NULL) return NULL; 3141 3317 e = pLDeg(h,&l)-pFDeg(h); 3142 3318 j = 0; … … 3239 3415 else assume(strat->sevS[i] == pGetShortExpVector(h.p)); 3240 3416 h.sev = strat->sevS[i]; 3417 h.SetpFDeg(); 3241 3418 /*puts the elements of S also to T*/ 3242 3419 enterT(h,strat); … … 3322 3499 cancelunit1(&h,strat->sl,strat); 3323 3500 h.length = pLength(h.p); 3501 h.SetpFDeg(); 3324 3502 /*puts the elements of S also to T*/ 3325 3503 enterT(h,strat); … … 3366 3544 strat->Shdl->m=strat->S; 3367 3545 } 3368 for (i=strat->sl+1; i>=atS+1; i--) 3369 { 3370 strat->S[i] = strat->S[i-1]; 3371 strat->ecartS[i] = strat->ecartS[i-1]; 3372 strat->sevS[i] = strat->sevS[i-1]; 3373 strat->S_2_R[i] = strat->S_2_R[i-1]; 3546 if (atS <= strat->sl) 3547 { 3548 #ifdef ENTER_USE_MEMMOVE 3549 // #if 0 3550 memmove(&(strat->S[atS+1]), &(strat->S[atS]), 3551 (strat->sl - atS + 1)*sizeof(poly)); 3552 memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]), 3553 (strat->sl - atS + 1)*sizeof(int)); 3554 memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]), 3555 (strat->sl - atS + 1)*sizeof(unsigned long)); 3556 memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]), 3557 (strat->sl - atS + 1)*sizeof(int)); 3558 #else 3559 for (i=strat->sl+1; i>=atS+1; i--) 3560 { 3561 strat->S[i] = strat->S[i-1]; 3562 strat->ecartS[i] = strat->ecartS[i-1]; 3563 strat->sevS[i] = strat->sevS[i-1]; 3564 strat->S_2_R[i] = strat->S_2_R[i-1]; 3565 } 3566 #endif 3374 3567 } 3375 3568 if (strat->fromQ!=NULL) … … 3405 3598 assume(strat->tailRing == p.tailRing); 3406 3599 assume(p.pLength == 0 || pLength(p.p) == p.pLength); 3600 assume(p.FDeg == p.pFDeg()); 3601 assume(!p.is_normalized || nIsOne(pGetCoeff(p.p))); 3407 3602 3408 3603 strat->newt = TRUE; … … 3411 3606 if (strat->tl == strat->tmax-1) 3412 3607 enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmax); 3413 for (i=strat->tl+1; i>=atT+1; i--) 3414 { 3415 strat->T[i] = strat->T[i-1]; 3416 strat->sevT[i] = strat->sevT[i-1]; 3417 strat->R[strat->T[i].i_r] = &(strat->T[i]); 3608 if (atT <= strat->tl) 3609 { 3610 #ifdef ENTER_USE_MEMMOVE 3611 memmove(&(strat->T[atT+1]), &(strat->T[atT]), 3612 (strat->tl-atT+1)*sizeof(TObject)); 3613 memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]), 3614 (strat->tl-atT+1)*sizeof(unsigned long)); 3615 #endif 3616 for (i=strat->tl+1; i>=atT+1; i--) 3617 { 3618 #ifndef ENTER_USE_MEMMOVE 3619 strat->T[i] = strat->T[i-1]; 3620 strat->sevT[i] = strat->sevT[i-1]; 3621 #endif 3622 strat->R[strat->T[i].i_r] = &(strat->T[i]); 3623 } 3418 3624 } 3419 3625 … … 3433 3639 strat->T[atT].max = NULL; 3434 3640 3435 strat->T[atT].FDeg = p.pFDeg();3436 3641 strat->tl++; 3437 3642 strat->R[strat->tl] = &(strat->T[atT]); … … 3467 3672 else PrintS("ideal/module is not homogeneous\n"); 3468 3673 } 3674 } 3675 3676 BOOLEAN kPosInLDependsOnLength(int (*pos_in_l) 3677 (const LSet set, const int length, 3678 LObject* L,const kStrategy strat)) 3679 { 3680 if (pos_in_l == posInL110 || 3681 pos_in_l == posInL10) 3682 return TRUE; 3683 3684 return FALSE; 3469 3685 } 3470 3686 … … 3539 3755 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18)) 3540 3756 strat->posInT = posInT1; 3757 strat->posInLDependsOnLength = kPosInLDependsOnLength(strat->posInL); 3541 3758 } 3542 3759 … … 3780 3997 * 3781 3998 ***************************************************************/ 3782 BOOLEAN kCheckSpolyCreation(kStrategy strat, 3783 poly &m1, poly &m2) 3784 { 3785 assume(pNext(strat->P.p) == strat->tail); 3786 assume(strat->P.p1 != NULL && strat->P.p2 != NULL); 3787 assume(strat->P.i_r1 >= 0 && strat->P.i_r1 <= strat->tl); 3788 assume(strat->P.i_r2 >= 0 && strat->P.i_r2 <= strat->tl); 3999 BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2) 4000 { 4001 assume(L->p1 != NULL && L->p2 != NULL); 4002 assume(L->i_r1 >= 0 && L->i_r1 <= strat->tl); 4003 assume(L->i_r2 >= 0 && L->i_r2 <= strat->tl); 3789 4004 assume(strat->tailRing != currRing); 3790 4005 3791 if (! k_GetLeadTerms(strat->P.p1, strat->P.p2, currRing, 3792 m1, m2, strat->tailRing)) 4006 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing)) 3793 4007 return FALSE; 3794 poly p1_max = (strat->R[ strat->P.i_r1])->max;3795 poly p2_max = (strat->R[ strat->P.i_r2])->max;4008 poly p1_max = (strat->R[L->i_r1])->max; 4009 poly p2_max = (strat->R[L->i_r2])->max; 3796 4010 3797 4011 if ((p1_max != NULL && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) || -
Singular/kutil.h
r3d3d16 r5038cd 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: kutil.h,v 1.4 4 2000-11-16 09:54:52obachman Exp $ */6 /* $Id: kutil.h,v 1.45 2000-11-23 17:34:10 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for kStd … … 119 119 120 120 poly lcm; /*- the lcm of p1,p2 -*/ 121 poly last; // pLast(p) during reductions 121 122 kBucket_pt bucket; 122 123 int i_r1, i_r2; … … 134 135 135 136 // spoly related things 137 // preparation for reduction if not spoly 138 KINLINE void PrepareRed(BOOLEAN use_bucket); 136 139 KINLINE void SetLmTail(poly lm, poly new_p, int length, 137 int use_bucket, ring r );140 int use_bucket, ring r, poly last); 138 141 KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether); 139 142 KINLINE void Tail_Mult_nn(number n); 143 // deletes bucket, makes sure that p and t_p exists 140 144 KINLINE poly GetP(omBin lmBin = NULL); 141 KINLINE void CanonicalizeP(); 142 145 // does not delete bucket, just canonicalizes it 146 // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing 147 KINLINE poly CanonicalizeP(); 148 149 // makes a copy of the poly of L 150 KINLINE void Copy(); 151 // gets the poly and makes a copy of it 152 KINLINE poly CopyGetP(); 153 154 KINLINE int GetpLength(); 155 KINLINE long pLDeg(BOOLEAN use_last); 143 156 KINLINE long pLDeg(); 144 KINLINE long SetLength();157 KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE); 145 158 KINLINE long SetDegStuffReturnLDeg(); 159 KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last); 146 160 147 161 KINLINE long MinComp(); … … 176 190 int (*posInT)(const TSet T,const int tl,const LObject &h); 177 191 int (*posInL)(const LSet set, const int length, 178 const LObject &L,const kStrategy strat);192 LObject* L,const kStrategy strat); 179 193 void (*enterS)(LObject h, int pos,kStrategy strat, int atR = -1); 180 194 void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG); 181 195 int (*posInLOld)(const LSet Ls,const int Ll, 182 const LObject &Lo,const kStrategy strat); 196 LObject* Lo,const kStrategy strat); 197 pFDegProc pOrigFDeg; 198 pLDegProc pOrigLDeg; 183 199 pFDegProc pOldFDeg; 184 200 ideal Shdl; … … 204 220 pShallowCopyDeleteProc p_shallow_copy_delete; 205 221 BOOLEAN *pairtest;/*used for enterOnePair*/ 222 // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength) 223 BOOLEAN LDegLast; 224 // if set, then L.length == L.pLength 225 BOOLEAN length_pLength; 226 // if set, then posInL does not depend on L.length 227 BOOLEAN posInLDependsOnLength; 206 228 int cp,c3; 207 229 int sl,mu; … … 246 268 247 269 void deleteHC(poly *p, int *e, int *l, kStrategy strat); 270 void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE); 248 271 void deleteInS (int i,kStrategy strat); 249 272 void cleanT (kStrategy strat); … … 265 288 void reorderS (int* suc,kStrategy strat); 266 289 int posInL0 (const LSet set, const int length, 267 const LObject &L,const kStrategy strat);290 LObject* L,const kStrategy strat); 268 291 int posInL11 (const LSet set, const int length, 269 const LObject &L,const kStrategy strat);292 LObject* L,const kStrategy strat); 270 293 int posInL13 (const LSet set, const int length, 271 const LObject &L,const kStrategy strat);294 LObject* L,const kStrategy strat); 272 295 int posInL15 (const LSet set, const int length, 273 const LObject &L,const kStrategy strat);296 LObject* L,const kStrategy strat); 274 297 int posInL17 (const LSet set, const int length, 275 const LObject &L,const kStrategy strat); 298 LObject* L,const kStrategy strat); 299 int posInL10 (const LSet set, const int length, 300 LObject* L,const kStrategy strat); 276 301 KINLINE poly redtailBba (poly p,int pos,kStrategy strat); 277 302 poly redtailBba (LObject *L, int pos,kStrategy strat); 278 303 poly redtail (poly p,int pos,kStrategy strat); 304 poly redtail (LObject *L,int pos,kStrategy strat); 279 305 void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1); 280 306 void entersets (LObject h); … … 296 322 void cancelunit (LObject* p); 297 323 void HEckeTest (poly pp,kStrategy strat); 298 void redtailS (poly* h,int maxIndex);299 void redtailMora (poly* h,int maxIndex);300 324 void initBuchMoraCrit(kStrategy strat); 301 325 void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat); … … 314 338 // number of first divisor, otherwise 315 339 int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT, 316 const int tl, const LObject* L );340 const int tl, const LObject* L, const int start=0); 317 341 // same with S 318 342 int kFindDivisibleByInS(const polyset &S, const unsigned long* sev, … … 460 484 // exponent bound of strat->tailRing 461 485 // FALSE, otherwise 462 BOOLEAN kCheckSpolyCreation( kStrategy strat, poly &m1, poly &m2);486 BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2); 463 487 // change strat->tailRing and adjust all data in strat, L, and T: 464 488 // new tailRing has larger exponent bound -
Singular/pInline0.h
r3d3d16 r5038cd 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline0.h,v 1. 4 2000-11-08 15:34:59obachman Exp $9 * Version: $Id: pInline0.h,v 1.5 2000-11-23 17:34:11 obachman Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE0_H … … 41 41 } 42 42 43 44 43 // returns minimal column number in the modul element a (or 0) 45 PINLINE0 int p_MinComp(poly p, ring r)44 PINLINE0 long p_MinComp(poly p, ring lmRing, ring tailRing) 46 45 { 47 intresult,i;46 long result,i; 48 47 49 48 if(p==NULL) return 0; 50 result = p_GetComp(p, r);51 while (pNext(p)!=NULL)49 result = p_GetComp(p,lmRing); 50 if (result != 0) 52 51 { 53 pIter(p); 54 i = p_GetComp(p,r); 55 if (i<result) result = i; 52 while (pNext(p)!=NULL) 53 { 54 pIter(p); 55 i = p_GetComp(p,tailRing); 56 if (i<result) result = i; 57 } 56 58 } 57 59 return result; … … 61 63 PINLINE0 long p_MaxComp(poly p, ring lmRing, ring tailRing) 62 64 { 63 intresult,i;65 long result,i; 64 66 65 67 if(p==NULL) return 0; 66 68 result = p_GetComp(p, lmRing); 67 while (pNext(p)!=NULL)69 if (result != 0) 68 70 { 69 pIter(p); 70 i = p_GetComp(p, tailRing); 71 if (i>result) result = i; 71 while (pNext(p)!=NULL) 72 { 73 pIter(p); 74 i = p_GetComp(p, tailRing); 75 if (i>result) result = i; 76 } 72 77 } 73 78 return result; … … 113 118 } 114 119 120 /*2 121 * returns the length of a (numbers of monomials) 122 */ 123 PINLINE0 poly pLast(poly a, int &l) 124 { 125 if (a == NULL) 126 { 127 l = 0; 128 return NULL; 129 } 130 l = 1; 131 while (pNext(a)!=NULL) 132 { 133 pIter(a); 134 l++; 135 } 136 return a; 137 } 138 115 139 #endif // PINLINE_CC 116 140 -
Singular/pInline2.h
r3d3d16 r5038cd 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline2.h,v 1.1 7 2000-11-13 14:50:24 levandovExp $9 * Version: $Id: pInline2.h,v 1.18 2000-11-23 17:34:11 obachman Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE2_H … … 465 465 PINLINE2 poly pp_Mult_mm(poly p, poly m, const ring r) 466 466 { 467 return r->p_Procs->pp_Mult_mm(p, m, NULL, r); 467 poly last; 468 int shorter; 469 return r->p_Procs->pp_Mult_mm(p, m, shorter, NULL, r, last); 468 470 } 469 471 … … 478 480 { 479 481 int shorter; 480 return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r); 482 poly last; 483 return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last); 481 484 } 482 485 PINLINE2 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, … … 484 487 { 485 488 int shorter; 486 poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r); 489 poly last; 490 poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r, last); 487 491 lp = (lp + lq) - shorter; 488 492 return res; … … 538 542 PINLINE2 poly pp_Mult_qq(poly p, poly q, const ring r) 539 543 { 544 poly last; 545 int shorter; 540 546 if (p == NULL || q == NULL) return NULL; 541 547 542 548 if (pNext(p) == NULL) 543 return r->p_Procs->pp_Mult_mm(q, p, NULL, r);549 return r->p_Procs->pp_Mult_mm(q, p, shorter, NULL, r, last); 544 550 545 551 if (pNext(q) == NULL) 546 return r->p_Procs->pp_Mult_mm(p, q, NULL, r);552 return r->p_Procs->pp_Mult_mm(p, q, shorter, NULL, r, last); 547 553 548 554 poly qq = q; … … 560 566 PINLINE2 poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, const ring r) 561 567 { 562 poly res ;568 poly res, last; 563 569 int shorter; 564 570 number n_old = pGetCoeff(m); … … 567 573 pSetCoeff0(m, n_neg); 568 574 569 res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r );575 res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last); 570 576 pSetCoeff0(m, n_old); 571 577 n_Delete(&n_neg, r); -
Singular/p_Minus_mm_Mult_qq__Template.cc
r3d3d16 r5038cd 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: p_Minus_mm_Mult_qq__Template.cc,v 1. 6 2000-11-03 14:50:21 obachman Exp $9 * Version: $Id: p_Minus_mm_Mult_qq__Template.cc,v 1.7 2000-11-23 17:34:11 obachman Exp $ 10 10 *******************************************************************/ 11 11 … … 18 18 * 19 19 ***************************************************************/ 20 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int& Shorter, const poly spNoether, const ring r )20 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int& Shorter, const poly spNoether, const ring r, poly &last) 21 21 { 22 22 p_Test(p, r); … … 105 105 a = pNext(a) = p;// append p to result and advance p 106 106 pIter(p); 107 if (p == NULL) goto Finish; ;107 if (p == NULL) goto Finish; 108 108 goto CmpTop; 109 109 … … 111 111 Finish: // q or p is NULL: Clean-up time 112 112 if (q == NULL) // append rest of p to result 113 { 113 114 pNext(a) = p; 115 if (p == NULL) last = a; 116 } 114 117 else // append (- m*q) to result 115 118 { 116 119 pSetCoeff0(m, tneg); 117 pNext(a) = r->p_Procs->pp_Mult_mm(q, m, spNoether, r); 120 last = a; 121 pNext(a) = r->p_Procs->pp_Mult_mm(q, m, shorter, spNoether, r, last); 118 122 pSetCoeff0(m, tm); 119 123 } -
Singular/p_Mult_q.cc
r3d3d16 r5038cd 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: p_Mult_q.cc,v 1. 5 2000-09-18 09:19:26obachman Exp $9 * Version: $Id: p_Mult_q.cc,v 1.6 2000-11-23 17:34:11 obachman Exp $ 10 10 *******************************************************************/ 11 11 #include "mod2.h" … … 95 95 } 96 96 97 #if 098 poly _p_Mult_q(poly p, poly q, const int copy, const ring r)99 {100 pAssume (p != NULL && pNext(p) != NULL && q != NULL && pNext(q) != NULL);101 102 // to minimize the number of polynomial comparisons103 // we reverse p and should arrange p and q such that104 // pLast(p)*pHead(q) > pHead(p)*pLast(q)105 // as a first approximation, we just compare the head terms106 #if 0107 if (p_LmCmp(p, q, r) == -1)108 {109 poly tmp = q;110 q = p;111 p = tmp;112 }113 p = r->p_Procs->p_ReverseNeg(p, r);114 #endif115 116 poly pp = p;117 int shorter;118 p_Minus_mm_Mult_qq_Proc_Ptr p_minus_mm_mult_qq119 = r->p_Procs->p_Minus_mm_Mult_qq;120 poly pr = NULL;121 122 while (pp != NULL)123 {124 pr = p_minus_mm_mult_qq(pr, pp, q, shorter, NULL, r);125 pIter(pp);126 }127 128 if (copy)129 {130 r->p_Procs->p_ReverseNeg(p, r);131 }132 else133 {134 r->p_Procs->p_Delete(&q, r);135 r->p_Procs->p_Delete(&p, r);136 }137 return pr;138 }139 140 141 142 #endif -
Singular/p_Procs.h
r3d3d16 r5038cd 8 8 * Author: obachman (Olaf Bachmann) 9 9 * Created: 8/00 10 * Version: $Id: p_Procs.h,v 1. 7 2000-11-03 14:50:22 obachman Exp $10 * Version: $Id: p_Procs.h,v 1.8 2000-11-23 17:34:12 obachman Exp $ 11 11 *******************************************************************/ 12 12 #ifndef P_PROCS_H … … 22 22 typedef poly (*p_Mult_mm_Proc_Ptr)(poly p, poly m, const ring r); 23 23 typedef poly (*pp_Mult_mm_Proc_Ptr)(poly p, poly m, 24 poly spNoether, const ring r); 24 int &shorter, poly spNoether, 25 const ring r, 26 poly &last); 25 27 typedef poly (*p_Add_q_Proc_Ptr)(poly p, poly q, int & shorter, const ring r); 26 28 typedef poly (*p_Minus_mm_Mult_qq_Proc_Ptr)(poly p, poly m, poly q, 27 28 const ring r);29 int &shorter, poly spNoether, 30 const ring r, poly &last); 29 31 typedef poly (*p_Neg_Proc_Ptr)(poly p, const ring r); 30 32 typedef poly (*pp_Mult_Coeff_mm_DivSelect_Proc_Ptr)(poly p, const poly m, const ring r); -
Singular/p_polys.cc
r3d3d16 r5038cd 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: p_polys.cc,v 1. 9 2000-11-14 16:04:59obachman Exp $9 * Version: $Id: p_polys.cc,v 1.10 2000-11-23 17:34:12 obachman Exp $ 10 10 *******************************************************************/ 11 11 … … 169 169 * the ordering is compatible with degree, use a->order 170 170 */ 171 longpDeg(poly a, ring r)171 inline long _pDeg(poly a, ring r) 172 172 { 173 173 p_LmCheckPolyRing(a, r); 174 174 assume(p_GetOrder(a, r) == pWTotaldegree(a, r)); 175 175 return p_GetOrder(a, r); 176 } 177 178 long pDeg(poly a, ring r) 179 { 180 return _pDeg(a, r); 176 181 } 177 182 … … 182 187 * the ordering is not compatible with degree so do not use p->Order 183 188 */ 184 longpTotaldegree(poly p, ring r)189 inline long _pTotaldegree(poly p, ring r) 185 190 { 186 191 p_LmCheckPolyRing(p, r); 187 192 return (long) p_ExpVectorQuerSum(p, r); 193 } 194 long pTotaldegree(poly p, ring r) 195 { 196 return (long) _pTotaldegree(p, r); 188 197 } 189 198 … … 295 304 int ll=1; 296 305 297 while ((pNext(p)!=NULL) && (p_GetComp(pNext(p), r)==k)) 298 { 299 pIter(p); 300 ll++; 306 if (k > 0) 307 { 308 while ((pNext(p)!=NULL) && (p_GetComp(pNext(p), r)==k)) 309 { 310 pIter(p); 311 ll++; 312 } 313 } 314 else 315 { 316 while (pNext(p)!=NULL) 317 { 318 pIter(p); 319 ll++; 320 } 301 321 } 302 322 *l=ll; … … 354 374 int ll=1; 355 375 356 while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k)) 357 { 358 ll++; 376 if (k != 0) 377 { 378 while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k)) 379 { 380 ll++; 381 } 382 } 383 else 384 { 385 while ((p=pNext(p)) !=NULL) 386 { 387 ll++; 388 } 359 389 } 360 390 *l=ll; … … 374 404 long t,max; 375 405 376 max=pFDeg(p); 377 while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k)) 378 { 379 t=pFDeg(p, r); 380 if (t>max) max=t; 381 ll++; 406 max=pFDeg(p, r); 407 if (k > 0) 408 { 409 while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k)) 410 { 411 t=pFDeg(p, r); 412 if (t>max) max=t; 413 ll++; 414 } 415 } 416 else 417 { 418 while ((p=pNext(p))!=NULL) 419 { 420 t=pFDeg(p, r); 421 if (t>max) max=t; 422 ll++; 423 } 382 424 } 383 425 *l=ll; … … 398 440 399 441 max=pFDeg(p, r); 400 while ((p=pNext(p))!=NULL) 401 { 402 if (! rIsSyzIndexRing(r) || 403 (p_GetComp(p, r)<=rGetCurrSyzLimit(r))) 404 { 405 if ((t=pFDeg(p, r))>max) max=t; 406 ll++; 407 } 408 else break; 442 if (rIsSyzIndexRing(r)) 443 { 444 long limit = rGetCurrSyzLimit(r); 445 while ((p=pNext(p))!=NULL) 446 { 447 if (p_GetComp(p, r)<=limit) 448 { 449 if ((t=pFDeg(p, r))>max) max=t; 450 ll++; 451 } 452 else break; 453 } 454 } 455 else 456 { 457 while ((p=pNext(p))!=NULL) 458 { 459 if ((t=pFDeg(p, r))>max) max=t; 460 ll++; 461 } 462 } 463 *l=ll; 464 return max; 465 } 466 467 // like pLDeg1, only pFDeg == Deg 468 long pLDeg1_Deg(poly p,int *l, ring r) 469 { 470 p_CheckPolyRing(p, r); 471 Exponent_t k= p_GetComp(p, r); 472 int ll=1; 473 long t,max; 474 475 max=_pDeg(p, r); 476 if (k > 0) 477 { 478 while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k)) 479 { 480 t=_pDeg(p, r); 481 if (t>max) max=t; 482 ll++; 483 } 484 } 485 else 486 { 487 while ((p=pNext(p))!=NULL) 488 { 489 t=_pDeg(p, r); 490 if (t>max) max=t; 491 ll++; 492 } 493 } 494 *l=ll; 495 return max; 496 } 497 498 long pLDeg1c_Deg(poly p,int *l, ring r) 499 { 500 p_CheckPolyRing(p, r); 501 int ll=1; 502 long t,max; 503 504 max=_pDeg(p, r); 505 if (rIsSyzIndexRing(r)) 506 { 507 long limit = rGetCurrSyzLimit(r); 508 while ((p=pNext(p))!=NULL) 509 { 510 if (p_GetComp(p, r)<=limit) 511 { 512 if ((t=_pDeg(p, r))>max) max=t; 513 ll++; 514 } 515 else break; 516 } 517 } 518 else 519 { 520 while ((p=pNext(p))!=NULL) 521 { 522 if ((t=_pDeg(p, r))>max) max=t; 523 ll++; 524 } 525 } 526 *l=ll; 527 return max; 528 } 529 530 // like pLDeg1, only pFDeg == pTotoalDegree 531 long pLDeg1_Totaldegree(poly p,int *l, ring r) 532 { 533 p_CheckPolyRing(p, r); 534 Exponent_t k= p_GetComp(p, r); 535 int ll=1; 536 long t,max; 537 538 max=_pTotaldegree(p, r); 539 if (k > 0) 540 { 541 while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k)) 542 { 543 t=_pTotaldegree(p, r); 544 if (t>max) max=t; 545 ll++; 546 } 547 } 548 else 549 { 550 while ((p=pNext(p))!=NULL) 551 { 552 t=_pTotaldegree(p, r); 553 if (t>max) max=t; 554 ll++; 555 } 556 } 557 *l=ll; 558 return max; 559 } 560 561 long pLDeg1c_Totaldegree(poly p,int *l, ring r) 562 { 563 p_CheckPolyRing(p, r); 564 int ll=1; 565 long t,max; 566 567 max=_pTotaldegree(p, r); 568 if (rIsSyzIndexRing(r)) 569 { 570 long limit = rGetCurrSyzLimit(r); 571 while ((p=pNext(p))!=NULL) 572 { 573 if (p_GetComp(p, r)<=limit) 574 { 575 if ((t=_pTotaldegree(p, r))>max) max=t; 576 ll++; 577 } 578 else break; 579 } 580 } 581 else 582 { 583 while ((p=pNext(p))!=NULL) 584 { 585 if ((t=_pTotaldegree(p, r))>max) max=t; 586 ll++; 587 } 409 588 } 410 589 *l=ll; … … 533 712 return TRUE; 534 713 } 714 715 /*2 716 *test if a monomial /head term is a pure power 717 */ 718 int p_IsPurePower(const poly p, const ring r) 719 { 720 int i,k=0; 721 722 for (i=r->N;i;i--) 723 { 724 if (p_GetExp(p,i, r)!=0) 725 { 726 if(k!=0) return 0; 727 k=i; 728 } 729 } 730 return k; 731 } -
Singular/p_polys.h
r3d3d16 r5038cd 8 8 * Author: obachman (Olaf Bachmann) 9 9 * Created: 9/00 10 * Version: $Id: p_polys.h,v 1.1 4 2000-11-14 16:05:00obachman Exp $10 * Version: $Id: p_polys.h,v 1.15 2000-11-23 17:34:12 obachman Exp $ 11 11 *******************************************************************/ 12 12 #ifndef P_POLYS_H … … 214 214 // return TRUE if all monoms have the same component 215 215 BOOLEAN p_OneComp(poly p, ring r); 216 int p_IsPurePower(const poly p, const ring r); 217 216 218 /*************************************************************** 217 219 * … … 299 301 PINLINE0 long p_MaxComp(poly p, ring lmRing, ring tailRing); 300 302 inline long p_MaxComp(poly p,ring lmRing) {return p_MaxComp(p,lmRing,lmRing);} 301 PINLINE0 int p_MinComp(poly p, ring r); 303 PINLINE0 long p_MinComp(poly p, ring lmRing, ring tailRing); 304 inline long p_MinComp(poly p,ring lmRing) {return p_MinComp(p,lmRing,lmRing);} 302 305 303 306 /*************************************************************** … … 307 310 ***************************************************************/ 308 311 PINLINE0 int pLength(poly a); 312 PINLINE0 poly pLast(poly a, int &length); 313 inline poly pLast(poly a) { int l; return pLast(a, l);} 309 314 PINLINE0 poly pReverse(poly p); 310 315 … … 346 351 long pLDeg1(poly p,int *l, ring r); 347 352 long pLDeg1c(poly p,int *l, ring r); 353 long pLDeg1_Deg(poly p,int *l, ring r); 354 long pLDeg1c_Deg(poly p,int *l, ring r); 355 long pLDeg1_Totaldegree(poly p,int *l, ring r); 356 long pLDeg1c_Totaldegree(poly p,int *l, ring r); 348 357 349 358 /*************************************************************** -
Singular/polys.h
r3d3d16 r5038cd 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys.h,v 1.4 5 2000-11-14 16:05:00obachman Exp $ */6 /* $Id: polys.h,v 1.46 2000-11-23 17:34:12 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate polynomials of the … … 237 237 BOOLEAN pIsConstant(const poly p); 238 238 BOOLEAN pIsConstantPoly(poly p); 239 int pIsPurePower(const poly p); 239 #define pIsPurePower(p) p_IsPurePower(p, currRing) 240 240 #define pIsVector(p) (pGetComp(p)!=0) 241 241 BOOLEAN pHasNotCF(poly p1, poly p2); /*has no common factor ?*/ … … 270 270 long pLDeg1(poly p,int *l, ring r = currRing); 271 271 long pLDeg1c(poly p,int *l, ring r = currRing); 272 long pLDeg1_Deg(poly p,int *l, ring r = currRing); 273 long pLDeg1c_Deg(poly p,int *l, ring r = currRing); 274 long pLDeg1_Totaldegree(poly p,int *l, ring r = currRing); 275 long pLDeg1c_Totaldegree(poly p,int *l, ring r = currRing); 272 276 273 277 /*-------------pComp for syzygies:-------------------*/ -
Singular/polys1.cc
r3d3d16 r5038cd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys1.cc,v 1.5 3 2000-11-14 16:05:00obachman Exp $ */4 /* $Id: polys1.cc,v 1.54 2000-11-23 17:34:13 obachman Exp $ */ 5 5 6 6 /* … … 62 62 } 63 63 64 /*265 *test if a monomial /head term is a pure power66 */67 int pIsPurePower(const poly p)68 {69 int i,k=0;70 71 for (i=pVariables;i;i--)72 {73 if (pGetExp(p,i)!=0)74 {75 if(k!=0) return 0;76 k=i;77 }78 }79 return k;80 }81 64 82 65 -
Singular/pp_Mult_mm__Template.cc
r3d3d16 r5038cd 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pp_Mult_mm__Template.cc,v 1. 6 2000-10-30 16:54:56obachman Exp $9 * Version: $Id: pp_Mult_mm__Template.cc,v 1.7 2000-11-23 17:34:13 obachman Exp $ 10 10 *******************************************************************/ 11 11 … … 18 18 * 19 19 ***************************************************************/ 20 poly pp_Mult_mm(poly p, const poly m, const poly spNoether, const ring ri)20 poly pp_Mult_mm(poly p, const poly m, int& Shorter, const poly spNoether, const ring ri, poly &last) 21 21 { 22 22 p_Test(p, ri); 23 23 p_LmTest(m, ri); 24 if (p == NULL) return NULL; 24 if (p == NULL) 25 { 26 last = NULL; 27 return NULL; 28 } 25 29 spolyrec rp; 26 30 poly q = &rp, r; … … 45 49 } 46 50 while (p != NULL); 51 last = q; 47 52 } 48 53 else … … 56 61 if (p_LmCmp(r, spNoether, ri) == -1) 57 62 { 63 Shorter += pLength(p); 58 64 p_FreeBinAddr(r, ri); 59 65 break; … … 63 69 pIter(p); 64 70 } 71 if (q != &rp) last = q; 65 72 } 66 73 pNext(q) = NULL; 67 74 68 75 p_Test(pNext(&rp), ri); 69 76 return pNext(&rp); -
Singular/ring.cc
r3d3d16 r5038cd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.14 4 2000-11-23 14:06:50 SingularExp $ */4 /* $Id: ring.cc,v 1.145 2000-11-23 17:34:13 obachman Exp $ */ 5 5 6 6 /* … … 2631 2631 { 2632 2632 // Hmm... sometimes (e.g., from maGetPreimage) new variables 2633 // are intorduced, but their name isnever set2634 // hence, do the following awkward trick2633 // are intorduced, but their names are never set 2634 // hence, we do the following awkward trick 2635 2635 int N = omSizeWOfAddr(r->names); 2636 2636 if (r->N < N) N = r->N; … … 2707 2707 r->ComponentOrder = 1; 2708 2708 r->pFDeg = pTotaldegree; 2709 r->pLDeg = (r->OrdSgn == 1 ? r->pLDeg =pLDegb : pLDeg0);2709 r->pLDeg = (r->OrdSgn == 1 ? pLDegb : pLDeg0); 2710 2710 2711 2711 /*======== ordering type is (_,c) =========================*/ … … 2743 2743 && (order[2]==0)) 2744 2744 { 2745 /* pLDeg = ldeg0; is standard*/2746 2745 if ((order[0]==ringorder_C)||(order[0]==ringorder_S)|| 2747 2746 order[0]==ringorder_s)
Note: See TracChangeset
for help on using the changeset viewer.