Changeset aa98be in git for libpolys/polys/monomials


Ignore:
Timestamp:
Sep 28, 2011, 3:14:16 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
32cc7e437ee85bf7d555756eb824eadce50d50c7
Parents:
f3fb4d02b80a3234382e5318316d68fb66cc1f08
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-09-28 15:14:16+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 16:13:41+01:00
Message:
fix: p_Content for extention fields
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/monomials/p_polys.cc

    rf3fb4d raa98be  
    19581958
    19591959static number p_InitContent(poly ph, const ring r);
    1960 static number p_InitContent_a(poly ph, const ring r);
    19611960
    19621961void p_Content(poly ph, const ring r)
     
    20012000    {
    20022001      h=p_InitContent(ph,r);
    2003       p=ph;
    2004     }
    2005     else if (rField_is_Extension(r)
    2006              &&
    2007              (
    2008               (rPar(r)>1) || rMinpolyIsNULL(r)
    2009              )
    2010             )
    2011     {
    2012       h=p_InitContent_a(ph,r);
    20132002      p=ph;
    20142003    }
     
    20522041    n_Delete(&h,r->cf);
    20532042#ifdef HAVE_FACTORY
    2054     if ( (n_GetChar(r) == 1) || (n_GetChar(r) < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
    2055     {
    2056       singclap_divide_content(ph, r);
    2057       if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
    2058     }
     2043//    if ( (n_GetChar(r) == 1) || (n_GetChar(r) < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
     2044//    {
     2045//      singclap_divide_content(ph, r);
     2046//      if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
     2047//    }
    20592048#endif
    20602049    if (rField_is_Q_a(r))
    20612050    {
    2062       //number hzz = nlInit(1, r->cf);
    2063       h = nlInit(1, r->cf);
    2064       p=ph;
    2065       Werror("longalg missing 1");
    2066 #if 0
    2067       while (p!=NULL)
    2068       { // each monom: coeff in Q_a
    2069         lnumber c_n_n=(lnumber)pGetCoeff(p);
    2070         poly c_n=c_n_n->z;
    2071         while (c_n!=NULL)
    2072         { // each monom: coeff in Q
    2073           d=nlLcm(hzz,pGetCoeff(c_n),r->extRing->cf);
    2074           n_Delete(&hzz,r->extRing->cf);
    2075           hzz=d;
    2076           pIter(c_n);
    2077         }
    2078         c_n=c_n_n->n;
    2079         while (c_n!=NULL)
    2080         { // each monom: coeff in Q
    2081           d=nlLcm(h,pGetCoeff(c_n),r->extRing->cf);
    2082           n_Delete(&h,r->extRing->cf);
    2083           h=d;
    2084           pIter(c_n);
    2085         }
    2086         pIter(p);
    2087       }
    2088       /* hzz contains the 1/lcm of all denominators in c_n_n->z*/
    2089       /* h contains the 1/lcm of all denominators in c_n_n->n*/
    2090       number htmp=nlInvers(h,r->extRing->cf);
    2091       number hzztmp=nlInvers(hzz,r->extRing->cf);
    2092       number hh=nlMult(hzz,h,r->extRing->cf);
    2093       nlDelete(&hzz,r->extRing->cf);
    2094       nlDelete(&h,r->extRing->cf);
    2095       number hg=nlGcd(hzztmp,htmp,r->extRing->cf);
    2096       nlDelete(&hzztmp,r->extRing->cf);
    2097       nlDelete(&htmp,r->extRing->cf);
    2098       h=nlMult(hh,hg,r->extRing->cf);
    2099       nlDelete(&hg,r->extRing->cf);
    2100       nlDelete(&hh,r->extRing->cf);
    2101       nlNormalize(h,r->extRing->cf);
    2102       if(!nlIsOne(h,r->extRing->cf))
    2103       {
     2051      // we only need special handling for alg. ext.
     2052      if (getCoeffType(r->cf)==n_algExt)
     2053      {
     2054        number hzz = n_Init(1, r->cf->extRing->cf);
    21042055        p=ph;
    21052056        while (p!=NULL)
    21062057        { // each monom: coeff in Q_a
    2107           lnumber c_n_n=(lnumber)pGetCoeff(p);
    2108           poly c_n=c_n_n->z;
     2058          poly c_n_n=(poly)pGetCoeff(p);
     2059          poly c_n=c_n_n;
    21092060          while (c_n!=NULL)
    21102061          { // each monom: coeff in Q
    2111             d=nlMult(h,pGetCoeff(c_n),r->extRing->cf);
    2112             nlNormalize(d,r->extRing->cf);
    2113             nlDelete(&pGetCoeff(c_n),r->extRing->cf);
    2114             pGetCoeff(c_n)=d;
     2062            d=n_Lcm(hzz,pGetCoeff(c_n),r->cf->extRing->cf);
     2063            n_Delete(&hzz,r->cf->extRing->cf);
     2064            hzz=d;
    21152065            pIter(c_n);
    21162066          }
    2117           c_n=c_n_n->n;
    2118           while (c_n!=NULL)
    2119           { // each monom: coeff in Q
    2120             d=nlMult(h,pGetCoeff(c_n),r->extRing->cf);
    2121             nlNormalize(d,r->extRing->cf);
    2122             nlDelete(&pGetCoeff(c_n),r->extRing->cf);
    2123             pGetCoeff(c_n)=d;
    2124             pIter(c_n);
     2067        }
     2068        pIter(p);
     2069        /* hzz contains the 1/lcm of all denominators in c_n_n*/
     2070        h=n_Invers(hzz,r->cf->extRing->cf);
     2071        n_Delete(&hzz,r->cf->extRing->cf);
     2072        n_Normalize(h,r->cf->extRing->cf);
     2073        if(!n_IsOne(h,r->cf->extRing->cf))
     2074        {
     2075          p=ph;
     2076          while (p!=NULL)
     2077          { // each monom: coeff in Q_a
     2078            poly c_n=(poly)pGetCoeff(p);
     2079            while (c_n!=NULL)
     2080            { // each monom: coeff in Q
     2081              d=n_Mult(h,pGetCoeff(c_n),r->cf->extRing->cf);
     2082              n_Normalize(d,r->cf->extRing->cf);
     2083              n_Delete(&pGetCoeff(c_n),r->cf->extRing->cf);
     2084              pGetCoeff(c_n)=d;
     2085              pIter(c_n);
     2086            }
     2087            pIter(p);
    21252088          }
    2126           pIter(p);
    21272089        }
    2128       }
    2129       nlDelete(&h,r->extRing->cf);
    2130 #endif
     2090        n_Delete(&h,r->cf->extRing->cf);
     2091      }
    21312092    }
    21322093  }
     
    22772238}
    22782239#endif
    2279 
    2280 number p_InitContent_a(poly ph, const ring r)
    2281 // only for coefficients in K(a)/<minpoly(a)> and K(t_1, t_2, ..., t_n)
    2282 {
    2283   number d=pGetCoeff(ph);
    2284   /* old: int s=n_ParDeg(d,r->cf);   new: */
    2285   int s = p_Totaldegree((poly)d, r->cf->extRing);
    2286   if (s <=1) return n_Copy(d,r->cf);
    2287   int s2=-1;
    2288   number d2;
    2289   int ss;
    2290   loop
    2291   {
    2292     pIter(ph);
    2293     if(ph==NULL)
    2294     {
    2295       if (s2==-1) return n_Copy(d,r->cf);
    2296       break;
    2297     }
    2298     /* old: if ((ss=n_ParDeg(pGetCoeff(ph),r->cf))<s)   new: */
    2299     if ((ss = p_Totaldegree((poly)pGetCoeff(ph), r->cf->extRing)) < s)
    2300     {
    2301       s2=s;
    2302       d2=d;
    2303       s=ss;
    2304       d=pGetCoeff(ph);
    2305       if (s2<=1) break;
    2306     }
    2307   }
    2308   return n_Gcd(d,d2,r->cf);
    2309 }
    2310 
    23112240
    23122241//void pContent(poly ph)
Note: See TracChangeset for help on using the changeset viewer.