Changeset 152e71c in git
- Timestamp:
- Feb 28, 2014, 5:23:48 PM (10 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 546e3e4eb7aba52cab2eb659c027866693024f3c
- Parents:
- c2b10fe022a6d9764f0efba82bd5909bf1739ee0
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/kpolys.cc
rc2b10f r152e71c 71 71 return FALSE; 72 72 } 73 73 74 #ifdef HAVE_RATGRING 74 75 BOOLEAN pCompareChainPart (poly p,poly p1,poly p2,poly lcm, const ring R) -
kernel/kutil.h
rc2b10f r152e71c 552 552 BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start); 553 553 BOOLEAN findMinLMPair(poly sig, unsigned long not_sevSig, kStrategy strat, int start); 554 // returns index of p in TSet, or -1 if not found 554 555 /// returns index of p in TSet, or -1 if not found 555 556 int kFindInT(poly p, TSet T, int tlength); 556 557 557 // return -1 if no divisor is found558 // number of first divisor, otherwise558 /// return -1 if no divisor is found 559 /// number of first divisor in T, otherwise 559 560 int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT, 560 561 const int tl, const LObject* L, const int start=0); 561 // same with S 562 563 /// return -1 if no divisor is found 564 /// number of first divisor in S, otherwise 562 565 int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L); 563 566 -
kernel/polys.h
rc2b10f r152e71c 361 361 BOOLEAN pCompareChain (poly p, poly p1, poly p2, poly lcm, const ring R = currRing); 362 362 363 #ifdef HAVE_RATGRING 364 BOOLEAN pCompareChainPart (poly p, poly p1, poly p2, poly lcm, const ring R = currRing); 365 #endif 366 367 363 368 #define pEqualPolys(p1,p2) p_EqualPolys(p1,p2,currRing) 364 369 -
kernel/ratgring.cc
rc2b10f r152e71c 41 41 } 42 42 43 /*244 * returns the rational LCM of the head terms of a and b45 * without coefficient!!!46 */47 poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r)48 {49 poly m = // p_One( r);50 p_Init(r);51 52 const int (currRing->N) = r->N;53 54 // for (int i = (currRing->N); i>=r->real_var_start; i--)55 for (int i = r->real_var_end; i>=r->real_var_start; i--)56 {57 const int lExpA = p_GetExp (a, i, r);58 const int lExpB = p_GetExp (b, i, r);59 60 p_SetExp (m, i, si_max(lExpA, lExpB), r);61 }62 63 p_SetComp (m, lCompM, r);64 p_Setm(m,r);65 n_New(&(p_GetCoeff(m, r)), r);66 67 return(m);68 };69 70 43 // void pLcmRat(poly a, poly b, poly m, poly pshift) 71 44 // { … … 105 78 } 106 79 107 /* returns x-coeff of p, i.e. a poly in x, s.t. corresponding xd-monomials108 have the same D-part and the component 0109 does not destroy p110 */111 112 poly p_GetCoeffRat(poly p, int ishift, ring r)113 {114 poly q = pNext(p);115 poly res; // = p_Head(p,r);116 res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally117 p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r);118 poly s;119 long cmp = p_GetComp(p, r);120 while ( (q!= NULL) && (p_Comp_k_n(p, q, ishift+1, r)) && (p_GetComp(q, r) == cmp) )121 {122 s = p_GetExp_k_n(q, ishift+1, r->N, r);123 p_SetCoeff(s,n_Copy(p_GetCoeff(q,r),r),r);124 res = p_Add_q(res,s,r);125 q = pNext(q);126 }127 cmp = 0;128 p_SetCompP(res,cmp,r);129 return res;130 }131 132 void p_LmDeleteAndNextRat(poly *p, int ishift, ring r)133 {134 /* modifies p*/135 // Print("start: "); Print(" "); p_wrp(*p,r);136 p_LmCheckPolyRing2(*p, r);137 poly q = p_Head(*p,r);138 const long cmp = p_GetComp(*p, r);139 while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ) && (p_GetComp(*p, r) == cmp) )140 {141 p_LmDelete(p,r);142 // Print("while: ");p_wrp(*p,r);Print(" ");143 }144 // p_wrp(*p,r);Print(" ");145 // PrintS("end\n");146 p_LmDelete(&q,r);147 }148 149 80 /* to test!!! */ 150 81 /* ExpVector(pr) = ExpVector(p1) - ExpVector(p2) */ … … 236 167 PrintS(" GCD_start:"); 237 168 #endif 238 poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r) );169 poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r), r); 239 170 #ifdef PDEBUG 240 171 p_wrp(g,r); 241 172 PrintS(" GCD_end;\n"); 242 173 #endif 243 poly u = singclap_pdivide(q, g); //q/g244 poly v = singclap_pdivide(p, g); //p/g174 poly u = singclap_pdivide(q, g, r); //q/g 175 poly v = singclap_pdivide(p, g, r); //p/g 245 176 v = p_Neg(v,r); 246 177 p_Delete(&p,r); … … 403 334 // } 404 335 336 #undef CC 405 337 406 338 /*4 - follow the numbering of gring.cc … … 708 640 } 709 641 710 void pContentRat(poly &ph)711 // changes ph712 // for rat coefficients in K(x1,..xN)713 {714 715 // init array of RatLeadCoeffs716 // poly p_GetCoeffRat(poly p, int ishift, ring r);717 718 int len=pLength(ph);719 poly *C = (poly *)omAlloc0((len+1)*sizeof(poly)); //rat coeffs720 poly *LM = (poly *)omAlloc0((len+1)*sizeof(poly)); // rat lead terms721 int *D = (int *)omAlloc0((len+1)*sizeof(int)); //degrees of coeffs722 int *L = (int *)omAlloc0((len+1)*sizeof(int)); //lengths of coeffs723 int k = 0;724 poly p = pCopy(ph); // ph will be needed below725 int mintdeg = pTotaldegree(p);726 int minlen = len;727 int dd = 0; int i;728 int HasConstantCoef = 0;729 int is = currRing->real_var_start - 1;730 while (p!=NULL)731 {732 LM[k] = p_GetExp_k_n(p,1,is,currRing); // need LmRat istead of p_HeadRat(p, is, currRing); !733 C[k] = p_GetCoeffRat(p, is, currRing);734 D[k] = pTotaldegree(C[k]);735 mintdeg = si_min(mintdeg,D[k]);736 L[k] = pLength(C[k]);737 minlen = si_min(minlen,L[k]);738 if (pIsConstant(C[k]))739 {740 // C[k] = const, so the content will be numerical741 HasConstantCoef = 1;742 // smth like goto cleanup and return(pContent(p));743 }744 p_LmDeleteAndNextRat(&p, is, currRing);745 k++;746 }747 748 // look for 1 element of minimal degree and of minimal length749 k--;750 poly d;751 int mindeglen = len;752 if (k<=0) // this poly is not a ratgring poly -> pContent753 {754 pDelete(&C[0]);755 pDelete(&LM[0]);756 p_Content(ph,currRing);757 goto cleanup;758 }759 760 int pmindeglen;761 for(i=0; i<=k; i++)762 {763 if (D[i] == mintdeg)764 {765 if (L[i] < mindeglen)766 {767 mindeglen=L[i];768 pmindeglen = i;769 }770 }771 }772 d = pCopy(C[pmindeglen]);773 // there are dd>=1 mindeg elements774 // and pmideglen is the coordinate of one of the smallest among them775 776 // poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r));777 // return naGcd(d,d2,currRing);778 779 // adjoin pContentRat here?780 for(i=0; i<=k; i++)781 {782 d=singclap_gcd(d,pCopy(C[i]));783 if (pTotaldegree(d)==0)784 {785 // cleanup, pContent, return786 pDelete(&d);787 for(;k>=0;k--)788 {789 pDelete(&C[k]);790 pDelete(&LM[k]);791 }792 p_Content(ph,currRing);793 goto cleanup;794 }795 }796 for(i=0; i<=k; i++)797 {798 poly h=singclap_pdivide(C[i],d);799 pDelete(&C[i]);800 C[i]=h;801 }802 803 // zusammensetzen,804 p=NULL; // just to be sure805 for(i=0; i<=k; i++)806 {807 p = pAdd(p, pMult(C[i],LM[i]) );808 C[i]=NULL; LM[i]=NULL;809 }810 pDelete(&ph); // do not need it anymore811 ph = p;812 // aufraeumen, return813 cleanup:814 omFree(C);815 omFree(LM);816 omFree(D);817 omFree(L);818 }819 820 642 // test if monomial is a constant, i.e. if all exponents and the component 821 643 // is zero -
kernel/ratgring.h
rc2b10f r152e71c 12 12 #include <kernel/structs.h> 13 13 #include <polys/nc/nc.h> 14 #include <polys/monomials/p_polys.h> 14 15 15 16 /* MACROS */ … … 21 22 void pLcmRat(poly a, poly b, poly m, int rat_shift); 22 23 23 poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r);24 25 poly p_GetCoeffRat(poly p, int ishift, ring r);26 27 24 poly p_HeadRat(poly p, int ishift, ring r); 28 29 void p_LmDeleteAndNextRat(poly *p, int ishift, ring r);30 25 31 26 void p_ExpVectorDiffRat(poly pr, poly p1, poly p2, int ishift, ring r); … … 113 108 114 109 // Content stuff 115 116 void pContentRat(poly &ph); 110 static inline void pContentRat(poly &ph, const ring r = currRing){ p_ContentRat(ph, r); } ; 117 111 118 112 BOOLEAN p_LmIsConstantRat(const poly p, const ring r); … … 120 114 BOOLEAN p_LmIsConstantCompRat(const poly p, const ring r); 121 115 122 BOOLEAN pCompareChainPart (poly p,poly p1,poly p2,poly lcm);123 124 116 #endif /* HAVE_PLURAL */ 125 117 #endif -
libpolys/polys/monomials/p_polys.cc
rc2b10f r152e71c 1589 1589 /* Don't do a pSetm here, otherwise hres/lres chockes */ 1590 1590 } 1591 1592 1593 1594 #ifdef HAVE_RATGRING 1595 /*2 1596 * returns the rational LCM of the head terms of a and b 1597 * without coefficient!!! 1598 */ 1599 poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r) 1600 { 1601 poly m = // p_One( r); 1602 p_Init(r); 1603 1604 // const int (currRing->N) = r->N; 1605 1606 // for (int i = (currRing->N); i>=r->real_var_start; i--) 1607 for (int i = r->real_var_end; i>=r->real_var_start; i--) 1608 { 1609 const int lExpA = p_GetExp (a, i, r); 1610 const int lExpB = p_GetExp (b, i, r); 1611 1612 p_SetExp (m, i, si_max(lExpA, lExpB), r); 1613 } 1614 1615 p_SetComp (m, lCompM, r); 1616 p_Setm(m,r); 1617 n_New(&(p_GetCoeff(m, r)), r); 1618 1619 return(m); 1620 }; 1621 1622 void p_LmDeleteAndNextRat(poly *p, int ishift, ring r) 1623 { 1624 /* modifies p*/ 1625 // Print("start: "); Print(" "); p_wrp(*p,r); 1626 p_LmCheckPolyRing2(*p, r); 1627 poly q = p_Head(*p,r); 1628 const long cmp = p_GetComp(*p, r); 1629 while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ) && (p_GetComp(*p, r) == cmp) ) 1630 { 1631 p_LmDelete(p,r); 1632 // Print("while: ");p_wrp(*p,r);Print(" "); 1633 } 1634 // p_wrp(*p,r);Print(" "); 1635 // PrintS("end\n"); 1636 p_LmDelete(&q,r); 1637 } 1638 1639 1640 /* returns x-coeff of p, i.e. a poly in x, s.t. corresponding xd-monomials 1641 have the same D-part and the component 0 1642 does not destroy p 1643 */ 1644 poly p_GetCoeffRat(poly p, int ishift, ring r) 1645 { 1646 poly q = pNext(p); 1647 poly res; // = p_Head(p,r); 1648 res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally 1649 p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r); 1650 poly s; 1651 long cmp = p_GetComp(p, r); 1652 while ( (q!= NULL) && (p_Comp_k_n(p, q, ishift+1, r)) && (p_GetComp(q, r) == cmp) ) 1653 { 1654 s = p_GetExp_k_n(q, ishift+1, r->N, r); 1655 p_SetCoeff(s,n_Copy(p_GetCoeff(q,r),r),r); 1656 res = p_Add_q(res,s,r); 1657 q = pNext(q); 1658 } 1659 cmp = 0; 1660 p_SetCompP(res,cmp,r); 1661 return res; 1662 } 1663 1664 1665 1666 void p_ContentRat(poly &ph, const ring r) 1667 // changes ph 1668 // for rat coefficients in K(x1,..xN) 1669 { 1670 // init array of RatLeadCoeffs 1671 // poly p_GetCoeffRat(poly p, int ishift, ring r); 1672 1673 int len=pLength(ph); 1674 poly *C = (poly *)omAlloc0((len+1)*sizeof(poly)); //rat coeffs 1675 poly *LM = (poly *)omAlloc0((len+1)*sizeof(poly)); // rat lead terms 1676 int *D = (int *)omAlloc0((len+1)*sizeof(int)); //degrees of coeffs 1677 int *L = (int *)omAlloc0((len+1)*sizeof(int)); //lengths of coeffs 1678 int k = 0; 1679 poly p = p_Copy(ph, r); // ph will be needed below 1680 int mintdeg = p_Totaldegree(p, r); 1681 int minlen = len; 1682 int dd = 0; int i; 1683 int HasConstantCoef = 0; 1684 int is = r->real_var_start - 1; 1685 while (p!=NULL) 1686 { 1687 LM[k] = p_GetExp_k_n(p,1,is, r); // need LmRat istead of p_HeadRat(p, is, currRing); ! 1688 C[k] = p_GetCoeffRat(p, is, r); 1689 D[k] = p_Totaldegree(C[k], r); 1690 mintdeg = si_min(mintdeg,D[k]); 1691 L[k] = pLength(C[k]); 1692 minlen = si_min(minlen,L[k]); 1693 if (p_IsConstant(C[k], r)) 1694 { 1695 // C[k] = const, so the content will be numerical 1696 HasConstantCoef = 1; 1697 // smth like goto cleanup and return(pContent(p)); 1698 } 1699 p_LmDeleteAndNextRat(&p, is, r); 1700 k++; 1701 } 1702 1703 // look for 1 element of minimal degree and of minimal length 1704 k--; 1705 poly d; 1706 int mindeglen = len; 1707 if (k<=0) // this poly is not a ratgring poly -> pContent 1708 { 1709 p_Delete(&C[0], r); 1710 p_Delete(&LM[0], r); 1711 p_Content(ph, r); 1712 goto cleanup; 1713 } 1714 1715 int pmindeglen; 1716 for(i=0; i<=k; i++) 1717 { 1718 if (D[i] == mintdeg) 1719 { 1720 if (L[i] < mindeglen) 1721 { 1722 mindeglen=L[i]; 1723 pmindeglen = i; 1724 } 1725 } 1726 } 1727 d = p_Copy(C[pmindeglen], r); 1728 // there are dd>=1 mindeg elements 1729 // and pmideglen is the coordinate of one of the smallest among them 1730 1731 // poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r)); 1732 // return naGcd(d,d2,currRing); 1733 1734 // adjoin pContentRat here? 1735 for(i=0; i<=k; i++) 1736 { 1737 d=singclap_gcd(d,p_Copy(C[i], r), r); 1738 if (p_Totaldegree(d, r)==0) 1739 { 1740 // cleanup, pContent, return 1741 p_Delete(&d, r); 1742 for(;k>=0;k--) 1743 { 1744 p_Delete(&C[k], r); 1745 p_Delete(&LM[k], r); 1746 } 1747 p_Content(ph, r); 1748 goto cleanup; 1749 } 1750 } 1751 for(i=0; i<=k; i++) 1752 { 1753 poly h=singclap_pdivide(C[i],d, r); 1754 p_Delete(&C[i], r); 1755 C[i]=h; 1756 } 1757 1758 // zusammensetzen, 1759 p=NULL; // just to be sure 1760 for(i=0; i<=k; i++) 1761 { 1762 p = p_Add_q(p, p_Mult_q(C[i],LM[i], r), r); 1763 C[i]=NULL; LM[i]=NULL; 1764 } 1765 p_Delete(&ph, r); // do not need it anymore 1766 ph = p; 1767 // aufraeumen, return 1768 cleanup: 1769 omFree(C); 1770 omFree(LM); 1771 omFree(D); 1772 omFree(L); 1773 } 1774 1775 1776 #endif 1777 1591 1778 1592 1779 /* assumes that p and divisor are univariate polynomials in r, … … 2614 2801 { 2615 2802 /* quick unit detection in the rational case is done in gr_nc_bba */ 2616 p ContentRat(p);2803 p_ContentRat(p, r); 2617 2804 start=p; 2618 2805 } -
libpolys/polys/monomials/p_polys.h
rc2b10f r152e71c 1577 1577 } 1578 1578 #ifdef HAVE_RINGS 1579 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r)));1579 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf)); 1580 1580 return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf); 1581 1581 #else … … 1618 1618 while (i>=start); 1619 1619 #ifdef HAVE_RINGS 1620 return n DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r));1620 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf); 1621 1621 #else 1622 1622 return TRUE; … … 1837 1837 // returns the LCM of the head terms of a and b in *m 1838 1838 void p_Lcm(const poly a, const poly b, poly m, const ring r); 1839 1840 #ifdef HAVE_RATGRING 1841 poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r); 1842 poly p_GetCoeffRat(poly p, int ishift, ring r); 1843 void p_LmDeleteAndNextRat(poly *p, int ishift, ring r); 1844 void p_ContentRat(poly &ph, const ring r); 1845 #endif /* ifdef HAVE_RATGRING */ 1846 1839 1847 1840 1848 poly p_Diff(poly a, int k, const ring r);
Note: See TracChangeset
for help on using the changeset viewer.