Changeset 8d1d30c in git for polys


Ignore:
Timestamp:
Nov 10, 2010, 1:39:20 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
fbf8a60b7b930de2742fc70ec47fc8300a70db5c
Parents:
bf183f6e9bba75d2e45f3db83852e93ecae6d90d
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2010-11-10 13:39:20+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:55:37+01:00
Message:
p_Content, pCleardenom
Location:
polys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • polys/monomials/p_polys.cc

    rbf183f r8d1d30c  
    16961696  return rc;
    16971697}
     1698
     1699/* --------------------------------------------------------------------------------*/
     1700/* content suff                                                                   */
     1701
     1702static number p_InitContent(poly ph, const ring r);
     1703static number p_InitContent_a(poly ph, const ring r);
     1704
     1705void p_Content(poly ph, const ring r)
     1706{
     1707#ifdef HAVE_RINGS
     1708  if (rField_is_Ring(r))
     1709  {
     1710    if ((ph!=NULL) && rField_has_Units(r))
     1711    {
     1712      number k = nGetUnit(pGetCoeff(ph));
     1713      if (!n_IsOne(k,r->cf))
     1714      {
     1715        number tmpGMP = k;
     1716        k = n_Invers(k,r->cf);
     1717        n_Delete(&tmpGMP,r->cf);
     1718        poly h = pNext(ph);
     1719        p_SetCoeff(ph, n_Mult(pGetCoeff(ph), k,r->cf),r);
     1720        while (h != NULL)
     1721        {
     1722          p_SetCoeff(h, n_Mult(pGetCoeff(h), k,r->cf),r);
     1723          pIter(h);
     1724        }
     1725      }
     1726      n_Delete(&k,r->cf);
     1727    }
     1728    return;
     1729  }
     1730#endif
     1731  number h,d;
     1732  poly p;
     1733
     1734  if(TEST_OPT_CONTENTSB) return;
     1735  if(pNext(ph)==NULL)
     1736  {
     1737    p_SetCoeff(ph,n_Init(1,r),r->cf);
     1738  }
     1739  else
     1740  {
     1741    n_Normalize(pGetCoeff(ph),r->cf);
     1742    if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
     1743    if (rField_is_Q())
     1744    {
     1745      h=p_InitContent(ph,r);
     1746      p=ph;
     1747    }
     1748    else if ((rField_is_Extension(r))
     1749    && ((rPar(r)>1)||(r->minpoly==NULL)))
     1750    {
     1751      h=p_InitContent_a(ph,r);
     1752      p=ph;
     1753    }
     1754    else
     1755    {
     1756      h=n_Copy(pGetCoeff(ph),r->cf);
     1757      p = pNext(ph);
     1758    }
     1759    while (p!=NULL)
     1760    {
     1761      n_Normalize(pGetCoeff(p),r->cf);
     1762      d=n_Gcd(h,pGetCoeff(p),r->cf);
     1763      n_Delete(&h,r->cf);
     1764      h = d;
     1765      if(n_IsOne(h,r->cf))
     1766      {
     1767        break;
     1768      }
     1769      pIter(p);
     1770    }
     1771    p = ph;
     1772    //number tmp;
     1773    if(!n_IsOne(h,r->cf))
     1774    {
     1775      while (p!=NULL)
     1776      {
     1777        //d = nDiv(pGetCoeff(p),h);
     1778        //tmp = nIntDiv(pGetCoeff(p),h);
     1779        //if (!nEqual(d,tmp))
     1780        //{
     1781        //  StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
     1782        //  nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
     1783        //  nWrite(tmp);Print(StringAppendS("\n"));
     1784        //}
     1785        //nDelete(&tmp);
     1786        d = n_IntDiv(pGetCoeff(p),h,r->cf);
     1787        p_SetCoeff(p,d,r);
     1788        pIter(p);
     1789      }
     1790    }
     1791    n_Delete(&h,r->cf);
     1792#ifdef HAVE_FACTORY
     1793    if ( (nGetChar() == 1) || (nGetChar() < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
     1794    {
     1795      singclap_divide_content(ph);
     1796      if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
     1797    }
     1798#endif
     1799    if (rField_is_Q_a(r))
     1800    {
     1801      number hzz = nlInit(1, r->cf);
     1802      h = nlInit(1, r->cf);
     1803      p=ph;
     1804      while (p!=NULL)
     1805      { // each monom: coeff in Q_a
     1806        lnumber c_n_n=(lnumber)pGetCoeff(p);
     1807        napoly c_n=c_n_n->z;
     1808        while (c_n!=NULL)
     1809        { // each monom: coeff in Q
     1810          d=nlLcm(hzz,pGetCoeff(c_n),r->algring);
     1811          n_Delete(&hzz,r->algring);
     1812          hzz=d;
     1813          pIter(c_n);
     1814        }
     1815        c_n=c_n_n->n;
     1816        while (c_n!=NULL)
     1817        { // each monom: coeff in Q
     1818          d=nlLcm(h,pGetCoeff(c_n),r->algring);
     1819          n_Delete(&h,r->algring);
     1820          h=d;
     1821          pIter(c_n);
     1822        }
     1823        pIter(p);
     1824      }
     1825      /* hzz contains the 1/lcm of all denominators in c_n_n->z*/
     1826      /* h contains the 1/lcm of all denominators in c_n_n->n*/
     1827      number htmp=nlInvers(h);
     1828      number hzztmp=nlInvers(hzz);
     1829      number hh=nlMult(hzz,h);
     1830      nlDelete(&hzz,r->algring);
     1831      nlDelete(&h,r->algring);
     1832      number hg=nlGcd(hzztmp,htmp,r->algring);
     1833      nlDelete(&hzztmp,r->algring);
     1834      nlDelete(&htmp,r->algring);
     1835      h=nlMult(hh,hg);
     1836      nlDelete(&hg,r->algring);
     1837      nlDelete(&hh,r->algring);
     1838      nlNormalize(h);
     1839      if(!nlIsOne(h))
     1840      {
     1841        p=ph;
     1842        while (p!=NULL)
     1843        { // each monom: coeff in Q_a
     1844          lnumber c_n_n=(lnumber)pGetCoeff(p);
     1845          napoly c_n=c_n_n->z;
     1846          while (c_n!=NULL)
     1847          { // each monom: coeff in Q
     1848            d=nlMult(h,pGetCoeff(c_n));
     1849            nlNormalize(d);
     1850            nlDelete(&pGetCoeff(c_n),r->algring);
     1851            pGetCoeff(c_n)=d;
     1852            pIter(c_n);
     1853          }
     1854          c_n=c_n_n->n;
     1855          while (c_n!=NULL)
     1856          { // each monom: coeff in Q
     1857            d=nlMult(h,pGetCoeff(c_n));
     1858            nlNormalize(d);
     1859            nlDelete(&pGetCoeff(c_n),r->algring);
     1860            pGetCoeff(c_n)=d;
     1861            pIter(c_n);
     1862          }
     1863          pIter(p);
     1864        }
     1865      }
     1866      nlDelete(&h,r->algring);
     1867    }
     1868  }
     1869}
     1870void p_SimpleContent(poly ph,int smax, const ring r)
     1871{
     1872  if(TEST_OPT_CONTENTSB) return;
     1873  if (ph==NULL) return;
     1874  if (pNext(ph)==NULL)
     1875  {
     1876    p_SetCoeff(ph,n_Init(1,r_cf),r);
     1877    return;
     1878  }
     1879  if ((pNext(pNext(ph))==NULL)||(!rField_is_Q(r)))
     1880  {
     1881    return;
     1882  }
     1883  number d=p_InitContent(ph,r);
     1884  if (nlSize(d,r->cf)<=smax)
     1885  {
     1886    //if (TEST_OPT_PROT) PrintS("G");
     1887    return;
     1888  }
     1889  poly p=ph;
     1890  number h=d;
     1891  if (smax==1) smax=2;
     1892  while (p!=NULL)
     1893  {
     1894#if 0
     1895    d=nlGcd(h,pGetCoeff(p),r->cf);
     1896    nlDelete(&h,r->cf);
     1897    h = d;
     1898#else
     1899    nlInpGcd(h,pGetCoeff(p),r->cf);
     1900#endif
     1901    if(nlSize(h,r->cf)<smax)
     1902    {
     1903      //if (TEST_OPT_PROT) PrintS("g");
     1904      return;
     1905    }
     1906    pIter(p);
     1907  }
     1908  p = ph;
     1909  if (!nlGreaterZero(pGetCoeff(p),r->cf)) h=nlNeg(h,r->cf);
     1910  if(nlIsOne(h,r->cf)) return;
     1911  //if (TEST_OPT_PROT) PrintS("c");
     1912  while (p!=NULL)
     1913  {
     1914#if 1
     1915    d = nlIntDiv(pGetCoeff(p),h,r->cf);
     1916    p_SetCoeff(p,d,r);
     1917#else
     1918    nlInpIntDiv(pGetCoeff(p),h,r->cf);
     1919#endif
     1920    pIter(p);
     1921  }
     1922  nlDelete(&h,r->cf);
     1923}
     1924
     1925static number p_InitContent(poly ph, const ring r)
     1926// only for coefficients in Q
     1927#if 0
     1928{
     1929  assume(!TEST_OPT_CONTENTSB);
     1930  assume(ph!=NULL);
     1931  assume(pNext(ph)!=NULL);
     1932  assume(rField_is_Q(r));
     1933  if (pNext(pNext(ph))==NULL)
     1934  {
     1935    return nlGetNom(pGetCoeff(pNext(ph)),r->cf);
     1936  }
     1937  poly p=ph;
     1938  number n1=nlGetNom(pGetCoeff(p),r->cf);
     1939  pIter(p);
     1940  number n2=nlGetNom(pGetCoeff(p),r->cf);
     1941  pIter(p);
     1942  number d;
     1943  number t;
     1944  loop
     1945  {
     1946    nlNormalize(pGetCoeff(p),r->cf);
     1947    t=nlGetNom(pGetCoeff(p),r->cf);
     1948    if (nlGreaterZero(t,r->cf))
     1949      d=nlAdd(n1,t,r->cf);
     1950    else
     1951      d=nlSub(n1,t,r->cf);
     1952    nlDelete(&t,r->cf);
     1953    nlDelete(&n1,r->cf);
     1954    n1=d;
     1955    pIter(p);
     1956    if (p==NULL) break;
     1957    nlNormalize(pGetCoeff(p),r->cf);
     1958    t=nlGetNom(pGetCoeff(p),r->cf);
     1959    if (nlGreaterZero(t,r->cf))
     1960      d=nlAdd(n2,t,r->cf);
     1961    else
     1962      d=nlSub(n2,t,r->cf);
     1963    nlDelete(&t,r->cf);
     1964    nlDelete(&n2,r->cf);
     1965    n2=d;
     1966    pIter(p);
     1967    if (p==NULL) break;
     1968  }
     1969  d=nlGcd(n1,n2,r->cf);
     1970  nlDelete(&n1,r->cf);
     1971  nlDelete(&n2,r->cf);
     1972  return d;
     1973}
     1974#else
     1975{
     1976  number d=pGetCoeff(ph);
     1977  if(SR_HDL(d)&SR_INT) return d;
     1978  int s=mpz_size1(d->z);
     1979  int s2=-1;
     1980  number d2;
     1981  loop
     1982  {
     1983    pIter(ph);
     1984    if(ph==NULL)
     1985    {
     1986      if (s2==-1) return nlCopy(d,r->cf);
     1987      break;
     1988    }
     1989    if (SR_HDL(pGetCoeff(ph))&SR_INT)
     1990    {
     1991      s2=s;
     1992      d2=d;
     1993      s=0;
     1994      d=pGetCoeff(ph);
     1995      if (s2==0) break;
     1996    }
     1997    else
     1998    if (mpz_size1((pGetCoeff(ph)->z))<=s)
     1999    {
     2000      s2=s;
     2001      d2=d;
     2002      d=pGetCoeff(ph);
     2003      s=mpz_size1(d->z);
     2004    }
     2005  }
     2006  return nlGcd(d,d2,r->cf);
     2007}
     2008#endif
     2009
     2010number p_InitContent_a(poly ph, const ring r)
     2011// only for coefficients in K(a) anf K(a,...)
     2012{
     2013  number d=pGetCoeff(ph);
     2014  int s=naParDeg(d);
     2015  if (s /* naParDeg(d)*/ <=1) return naCopy(d);
     2016  int s2=-1;
     2017  number d2;
     2018  int ss;
     2019  loop
     2020  {
     2021    pIter(ph);
     2022    if(ph==NULL)
     2023    {
     2024      if (s2==-1) return naCopy(d);
     2025      break;
     2026    }
     2027    if ((ss=naParDeg(pGetCoeff(ph)))<s)
     2028    {
     2029      s2=s;
     2030      d2=d;
     2031      s=ss;
     2032      d=pGetCoeff(ph);
     2033      if (s2<=1) break;
     2034    }
     2035  }
     2036  return naGcd(d,d2,r->cf);
     2037}
     2038
     2039
     2040//void pContent(poly ph)
     2041//{
     2042//  number h,d;
     2043//  poly p;
     2044//
     2045//  p = ph;
     2046//  if(pNext(p)==NULL)
     2047//  {
     2048//    pSetCoeff(p,nInit(1));
     2049//  }
     2050//  else
     2051//  {
     2052//#ifdef PDEBUG
     2053//    if (!pTest(p)) return;
     2054//#endif
     2055//    nNormalize(pGetCoeff(p));
     2056//    if(!nGreaterZero(pGetCoeff(ph)))
     2057//    {
     2058//      ph = pNeg(ph);
     2059//      nNormalize(pGetCoeff(p));
     2060//    }
     2061//    h=pGetCoeff(p);
     2062//    pIter(p);
     2063//    while (p!=NULL)
     2064//    {
     2065//      nNormalize(pGetCoeff(p));
     2066//      if (nGreater(h,pGetCoeff(p))) h=pGetCoeff(p);
     2067//      pIter(p);
     2068//    }
     2069//    h=nCopy(h);
     2070//    p=ph;
     2071//    while (p!=NULL)
     2072//    {
     2073//      d=nGcd(h,pGetCoeff(p));
     2074//      nDelete(&h);
     2075//      h = d;
     2076//      if(nIsOne(h))
     2077//      {
     2078//        break;
     2079//      }
     2080//      pIter(p);
     2081//    }
     2082//    p = ph;
     2083//    //number tmp;
     2084//    if(!nIsOne(h))
     2085//    {
     2086//      while (p!=NULL)
     2087//      {
     2088//        d = nIntDiv(pGetCoeff(p),h);
     2089//        pSetCoeff(p,d);
     2090//        pIter(p);
     2091//      }
     2092//    }
     2093//    nDelete(&h);
     2094//#ifdef HAVE_FACTORY
     2095//    if ( (nGetChar() == 1) || (nGetChar() < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
     2096//    {
     2097//      pTest(ph);
     2098//      singclap_divide_content(ph);
     2099//      pTest(ph);
     2100//    }
     2101//#endif
     2102//  }
     2103//}
     2104#if 0
     2105void p_Content(poly ph, const ring r)
     2106{
     2107  number h,d;
     2108  poly p;
     2109
     2110  if(pNext(ph)==NULL)
     2111  {
     2112    p_SetCoeff(ph,n_Init(1,r->cf),r);
     2113  }
     2114  else
     2115  {
     2116    n_Normalize(pGetCoeff(ph),r->cf);
     2117    if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
     2118    h=n_Copy(pGetCoeff(ph),r->cf);
     2119    p = pNext(ph);
     2120    while (p!=NULL)
     2121    {
     2122      n_Normalize(pGetCoeff(p),r->cf);
     2123      d=n_Gcd(h,pGetCoeff(p),r->cf);
     2124      n_Delete(&h,r->cf);
     2125      h = d;
     2126      if(n_IsOne(h,r->cf))
     2127      {
     2128        break;
     2129      }
     2130      pIter(p);
     2131    }
     2132    p = ph;
     2133    //number tmp;
     2134    if(!n_IsOne(h,r->cf))
     2135    {
     2136      while (p!=NULL)
     2137      {
     2138        //d = nDiv(pGetCoeff(p),h);
     2139        //tmp = nIntDiv(pGetCoeff(p),h);
     2140        //if (!nEqual(d,tmp))
     2141        //{
     2142        //  StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
     2143        //  nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
     2144        //  nWrite(tmp);Print(StringAppendS("\n"));
     2145        //}
     2146        //nDelete(&tmp);
     2147        d = n_IntDiv(pGetCoeff(p),h,r->cf);
     2148        p_SetCoeff(p,d,r->cf);
     2149        pIter(p);
     2150      }
     2151    }
     2152    n_Delete(&h,r->cf);
     2153#ifdef HAVE_FACTORY
     2154    //if ( (n_GetChar(r) == 1) || (n_GetChar(r) < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
     2155    //{
     2156    //  singclap_divide_content(ph);
     2157    //  if(!n_GreaterZero(pGetCoeff(ph),r)) ph = p_Neg(ph,r);
     2158    //}
     2159#endif
     2160  }
     2161}
     2162#endif
     2163/* --------------------------------------------------------------------------------*/
     2164/* cleardenom suff                                                                 */
     2165poly p_Cleardenom(poly ph, const ring r)
     2166{
     2167  poly start=ph;
     2168  number d, h;
     2169  poly p;
     2170
     2171#ifdef HAVE_RINGS
     2172  if (rField_is_Ring(r))
     2173  {
     2174    p_Content(ph,r);
     2175    return start;
     2176  }
     2177#endif
     2178  if (rField_is_Zp(r) && TEST_OPT_INTSTRATEGY) return start;
     2179  p = ph;
     2180  if(pNext(p)==NULL)
     2181  {
     2182    if (TEST_OPT_CONTENTSB)
     2183    {
     2184      number n=n_GetDenom(pGetCoeff(p),r->cf);
     2185      if (!n_IsOne(n,r->cf))
     2186      {
     2187        number nn=n_Mult(pGetCoeff(p),n,r->cf);
     2188        n_Normalize(nn,r->cf);
     2189        p_SetCoeff(p,nn,r);
     2190      }
     2191      n_Delete(&n,r->cf);
     2192    }
     2193    else
     2194      p_SetCoeff(p,n_Init(1,r->cf),r);
     2195  }
     2196  else
     2197  {
     2198    h = n_Init(1,r->cf);
     2199    while (p!=NULL)
     2200    {
     2201      n_Normalize(pGetCoeff(p,r->cf));
     2202      d=n_Lcm(h,pGetCoeff(p),r->cf);
     2203      n_Delete(&h,r->cf);
     2204      h=d;
     2205      pIter(p);
     2206    }
     2207    /* contains the 1/lcm of all denominators */
     2208    if(!n_IsOne(h,r->cf))
     2209    {
     2210      p = ph;
     2211      while (p!=NULL)
     2212      {
     2213        /* should be:
     2214        * number hh;
     2215        * nGetDenom(p->coef,&hh);
     2216        * nMult(&h,&hh,&d);
     2217        * nNormalize(d);
     2218        * nDelete(&hh);
     2219        * nMult(d,p->coef,&hh);
     2220        * nDelete(&d);
     2221        * nDelete(&(p->coef));
     2222        * p->coef =hh;
     2223        */
     2224        d=n_Mult(h,pGetCoeff(p),r->cf);
     2225        n_Normalize(d,r->cf);
     2226        p_SetCoeff(p,d,r);
     2227        pIter(p);
     2228      }
     2229      n_Delete(&h,r->cf);
     2230      if (nGetChar()==1)
     2231      {
     2232        loop
     2233        {
     2234          h = n_Init(1,r->cf);
     2235          p=ph;
     2236          while (p!=NULL)
     2237          {
     2238            d=n_Lcm(h,pGetCoeff(p),r->cf);
     2239            n_Delete(&h,r->cf);
     2240            h=d;
     2241            pIter(p);
     2242          }
     2243          /* contains the 1/lcm of all denominators */
     2244          if(!n_IsOne(h,r->cf))
     2245          {
     2246            p = ph;
     2247            while (p!=NULL)
     2248            {
     2249              /* should be:
     2250              * number hh;
     2251              * nGetDenom(p->coef,&hh);
     2252              * nMult(&h,&hh,&d);
     2253              * nNormalize(d);
     2254              * nDelete(&hh);
     2255              * nMult(d,p->coef,&hh);
     2256              * nDelete(&d);
     2257              * nDelete(&(p->coef));
     2258              * p->coef =hh;
     2259              */
     2260              d=n_Mult(h,pGetCoeff(p),r->cf);
     2261              n_Normalize(d,r->cf);
     2262              p_SetCoeff(p,d,r);
     2263              pIter(p);
     2264            }
     2265            n_Delete(&h,r->cf);
     2266          }
     2267          else
     2268          {
     2269            n_Delete(&h,r->cf);
     2270            break;
     2271          }
     2272        }
     2273      }
     2274    }
     2275    if (h!=NULL) n_Delete(&h,r->cf);
     2276 
     2277    p_Content(ph,r);
     2278#ifdef HAVE_RATGRING
     2279    if (rIsRatGRing(r))
     2280    {
     2281      /* quick unit detection in the rational case is done in gr_nc_bba */
     2282      pContentRat(ph);
     2283      start=ph;
     2284    }
     2285#endif
     2286  }
     2287  return start;
     2288}
     2289
     2290void p_Cleardenom_n(poly ph,const ring r,number &c)
     2291{
     2292  number d, h;
     2293  poly p;
     2294
     2295  p = ph;
     2296  if(pNext(p)==NULL)
     2297  {
     2298    c=n_Invers(pGetCoeff(p),r->cf);
     2299    p_SetCoeff(p,n_Init(1,r->cf),r);
     2300  }
     2301  else
     2302  {
     2303    h = n_Init(1,r->cf);
     2304    while (p!=NULL)
     2305    {
     2306      n_Normalize(pGetCoeff(p),r->cf);
     2307      d=n_Lcm(h,pGetCoeff(p),r->cf);
     2308      n_Delete(&h,r->cf);
     2309      h=d;
     2310      pIter(p);
     2311    }
     2312    c=h;
     2313    /* contains the 1/lcm of all denominators */
     2314    if(!n_IsOne(h,r->cf))
     2315    {
     2316      p = ph;
     2317      while (p!=NULL)
     2318      {
     2319        /* should be:
     2320        * number hh;
     2321        * nGetDenom(p->coef,&hh);
     2322        * nMult(&h,&hh,&d);
     2323        * nNormalize(d);
     2324        * nDelete(&hh);
     2325        * nMult(d,p->coef,&hh);
     2326        * nDelete(&d);
     2327        * nDelete(&(p->coef));
     2328        * p->coef =hh;
     2329        */
     2330        d=n_Mult(h,pGetCoeff(p),r->cf);
     2331        n_Normalize(d,r->cf);
     2332        p_SetCoeff(p,d,r);
     2333        pIter(p);
     2334      }
     2335      if (rField_is_Q_a(r))
     2336      {
     2337        loop
     2338        {
     2339          h = n_Init(1,r->cf);
     2340          p=ph;
     2341          while (p!=NULL)
     2342          {
     2343            d=n_Lcm(h,pGetCoeff(p),r->cf);
     2344            n_Delete(&h,r->cf);
     2345            h=d;
     2346            pIter(p);
     2347          }
     2348          /* contains the 1/lcm of all denominators */
     2349          if(!n_IsOne(h,r->cf))
     2350          {
     2351            p = ph;
     2352            while (p!=NULL)
     2353            {
     2354              /* should be:
     2355              * number hh;
     2356              * nGetDenom(p->coef,&hh);
     2357              * nMult(&h,&hh,&d);
     2358              * nNormalize(d);
     2359              * nDelete(&hh);
     2360              * nMult(d,p->coef,&hh);
     2361              * nDelete(&d);
     2362              * nDelete(&(p->coef));
     2363              * p->coef =hh;
     2364              */
     2365              d=n_Mult(h,pGetCoeff(p),r->cf);
     2366              n_Normalize(d,r->cf);
     2367              p_SetCoeff(p,d,r);
     2368              pIter(p);
     2369            }
     2370            number t=n_Mult(c,h,r->cf);
     2371            n_Delete(&c,r->cf);
     2372            c=t;
     2373          }
     2374          else
     2375          {
     2376            break;
     2377          }
     2378          n_Delete(&h,r->cf);
     2379        }
     2380      }
     2381    }
     2382  }
     2383}
     2384
     2385number p_GetAllDenom(poly ph, const ring r)
     2386{
     2387  number d=n_Init(1,r->cf);
     2388  poly p = ph;
     2389
     2390  while (p!=NULL)
     2391  {
     2392    number h=n_GetDenom(pGetCoeff(p),r->cf);
     2393    if (!n_IsOne(h,r->cf))
     2394    {
     2395      number dd=n_Mult(d,h,r->cf);
     2396      n_Delete(&d,r->cf);
     2397      d=dd;
     2398    }
     2399    n_Delete(&h,r->cf);
     2400    pIter(p);
     2401  }
     2402  return d;
     2403}
     2404
    16982405/***************************************************************
    16992406 *
  • polys/monomials/p_polys.h

    rbf183f r8d1d30c  
    297297 *
    298298 ***************************************************************/
     299void      p_Normalize(poly p,const ring r);
     300
     301void      p_Content(poly p, const ring r);
     302void      p_SimpleContent(poly p, int s, const ring r);
     303
     304poly      p_Cleardenom(poly p, const ring r);
     305void      p_Cleardenom_n(poly p, const ring r,number &c);
     306number    p_GetAllDenom(poly ph, const ring r);
     307
    299308static inline void p_Setm(poly p, const ring r);
    300309p_SetmProc p_GetSetmProc(ring r);
  • polys/polys.h

    rbf183f r8d1d30c  
    303303#define   pOne()   p_One(currRing)
    304304
    305 void      p_Content(poly p, const ring r);
    306 void      pSimpleContent(poly p, int s);
    307 poly      p_Cleardenom(poly p, const ring r);
    308 void      p_Cleardenom_n(poly p, const ring r,number &c);
    309 void      p_Normalize(poly p,const ring r);
    310 number    p_GetAllDenom(poly ph, const ring r);
    311305#define   pNormalize(p) p_Normalize(p,currRing)
    312306int       pSize( poly p );
Note: See TracChangeset for help on using the changeset viewer.