Changeset 152e71c in git


Ignore:
Timestamp:
Feb 28, 2014, 5:23:48 PM (10 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
546e3e4eb7aba52cab2eb659c027866693024f3c
Parents:
c2b10fe022a6d9764f0efba82bd5909bf1739ee0
Message:
Fixed ratGB compilation&linkage (if HAVE_RATGRING)
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/kpolys.cc

    rc2b10f r152e71c  
    7171  return FALSE;
    7272}
     73
    7374#ifdef HAVE_RATGRING
    7475BOOLEAN pCompareChainPart (poly p,poly p1,poly p2,poly lcm, const ring R)
  • kernel/kutil.h

    rc2b10f r152e71c  
    552552BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
    553553BOOLEAN 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
    555556int kFindInT(poly p, TSet T, int tlength);
    556557
    557 // return -1 if no divisor is found
    558 //        number of first divisor, otherwise
     558/// return -1 if no divisor is found
     559///        number of first divisor in T, otherwise
    559560int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT,
    560561                        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
    562565int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L);
    563566
  • kernel/polys.h

    rc2b10f r152e71c  
    361361BOOLEAN pCompareChain (poly p, poly p1, poly p2, poly lcm, const ring R = currRing);
    362362
     363#ifdef HAVE_RATGRING
     364BOOLEAN pCompareChainPart (poly p, poly p1, poly p2, poly lcm, const ring R = currRing);
     365#endif
     366
     367
    363368#define  pEqualPolys(p1,p2) p_EqualPolys(p1,p2,currRing)
    364369
  • kernel/ratgring.cc

    rc2b10f r152e71c  
    4141}
    4242
    43 /*2
    44 * returns the rational LCM of the head terms of a and b
    45 * 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 
    7043// void pLcmRat(poly a, poly b, poly m, poly pshift)
    7144// {
     
    10578}
    10679
    107 /* returns x-coeff of p, i.e. a poly in x, s.t. corresponding xd-monomials
    108 have the same D-part and the component 0
    109 does not destroy p
    110 */
    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 internally
    117   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 
    14980/* to test!!! */
    15081/* ExpVector(pr) = ExpVector(p1) - ExpVector(p2) */
     
    236167  PrintS(" GCD_start:");
    237168#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);
    239170#ifdef PDEBUG
    240171  p_wrp(g,r);
    241172  PrintS(" GCD_end;\n");
    242173#endif
    243   poly u = singclap_pdivide(q,g); //q/g
    244   poly v = singclap_pdivide(p,g); //p/g
     174  poly u = singclap_pdivide(q, g, r); //q/g
     175  poly v = singclap_pdivide(p, g, r); //p/g
    245176  v = p_Neg(v,r);
    246177  p_Delete(&p,r);
     
    403334// }
    404335
     336#undef CC
    405337
    406338/*4 - follow the numbering of gring.cc
     
    708640}
    709641
    710 void pContentRat(poly &ph)
    711 // changes ph
    712 // for rat coefficients in K(x1,..xN)
    713 {
    714 
    715   // init array of RatLeadCoeffs
    716   //  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 coeffs
    720   poly *LM = (poly *)omAlloc0((len+1)*sizeof(poly));  // rat lead terms
    721   int *D = (int *)omAlloc0((len+1)*sizeof(int));  //degrees of coeffs
    722   int *L = (int *)omAlloc0((len+1)*sizeof(int));  //lengths of coeffs
    723   int k = 0;
    724   poly p = pCopy(ph); // ph will be needed below
    725   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 numerical
    741       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 length
    749   k--;
    750   poly d;
    751   int mindeglen = len;
    752   if (k<=0) // this poly is not a ratgring poly -> pContent
    753   {
    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 elements
    774   // and pmideglen is the coordinate of one of the smallest among them
    775 
    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, return
    786       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 sure
    805   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 anymore
    811   ph = p;
    812   // aufraeumen, return
    813 cleanup:
    814   omFree(C);
    815   omFree(LM);
    816   omFree(D);
    817   omFree(L);
    818 }
    819 
    820642// test if monomial is a constant, i.e. if all exponents and the component
    821643// is zero
  • kernel/ratgring.h

    rc2b10f r152e71c  
    1212#include <kernel/structs.h>
    1313#include <polys/nc/nc.h>
     14#include <polys/monomials/p_polys.h>
    1415
    1516/* MACROS */
     
    2122void pLcmRat(poly a, poly b, poly m, int rat_shift);
    2223
    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 
    2724poly p_HeadRat(poly p, int ishift, ring r);
    28 
    29 void p_LmDeleteAndNextRat(poly *p, int ishift, ring r);
    3025
    3126void p_ExpVectorDiffRat(poly pr, poly p1, poly p2, int ishift, ring r);
     
    113108
    114109// Content stuff
    115 
    116 void pContentRat(poly &ph);
     110static inline void pContentRat(poly &ph, const ring r = currRing){ p_ContentRat(ph, r); } ;
    117111
    118112BOOLEAN p_LmIsConstantRat(const poly p, const ring r);
     
    120114BOOLEAN p_LmIsConstantCompRat(const poly p, const ring r);
    121115
    122 BOOLEAN pCompareChainPart (poly p,poly p1,poly p2,poly lcm);
    123 
    124116#endif /* HAVE_PLURAL */
    125117#endif
  • libpolys/polys/monomials/p_polys.cc

    rc2b10f r152e71c  
    15891589  /* Don't do a pSetm here, otherwise hres/lres chockes */
    15901590}
     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*/
     1599poly 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
     1622void 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
     1641have the same D-part and the component 0
     1642does not destroy p
     1643*/
     1644poly 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
     1666void 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
     1768cleanup:
     1769  omFree(C);
     1770  omFree(LM);
     1771  omFree(D);
     1772  omFree(L);
     1773}
     1774
     1775
     1776#endif
     1777
    15911778
    15921779/* assumes that p and divisor are univariate polynomials in r,
     
    26142801    {
    26152802      /* quick unit detection in the rational case is done in gr_nc_bba */
    2616       pContentRat(p);
     2803      p_ContentRat(p, r);
    26172804      start=p;
    26182805    }
  • libpolys/polys/monomials/p_polys.h

    rc2b10f r152e71c  
    15771577  }
    15781578#ifdef HAVE_RINGS
    1579   pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == nDivBy(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));
    15801580  return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
    15811581#else
     
    16181618  while (i>=start);
    16191619#ifdef HAVE_RINGS
    1620   return nDivBy(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);
    16211621#else
    16221622  return TRUE;
     
    18371837// returns the LCM of the head terms of a and b in *m
    18381838void p_Lcm(const poly a, const poly b, poly m, const ring r);
     1839
     1840#ifdef HAVE_RATGRING
     1841poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r);
     1842poly p_GetCoeffRat(poly p, int ishift, ring r);
     1843void p_LmDeleteAndNextRat(poly *p, int ishift, ring r);
     1844void p_ContentRat(poly &ph, const ring r);
     1845#endif /* ifdef HAVE_RATGRING */
     1846
    18391847
    18401848poly      p_Diff(poly a, int k, const ring r);
Note: See TracChangeset for help on using the changeset viewer.