Changeset e7d1fd in git
- Timestamp:
- Sep 27, 1999, 3:35:53 PM (25 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- 88ff58c3e09f5825f063912877992d787c2b0525
- Parents:
- e72e836bdc4f7b2643f6d02eef8fb1bd7e012d0c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/kbuckets.cc
re72e836 re7d1fd 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kbuckets.cc,v 1. 2 1999-05-26 16:20:17obachman Exp $ */4 /* $Id: kbuckets.cc,v 1.3 1999-09-27 13:35:53 obachman Exp $ */ 5 5 6 6 #include "mod2.h" … … 25 25 { 26 26 unsigned int i = 0; 27 27 28 28 if (l == 0) return 0; 29 29 l--; … … 38 38 } 39 39 40 40 41 41 42 42 #if defined(PDEBUG) && ! defined(HAVE_PSEUDO_BUCKETS) … … 50 50 if (bucket->buckets_length[i] != pLength(bucket->buckets[i])) 51 51 { 52 Warn("Bucket %d lengths difference should:%d has:%d in %s:%d \n",52 Warn("Bucket %d lengths difference should:%d has:%d in %s:%d", 53 53 i, bucket->buckets_length[i], pLength(bucket->buckets[i]), file, line); 54 54 assume(0); … … 56 56 else if (i > 0 && (int) pLogLength(bucket->buckets_length[i]) > i) 57 57 { 58 Warn("Bucket %d too long %d in %s:%d \n",58 Warn("Bucket %d too long %d in %s:%d", 59 59 i, bucket->buckets_length[i], file, line); 60 60 assume(0); … … 62 62 else if (i==0 && bucket->buckets_length[0] > 1) 63 63 { 64 Warn("Bucket 0 too long \n");64 Warn("Bucket 0 too long"); 65 65 } 66 66 } … … 79 79 && pComp0(lm, bucket->buckets[i]) != 1) 80 80 { 81 Warn("Bucket %d larger than lm in %s:%d \n", i, file, line);81 Warn("Bucket %d larger than lm in %s:%d", i, file, line); 82 82 assume(0); 83 83 } 84 84 } 85 85 86 86 for (; i<=MAX_BUCKET; i++) 87 87 { 88 88 if (bucket->buckets[i] != NULL || bucket->buckets_length[i] != 0) 89 89 { 90 Warn("Bucket %d not zero in %s:%d \n", i, file, line);90 Warn("Bucket %d not zero in %s:%d", i, file, line); 91 91 assume(0); 92 92 } … … 126 126 inline void kBucketAdjustBucketsUsed(kBucket_pt bucket) 127 127 { 128 while ( bucket->buckets_used > 0 && 128 while ( bucket->buckets_used > 0 && 129 129 bucket->buckets[bucket->buckets_used] == NULL) 130 130 (bucket->buckets_used)--; … … 152 152 } 153 153 } 154 155 154 155 156 156 static BOOLEAN kBucketIsCleared(kBucket_pt bucket) 157 157 { … … 171 171 { 172 172 int i; 173 173 174 174 assume(bucket != NULL); 175 175 assume(length <= 0 || length == pLength(lm)); … … 207 207 BOOLEAN zero = FALSE; 208 208 assume(bucket->buckets[0] == NULL && bucket->buckets_length[0] == 0); 209 209 210 210 do 211 211 { … … 217 217 int comp = (j == 0 ? 1 : 218 218 pComp0(bucket->buckets[i], bucket->buckets[j])); 219 220 if (comp > 0) 219 220 if (comp > 0) 221 221 { 222 222 if (j > 0 && … … 249 249 while (j < 0); 250 250 251 if (j == 0) 251 if (j == 0) 252 252 { 253 253 return; … … 290 290 bucket->buckets_length[1] = 0; 291 291 292 292 293 293 for (i=2; i<=bucket->buckets_used; i++) 294 294 { … … 347 347 { 348 348 int i; 349 349 350 350 assume(bucket != NULL); 351 351 assume(length <= 0 || length == pLength(lm)); … … 354 354 if (length <= 0) bucket->l = pLength(lm); 355 355 else bucket->l = length; 356 356 357 357 bucket->heap = heap; 358 358 assume(pprocs != NULL); … … 377 377 void kBucketClear(kBucket_pt bucket, poly *p, int *length) 378 378 { 379 assume(pLength(bucket->p) == bucket->l); 379 assume(pLength(bucket->p) == bucket->l); 380 380 *p = bucket->p; 381 381 *length = bucket->l; … … 406 406 } 407 407 } 408 408 409 409 #else 410 410 411 #define kBucketCompactifyIfNecessary(b) 411 #define kBucketCompactifyIfNecessary(b) 412 412 413 413 #endif … … 421 421 #ifndef HAVE_PSEUDO_BUCKETS 422 422 int i; 423 423 424 424 for (i=0; i<= bucket->buckets_used; i++) 425 if (bucket->buckets[i] != NULL) 425 if (bucket->buckets[i] != NULL) 426 426 bucket->pprocs->n_Mult_p(n, bucket->buckets[i]); 427 427 #else 428 428 bucket->pprocs->n_Mult_p(n, bucket->p); 429 #endif 429 #endif 430 430 } 431 431 … … 435 435 /// Does not destroy p and m 436 436 /// assume (*l <= 0 || pLength(p) == *l) 437 void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, 437 void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, 438 438 poly spNoether) 439 439 { … … 441 441 int i, l1; 442 442 poly p1 = p; 443 444 if (*l <= 0) 443 444 if (*l <= 0) 445 445 { 446 446 l1 = pLength(p1); … … 449 449 else 450 450 l1 = *l; 451 451 452 452 if (m == NULL || p == NULL) return; 453 453 454 454 #ifndef HAVE_PSEUDO_BUCKETS 455 455 kBucketMergeLm(bucket); … … 461 461 (&(bucket->buckets[i]), &(bucket->buckets_length[i]), 462 462 m, 463 p1, l1, 463 p1, l1, 464 464 spNoether, 465 465 bucket->pprocs->p_Mult_m, … … 473 473 { 474 474 bucket->pprocs->p_Add_q(&p1, &l1, 475 &(bucket->buckets[i]), 475 &(bucket->buckets[i]), 476 476 &(bucket->buckets_length[i]), 477 477 bucket->heap); … … 488 488 bucket->buckets[i] = p1; 489 489 bucket->buckets_length[i]=l1; 490 if (i >= bucket->buckets_used) 490 if (i >= bucket->buckets_used) 491 491 bucket->buckets_used = i; 492 492 else … … 494 494 #else // HAVE_PSEUDO_BUCKETS 495 495 bucket->pprocs->p_Minus_m_Mult_q(&(bucket->p), &(bucket->l), 496 m, p, l1, spNoether, 496 m, p, l1, spNoether, 497 497 bucket->pprocs->p_Mult_m, 498 498 bucket->heap); 499 #endif 499 #endif 500 500 kbTests(bucket); 501 501 } 502 502 503 503 ///////////////////////////////////////////////////////////////////////////// 504 // 504 // 505 505 // Extract all monomials from bucket with component comp 506 506 // Return as a polynomial *p with length *l 507 // In other words, afterwards 507 // In other words, afterwards 508 508 // Bpoly == Bpoly - (poly consisting of all monomials with component comp) 509 509 // and components of monomials of *p are all 0 510 // 511 void kBucketTakeOutComp(kBucket_pt bucket, 512 Exponent_t comp, 510 // 511 void kBucketTakeOutComp(kBucket_pt bucket, 512 Exponent_t comp, 513 513 poly *r_p, int *l) 514 514 { … … 536 536 pTakeOutComp(&(bucket->p), comp, &p, &lp); 537 537 (bucket->l) -= lp; 538 #endif 538 #endif 539 539 *r_p = p; 540 540 *l = lp; 541 541 542 542 kbTests(bucket); 543 543 } 544 544 545 void kBucketDecrOrdTakeOutComp(kBucket_pt bucket, 546 Exponent_t comp, Order_t order, 545 void kBucketDecrOrdTakeOutComp(kBucket_pt bucket, 546 Exponent_t comp, Order_t order, 547 547 poly *r_p, int *l) 548 548 { 549 549 poly p = NULL, q; 550 550 int i, lp = 0, lq; 551 551 552 552 #ifndef HAVE_PSEUDO_BUCKETS 553 553 kBucketMergeLm(bucket); … … 568 568 pDecrOrdTakeOutComp(&(bucket->p), comp, order, &p, &lp); 569 569 (bucket->l) -= lp; 570 #endif 570 #endif 571 571 572 572 *r_p = p; 573 573 *l = lp; 574 574 } 575 575 576 576 ///////////////////////////////////////////////////////////////////////////// 577 577 // Reduction of Bpoly with a given poly … … 580 580 extern int spCheckCoeff(number *a, number *b); 581 581 582 number kBucketPolyRed(kBucket_pt bucket, 583 poly p1, int l1, 582 number kBucketPolyRed(kBucket_pt bucket, 583 poly p1, int l1, 584 584 poly spNoether) 585 585 { 586 assume(p1 != NULL && 586 assume(p1 != NULL && 587 587 pDivisibleBy(p1, kBucketGetLm(bucket))); 588 588 assume(pLength(p1) == (int) l1); … … 591 591 BOOLEAN reset_vec=FALSE; 592 592 number rn; 593 593 594 594 if(a1==NULL) 595 595 { … … 615 615 pSetCompP(a1, pGetComp(lm)); 616 616 reset_vec = TRUE; 617 } 618 617 pSetComp(lm, pGetComp(p1)); 618 pSetm(lm); 619 } 620 619 621 spMonSub(lm,p1); 620 622 l1--; 621 623 622 624 kBucket_Minus_m_Mult_p(bucket, lm, a1, &l1, spNoether); 623 625 624 626 kb_pDelete1(lm, bucket->heap); 625 627 if (reset_vec) spModuleToPoly(a1); … … 654 656 } 655 657 #endif 656 658 657 659 kBucketInit(&(strat->bucket), h->p, h->length, &(strat->pprocs), 658 660 h->heap); 659 661 660 662 lm = kBucketGetLm(&(strat->bucket)); 661 663 662 664 for(;;) 663 665 { … … 666 668 #endif 667 669 j = 0; 668 670 669 671 #ifdef KB_HAVE_SHORT_EVECTORS 670 672 unsigned long ev = ~ pGetShortExpVector(lm); 671 673 #endif 672 674 673 675 if (strat->ak) 674 676 { … … 716 718 if (strat->T[j].length <= 0) 717 719 strat->T[j].length = pLength(strat->T[j].p); 718 719 // Compactify 720 721 // Compactify 720 722 kBucketCompactifyIfNecessary(&(strat->bucket)); 721 723 … … 725 727 nDelete(&up); 726 728 lm = kBucketGetLm(&(strat->bucket)); 727 729 728 730 if (lm == NULL) 729 731 { … … 768 770 #endif 769 771 kTest(strat); 770 772 771 773 if (strat->fromT) 772 774 { … … 781 783 782 784 poly lm = kBucketGetLm(&(strat->bucket)); 783 785 784 786 strat->fromT=FALSE; 785 787 … … 790 792 unsigned long ev = ~ pGetShortExpVector(lm); 791 793 #endif 792 794 793 795 if (strat->ak) 794 796 { … … 808 810 else 809 811 goto Found; 810 #else 812 #else 811 813 if (pDivisibleBy2(strat->T[j].p,lm)) goto Found; 812 814 j++; … … 818 820 #ifdef KDEBUG 819 821 if (TEST_OPT_DEBUG) PrintLn(); 820 #endif 822 #endif 821 823 kBucketClear(&(strat->bucket), &(h->p), &(h->length)); 822 824 if (TEST_OPT_INTSTRATEGY) pCleardenom(h->p);// also does a pContent … … 837 839 } 838 840 839 841 840 842 /* 841 843 * the polynomial to reduce with (up to the moment) is; … … 1026 1028 hp->heap); 1027 1029 } 1028 number up = kBucketPolyRed(&(strat->bucket), strat->S[j], 1029 pLength(strat->S[j]), 1030 number up = kBucketPolyRed(&(strat->bucket), strat->S[j], 1031 pLength(strat->S[j]), 1030 1032 strat->kNoether); 1031 1033 nDelete(&up); … … 1059 1061 length++; 1060 1062 } 1061 1063 1062 1064 1063 1065 Finish:
Note: See TracChangeset
for help on using the changeset viewer.