Changeset 6cbb4a in git
- Timestamp:
- May 31, 2019, 3:32:36 PM (5 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 66b71f6f6f2640e6319a2158fa60b0ee93cf6320
- Parents:
- 177e74793f08f4242754f552ff248df5d6d3a199f514ffb5811f1c5469b7cd01eed8078808bdb26f
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ffsolve.lib
rf514ffb r6cbb4a 481 481 } 482 482 } 483 varinfo = var aibles(univar_part);483 varinfo = variables(univar_part); 484 484 unsolved_vars = varinfo[3]; 485 485 unsolved_var_nums = varinfo[4]; -
factory/cf_factor.cc
rf514ffb r6cbb4a 631 631 #endif 632 632 int ch=getCharacteristic(); 633 if (f.isUnivariate()&& (ch>0)) 634 { 633 if (ch>0) 634 { 635 if (f.isUnivariate()&& (ch>0)) 636 { 635 637 #ifdef HAVE_NTL 636 //USE NTL637 if (ch>2)638 {638 //USE NTL 639 if (ch>2) 640 { 639 641 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400) 640 nmod_poly_t FLINTmipo, leadingCoeff;641 fq_nmod_ctx_t fq_con;642 643 nmod_poly_init (FLINTmipo, getCharacteristic());644 nmod_poly_init (leadingCoeff, getCharacteristic());645 convertFacCF2nmod_poly_t (FLINTmipo, getMipo (alpha));646 647 fq_nmod_ctx_init_modulus (fq_con, FLINTmipo, "Z");648 fq_nmod_poly_t FLINTF;649 convertFacCF2Fq_nmod_poly_t (FLINTF, f, fq_con);650 fq_nmod_poly_factor_t res;651 fq_nmod_poly_factor_init (res, fq_con);652 fq_nmod_poly_factor (res, leadingCoeff, FLINTF, fq_con);653 F= convertFLINTFq_nmod_poly_factor2FacCFFList (res, f.mvar(), alpha, fq_con);654 F.insert (CFFactor (Lc (f), 1));655 656 fq_nmod_poly_factor_clear (res, fq_con);657 fq_nmod_poly_clear (FLINTF, fq_con);658 nmod_poly_clear (FLINTmipo);659 nmod_poly_clear (leadingCoeff);660 fq_nmod_ctx_clear (fq_con);642 nmod_poly_t FLINTmipo, leadingCoeff; 643 fq_nmod_ctx_t fq_con; 644 645 nmod_poly_init (FLINTmipo, getCharacteristic()); 646 nmod_poly_init (leadingCoeff, getCharacteristic()); 647 convertFacCF2nmod_poly_t (FLINTmipo, getMipo (alpha)); 648 649 fq_nmod_ctx_init_modulus (fq_con, FLINTmipo, "Z"); 650 fq_nmod_poly_t FLINTF; 651 convertFacCF2Fq_nmod_poly_t (FLINTF, f, fq_con); 652 fq_nmod_poly_factor_t res; 653 fq_nmod_poly_factor_init (res, fq_con); 654 fq_nmod_poly_factor (res, leadingCoeff, FLINTF, fq_con); 655 F= convertFLINTFq_nmod_poly_factor2FacCFFList (res, f.mvar(), alpha, fq_con); 656 F.insert (CFFactor (Lc (f), 1)); 657 658 fq_nmod_poly_factor_clear (res, fq_con); 659 fq_nmod_poly_clear (FLINTF, fq_con); 660 nmod_poly_clear (FLINTmipo); 661 nmod_poly_clear (leadingCoeff); 662 fq_nmod_ctx_clear (fq_con); 661 663 #else 662 // First all cases with characteristic !=2663 // set remainder664 if (fac_NTL_char != getCharacteristic())665 {666 fac_NTL_char = getCharacteristic();667 zz_p::init(getCharacteristic());668 }669 670 // set minimal polynomial in NTL671 zz_pX minPo=convertFacCF2NTLzzpX(getMipo(alpha));672 zz_pE::init (minPo);673 674 // convert to NTL675 zz_pEX f1=convertFacCF2NTLzz_pEX(f,minPo);676 zz_pE leadcoeff= LeadCoeff(f1);677 678 //make monic679 f1=f1 / leadcoeff;680 681 // factorize using NTL682 vec_pair_zz_pEX_long factors;683 CanZass(factors,f1);684 685 // return converted result686 F=convertNTLvec_pair_zzpEX_long2FacCFFList(factors,leadcoeff,f.mvar(),alpha);687 #endif 688 }689 else if (/*getCharacteristic()*/ch==2)690 {691 // special case : GF2692 693 // remainder is two ==> nothing to do694 695 // set minimal polynomial in NTL using the optimized conversion routines for characteristic 2696 GF2X minPo=convertFacCF2NTLGF2X(getMipo(alpha,f.mvar()));697 GF2E::init (minPo);698 699 // convert to NTL again using the faster conversion routines700 GF2EX f1;701 if (isPurePoly(f))702 {703 GF2X f_tmp=convertFacCF2NTLGF2X(f);704 f1=to_GF2EX(f_tmp);705 }706 else707 f1=convertFacCF2NTLGF2EX(f,minPo);708 709 // make monic (in Z/2(a))710 GF2E f1_coef=LeadCoeff(f1);711 MakeMonic(f1);712 713 // factorize using NTL714 vec_pair_GF2EX_long factors;715 CanZass(factors,f1);716 717 // return converted result718 F=convertNTLvec_pair_GF2EX_long2FacCFFList(factors,f1_coef,f.mvar(),alpha);719 }664 // First all cases with characteristic !=2 665 // set remainder 666 if (fac_NTL_char != getCharacteristic()) 667 { 668 fac_NTL_char = getCharacteristic(); 669 zz_p::init(getCharacteristic()); 670 } 671 672 // set minimal polynomial in NTL 673 zz_pX minPo=convertFacCF2NTLzzpX(getMipo(alpha)); 674 zz_pE::init (minPo); 675 676 // convert to NTL 677 zz_pEX f1=convertFacCF2NTLzz_pEX(f,minPo); 678 zz_pE leadcoeff= LeadCoeff(f1); 679 680 //make monic 681 f1=f1 / leadcoeff; 682 683 // factorize using NTL 684 vec_pair_zz_pEX_long factors; 685 CanZass(factors,f1); 686 687 // return converted result 688 F=convertNTLvec_pair_zzpEX_long2FacCFFList(factors,leadcoeff,f.mvar(),alpha); 689 #endif 690 } 691 else if (/*getCharacteristic()*/ch==2) 692 { 693 // special case : GF2 694 695 // remainder is two ==> nothing to do 696 697 // set minimal polynomial in NTL using the optimized conversion routines for characteristic 2 698 GF2X minPo=convertFacCF2NTLGF2X(getMipo(alpha,f.mvar())); 699 GF2E::init (minPo); 700 701 // convert to NTL again using the faster conversion routines 702 GF2EX f1; 703 if (isPurePoly(f)) 704 { 705 GF2X f_tmp=convertFacCF2NTLGF2X(f); 706 f1=to_GF2EX(f_tmp); 707 } 708 else 709 f1=convertFacCF2NTLGF2EX(f,minPo); 710 711 // make monic (in Z/2(a)) 712 GF2E f1_coef=LeadCoeff(f1); 713 MakeMonic(f1); 714 715 // factorize using NTL 716 vec_pair_GF2EX_long factors; 717 CanZass(factors,f1); 718 719 // return converted result 720 F=convertNTLvec_pair_GF2EX_long2FacCFFList(factors,f1_coef,f.mvar(),alpha); 721 } 720 722 #else 721 factoryError ("univariate factorization depends on NTL(missing)");722 return CFFList (CFFactor (f, 1));723 factoryError ("univariate factorization depends on NTL(missing)"); 724 return CFFList (CFFactor (f, 1)); 723 725 #endif //HAVE_NTL 724 } 725 else if (ch>0) 726 { 727 #ifdef HAVE_NTL 728 F= FqFactorize (f, alpha); 729 #else 730 ASSERT( f.isUnivariate(), "multivariate factorization depends on NTL(missing)" ); 731 factoryError ("multivariate factorization depends on NTL(missing)"); 732 return CFFList (CFFactor (f, 1)); 733 #endif 734 735 } 736 else if (f.isUnivariate() && (ch == 0)) // Q(a)[x] 737 { 738 F= AlgExtFactorize (f, alpha); 739 } 740 else //Q(a)[x1,...,xn] 741 { 726 } 727 else 728 { 742 729 #ifdef HAVE_NTL 743 F= ratFactorize (f, alpha);730 F= FqFactorize (f, alpha); 744 731 #else 745 ASSERT( f.isUnivariate(), "multivariate factorization depends on NTL(missing)" ); 746 factoryError ("multivariate factorization depends on NTL(missing)"); 747 return CFFList (CFFactor (f, 1)); 748 #endif 732 ASSERT( f.isUnivariate(), "multivariate factorization depends on NTL(missing)" ); 733 factoryError ("multivariate factorization depends on NTL(missing)"); 734 return CFFList (CFFactor (f, 1)); 735 #endif 736 } 737 } 738 else // Q(a)[x] 739 { 740 if (f.isUnivariate()) 741 { 742 F= AlgExtFactorize (f, alpha); 743 } 744 else //Q(a)[x1,...,xn] 745 { 746 #ifdef HAVE_NTL 747 F= ratFactorize (f, alpha); 748 #else 749 ASSERT( f.isUnivariate(), "multivariate factorization depends on NTL(missing)" ); 750 factoryError ("multivariate factorization depends on NTL(missing)"); 751 return CFFList (CFFactor (f, 1)); 752 #endif 753 } 749 754 } 750 755 if(isOn(SW_USE_NTL_SORT)) F.sort(cmpCF); -
kernel/GBEngine/kstd1.cc
r177e74 r6cbb4a 520 520 } 521 521 } 522 523 int redRiloc_Z (LObject* h,kStrategy strat) 524 { 525 int i,at,ei,li,ii; 526 int j = 0; 527 int pass = 0; 528 long d,reddeg; 529 int docoeffred = 0; 530 poly T0p = strat->T[0].p; 531 int T0ecart = strat->T[0].ecart; 532 533 534 d = h->GetpFDeg()+ h->ecart; 535 reddeg = strat->LazyDegree+d; 536 h->SetShortExpVector(); 537 if (strat->T[0].GetpFDeg() == 0 && strat->T[0].length <= 2) { 538 docoeffred = 1; 539 } 540 loop 541 { 542 /* cut down the lead coefficients, only possible if the degree of 543 * T[0] is 0 (constant). This is only efficient if T[0] is short, thus 544 * we ask for the length of T[0] to be <= 2 */ 545 if (docoeffred) { 546 j = kTestDivisibleByT0_Z(strat, h); 547 if (j == 0 && n_DivBy(pGetCoeff(h->p), pGetCoeff(T0p), currRing->cf) == FALSE 548 && T0ecart <= h->ecart) { 549 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer)) 550 * => we try to cut down the lead coefficient at least */ 551 /* first copy T[j] in order to multiply it with a coefficient later on */ 552 number mult, rest; 553 TObject tj = strat->T[0]; 554 tj.Copy(); 555 /* compute division with remainder of lc(h) and lc(T[j]) */ 556 mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(T0p), 557 &rest, currRing->cf); 558 /* set corresponding new lead coefficient already. we do not 559 * remove the lead term in ksReducePolyLC, but only apply 560 * a lead coefficient reduction */ 561 tj.Mult_nn(mult); 562 ksReducePolyLC(h, &tj, NULL, &rest, strat); 563 tj.Delete(); 564 tj.Clear(); 565 } 566 } 567 j = kFindDivisibleByInT(strat, h); 568 if (j < 0) 569 { 570 // over ZZ: cleanup coefficients by complete reduction with monomials 571 postReduceByMon(h, strat); 572 if(h->p == NULL) 573 { 574 kDeleteLcm(h); 575 h->Clear(); 576 return 0; 577 } 578 if (strat->honey) h->SetLength(strat->length_pLength); 579 if(strat->tl >= 0) 580 h->i_r1 = strat->tl; 581 else 582 h->i_r1 = -1; 583 if (h->GetLmTailRing() == NULL) 584 { 585 kDeleteLcm(h); 586 h->Clear(); 587 return 0; 588 } 589 return 1; 590 } 591 592 ei = strat->T[j].ecart; 593 ii = j; 594 #if 1 595 if (ei > h->ecart && ii < strat->tl) 596 { 597 li = strat->T[j].length; 598 // the polynomial to reduce with (up to the moment) is; 599 // pi with ecart ei and length li 600 // look for one with smaller ecart 601 i = j; 602 loop 603 { 604 /*- takes the first possible with respect to ecart -*/ 605 i++; 606 #if 1 607 if (i > strat->tl) break; 608 if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei && 609 strat->T[i].length < li)) 610 && 611 p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i], h->GetLmTailRing(), ~h->sev, strat->tailRing) 612 && 613 n_DivBy(h->p->coef,strat->T[i].p->coef,strat->tailRing->cf)) 614 #else 615 j = kFindDivisibleByInT(strat, h, i); 616 if (j < 0) break; 617 i = j; 618 if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei && 619 strat->T[i].length < li)) 620 #endif 621 { 622 // the polynomial to reduce with is now 623 ii = i; 624 ei = strat->T[i].ecart; 625 if (ei <= h->ecart) break; 626 li = strat->T[i].length; 627 } 628 } 629 } 630 #endif 631 632 // end of search: have to reduce with pi 633 if (ei > h->ecart) 634 { 635 // It is not possible to reduce h with smaller ecart; 636 // if possible h goes to the lazy-set L,i.e 637 // if its position in L would be not the last one 638 strat->fromT = TRUE; 639 if (!TEST_OPT_REDTHROUGH && strat->Ll >= 0) /*- L is not empty -*/ 640 { 641 h->SetLmCurrRing(); 642 if (strat->honey && strat->posInLDependsOnLength) 643 h->SetLength(strat->length_pLength); 644 assume(h->FDeg == h->pFDeg()); 645 at = strat->posInL(strat->L,strat->Ll,h,strat); 646 if (at <= strat->Ll && pLmCmp(h->p, strat->L[strat->Ll].p) != 0 && !nEqual(h->p->coef, strat->L[strat->Ll].p->coef)) 647 { 648 /*- h will not become the next element to reduce -*/ 649 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); 650 #ifdef KDEBUG 651 if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at); 652 #endif 653 h->Clear(); 654 strat->fromT = FALSE; 655 return -1; 656 } 657 } 658 doRed(h,&(strat->T[ii]),strat->fromT,strat,TRUE); 659 } 660 else 661 { 662 // now we finally can reduce 663 doRed(h,&(strat->T[ii]),strat->fromT,strat,FALSE); 664 } 665 strat->fromT=FALSE; 666 // are we done ??? 667 if (h->IsNull()) 668 { 669 kDeleteLcm(h); 670 h->Clear(); 671 return 0; 672 } 673 674 // NO! 675 h->SetShortExpVector(); 676 h->SetpFDeg(); 677 if (strat->honey) 678 { 679 if (ei <= h->ecart) 680 h->ecart = d-h->GetpFDeg(); 681 else 682 h->ecart = d-h->GetpFDeg()+ei-h->ecart; 683 } 684 else 685 // this has the side effect of setting h->length 686 h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg(); 687 /*- try to reduce the s-polynomial -*/ 688 pass++; 689 d = h->GetpFDeg()+h->ecart; 690 /* 691 *test whether the polynomial should go to the lazyset L 692 *-if the degree jumps 693 *-if the number of pre-defined reductions jumps 694 */ 695 if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) 696 && ((d >= reddeg) || (pass > strat->LazyPass))) 697 { 698 h->SetLmCurrRing(); 699 if (strat->honey && strat->posInLDependsOnLength) 700 h->SetLength(strat->length_pLength); 701 assume(h->FDeg == h->pFDeg()); 702 at = strat->posInL(strat->L,strat->Ll,h,strat); 703 if (at <= strat->Ll) 704 { 705 int dummy=strat->sl; 706 if (kFindDivisibleByInS(strat, &dummy, h) < 0) 707 { 708 if (strat->honey && !strat->posInLDependsOnLength) 709 h->SetLength(strat->length_pLength); 710 return 1; 711 } 712 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); 713 #ifdef KDEBUG 714 if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); 715 #endif 716 h->Clear(); 717 return -1; 718 } 719 } 720 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) 721 { 722 Print(".%ld",d);mflush(); 723 reddeg = d+1; 724 if (h->pTotalDeg()+h->ecart >= (int)strat->tailRing->bitmask) 725 { 726 strat->overflow=TRUE; 727 //Print("OVERFLOW in redEcart d=%ld, max=%ld",d,strat->tailRing->bitmask); 728 h->GetP(); 729 at = strat->posInL(strat->L,strat->Ll,h,strat); 730 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); 731 h->Clear(); 732 return -1; 733 } 734 } 735 } 736 } 522 737 #endif 523 738 … … 762 977 static poly redMoraNFRing (poly h,kStrategy strat, int flag) 763 978 { 764 LObject H; 765 H.p = h; 766 int j = 0; 767 int z = 10; 768 int o = H.SetpFDeg(); 769 H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o; 770 if ((flag & 2) == 0) cancelunit(&H,TRUE); 771 H.sev = pGetShortExpVector(H.p); 772 unsigned long not_sev = ~ H.sev; 773 loop 774 { 775 if (j > strat->tl) 776 { 777 return H.p; 778 } 779 if (TEST_V_DEG_STOP) 780 { 781 if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p); 782 if (H.p==NULL) return NULL; 783 } 784 if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing) 785 && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf)) 786 ) 787 { 788 /*- remember the found T-poly -*/ 789 // poly pi = strat->T[j].p; 790 int ei = strat->T[j].ecart; 791 int li = strat->T[j].length; 792 int ii = j; 793 /* 794 * the polynomial to reduce with (up to the moment) is; 795 * pi with ecart ei and length li 796 */ 797 loop 798 { 799 /*- look for a better one with respect to ecart -*/ 800 /*- stop, if the ecart is small enough (<=ecart(H)) -*/ 801 j++; 802 if (j > strat->tl) break; 803 if (ei <= H.ecart) break; 804 if (((strat->T[j].ecart < ei) 805 || ((strat->T[j].ecart == ei) 806 && (strat->T[j].length < li))) 807 && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev) 808 && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf)) 809 ) 810 { 811 /* 812 * the polynomial to reduce with is now; 813 */ 814 // pi = strat->T[j].p; 815 ei = strat->T[j].ecart; 816 li = strat->T[j].length; 817 ii = j; 818 } 819 } 820 /* 821 * end of search: have to reduce with pi 822 */ 823 z++; 824 if (z>10) 825 { 826 pNormalize(H.p); 827 z=0; 828 } 829 if ((ei > H.ecart) && (!strat->kHEdgeFound)) 830 { 831 /* 832 * It is not possible to reduce h with smaller ecart; 833 * we have to reduce with bad ecart: H has to enter in T 834 */ 835 doRed(&H,&(strat->T[ii]),TRUE,strat,TRUE); 836 if (H.p == NULL) 837 return NULL; 838 } 839 else 840 { 841 /* 842 * we reduce with good ecart, h need not to be put to T 843 */ 844 doRed(&H,&(strat->T[ii]),FALSE,strat,TRUE); 845 if (H.p == NULL) 846 return NULL; 847 } 848 /*- try to reduce the s-polynomial -*/ 849 o = H.SetpFDeg(); 850 if ((flag &2 ) == 0) cancelunit(&H,TRUE); 851 H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o; 852 j = 0; 853 H.sev = pGetShortExpVector(H.p); 854 not_sev = ~ H.sev; 855 } 856 else 857 { 858 j++; 859 } 860 } 979 LObject H; 980 H.p = h; 981 int j0, j = 0; 982 int z = 10; 983 int docoeffred = 0; 984 poly T0p = strat->T[0].p; 985 int T0ecart = strat->T[0].ecart; 986 int o = H.SetpFDeg(); 987 H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o; 988 if ((flag & 2) == 0) cancelunit(&H,TRUE); 989 H.sev = pGetShortExpVector(H.p); 990 unsigned long not_sev = ~ H.sev; 991 if (strat->T[0].GetpFDeg() == 0 && strat->T[0].length <= 2) { 992 docoeffred = 1; 993 } 994 loop 995 { 996 /* cut down the lead coefficients, only possible if the degree of 997 * T[0] is 0 (constant). This is only efficient if T[0] is short, thus 998 * we ask for the length of T[0] to be <= 2 */ 999 if (docoeffred) { 1000 j0 = kTestDivisibleByT0_Z(strat, &H); 1001 if (j0 == 0 && n_DivBy(pGetCoeff(H.p), pGetCoeff(T0p), currRing->cf) == FALSE 1002 && T0ecart <= H.ecart) { 1003 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer)) 1004 * => we try to cut down the lead coefficient at least */ 1005 /* first copy T[j0] in order to multiply it with a coefficient later on */ 1006 number mult, rest; 1007 TObject tj = strat->T[0]; 1008 tj.Copy(); 1009 /* compute division with remainder of lc(h) and lc(T[j]) */ 1010 mult = n_QuotRem(pGetCoeff(H.p), pGetCoeff(T0p), 1011 &rest, currRing->cf); 1012 /* set corresponding new lead coefficient already. we do not 1013 * remove the lead term in ksReducePolyLC, but only apply 1014 * a lead coefficient reduction */ 1015 tj.Mult_nn(mult); 1016 ksReducePolyLC(&H, &tj, NULL, &rest, strat); 1017 tj.Delete(); 1018 tj.Clear(); 1019 } 1020 } 1021 if (j > strat->tl) 1022 { 1023 return H.p; 1024 } 1025 if (TEST_V_DEG_STOP) 1026 { 1027 if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p); 1028 if (H.p==NULL) return NULL; 1029 } 1030 if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing) 1031 && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf)) 1032 ) 1033 { 1034 /*- remember the found T-poly -*/ 1035 // poly pi = strat->T[j].p; 1036 int ei = strat->T[j].ecart; 1037 int li = strat->T[j].length; 1038 int ii = j; 1039 /* 1040 * the polynomial to reduce with (up to the moment) is; 1041 * pi with ecart ei and length li 1042 */ 1043 loop 1044 { 1045 /*- look for a better one with respect to ecart -*/ 1046 /*- stop, if the ecart is small enough (<=ecart(H)) -*/ 1047 j++; 1048 if (j > strat->tl) break; 1049 if (ei <= H.ecart) break; 1050 if (((strat->T[j].ecart < ei) 1051 || ((strat->T[j].ecart == ei) 1052 && (strat->T[j].length < li))) 1053 && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev) 1054 && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf)) 1055 ) 1056 { 1057 /* 1058 * the polynomial to reduce with is now; 1059 */ 1060 // pi = strat->T[j].p; 1061 ei = strat->T[j].ecart; 1062 li = strat->T[j].length; 1063 ii = j; 1064 } 1065 } 1066 /* 1067 * end of search: have to reduce with pi 1068 */ 1069 z++; 1070 if (z>10) 1071 { 1072 pNormalize(H.p); 1073 z=0; 1074 } 1075 if ((ei > H.ecart) && (!strat->kHEdgeFound)) 1076 { 1077 /* 1078 * It is not possible to reduce h with smaller ecart; 1079 * we have to reduce with bad ecart: H has to enter in T 1080 */ 1081 doRed(&H,&(strat->T[ii]),TRUE,strat,TRUE); 1082 if (H.p == NULL) 1083 return NULL; 1084 } 1085 else 1086 { 1087 /* 1088 * we reduce with good ecart, h need not to be put to T 1089 */ 1090 doRed(&H,&(strat->T[ii]),FALSE,strat,TRUE); 1091 if (H.p == NULL) 1092 return NULL; 1093 } 1094 /*- try to reduce the s-polynomial -*/ 1095 o = H.SetpFDeg(); 1096 if ((flag &2 ) == 0) cancelunit(&H,TRUE); 1097 H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o; 1098 j = 0; 1099 H.sev = pGetShortExpVector(H.p); 1100 not_sev = ~ H.sev; 1101 } 1102 else 1103 { 1104 j++; 1105 } 1106 } 861 1107 } 862 1108 #endif … … 1486 1732 } 1487 1733 1488 if (rField_is_Ring(currRing)) 1489 strat->red = redRiloc; 1734 if (rField_is_Ring(currRing)) { 1735 if (rField_is_Z(currRing)) 1736 strat->red = redRiloc_Z; 1737 else 1738 strat->red = redRiloc; 1739 } 1490 1740 1491 1741 /*reads the ecartWeights used for Graebes method from the -
kernel/GBEngine/kstd2.cc
r177e74 r6cbb4a 135 135 } 136 136 } 137 // return -1 if no divisor is found 138 // number of first divisor, otherwise 137 // return -1 if T[0] does not divide the leading monomial 138 int kTestDivisibleByT0_Z(const kStrategy strat, const LObject* L) 139 { 140 if (strat->tl < 1) 141 return -1; 142 143 unsigned long not_sev = ~L->sev; 144 const unsigned long sevT0 = strat->sevT[0]; 145 number rest, orest, mult; 146 if (L->p!=NULL) 147 { 148 const poly T0p = strat->T[0].p; 149 const ring r = currRing; 150 const poly p = L->p; 151 orest = pGetCoeff(p); 152 153 pAssume(~not_sev == p_GetShortExpVector(p, r)); 154 155 #if defined(PDEBUG) || defined(PDIV_DEBUG) 156 if (p_LmShortDivisibleBy(T0p, sevT0, not_sev, r)) 157 { 158 mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf); 159 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { 160 return 0; 161 } 162 } 163 #else 164 if (!(sevT0 & not_sev) && p_LmDivisibleBy(T0p, p, r)) 165 { 166 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf); 167 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { 168 return 0; 169 } 170 } 171 #endif 172 } 173 else 174 { 175 const poly T0p = strat->T[0].t_p; 176 const ring r = strat->tailRing; 177 const poly p = L->t_p; 178 orest = pGetCoeff(p); 179 #if defined(PDEBUG) || defined(PDIV_DEBUG) 180 if (p_LmShortDivisibleBy(strat->T[0].t_p, sevT[j], 181 p, not_sev, r)) 182 { 183 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf); 184 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { 185 return 0; 186 } 187 } 188 #else 189 if (!(sevT0 & not_sev) && p_LmDivisibleBy(T0p, p, r)) 190 { 191 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r->cf); 192 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { 193 return 0; 194 } 195 } 196 #endif 197 } 198 return -1; 199 } 200 139 201 int kFindDivisibleByInT_Z(const kStrategy strat, const LObject* L, const int start) 140 202 { … … 191 253 p, not_sev, r)) 192 254 { 193 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j]. p), &rest, r->cf);255 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r->cf); 194 256 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { 195 257 o = j; … … 200 262 if (!(sevT[j] & not_sev) && p_LmDivisibleBy(T[j].t_p, p, r)) 201 263 { 202 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j]. p), &rest, r->cf);264 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r->cf); 203 265 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r->cf), n_EucNorm(rest, r->cf), r->cf) == TRUE) { 204 266 o = j; -
kernel/GBEngine/kutil.h
r177e74 r6cbb4a 602 602 int kFindSameLMInT_Z(const kStrategy strat, const LObject* L, const int start=0); 603 603 604 /// tests if T[0] divides the leading monomial of L, returns -1 if not 605 int kTestDivisibleByT0_Z(const kStrategy strat, const LObject* L); 604 606 /// return -1 if no divisor is found 605 607 /// number of first divisor in S, otherwise
Note: See TracChangeset
for help on using the changeset viewer.